generated UTC: 2023-02-13 19:00 latest data: https://clojurians-log.clojureverse.org/shadow-cljs/2023-02-13 messages: 95350 pro tips: * Double click on text to filter by it. (doubleclick + cmd-f for extra points). * Click on date to keep day visible regardless of filter. * Click on time to keep hour visible regardless of filter.
(defmacro <>
([el content] (<> &form &env el content nil))
([el content style] `(~el {:inner-text ~content, :style ~style})))
defmacro?cljs.user=> (ns foo.core$macros)
nil
foo.core$macros=>
foo.core$macros=> (defmacro <>
#_=> ([el content] (<> &form &env el content nil))
#_=> ([el content style] `(~el {:inner-text ~content, :style ~style})))
true
foo.core$macros=> (foo.core/<> 'a "a" nil)
nil
foo.core$macros=> (foo.core/<> 'a "a")
nil
foo.core$macros=> '(foo.core/<> 'a "a")
(foo.core/<> (quote a) "a")
foo.core$macros=> '(foo.core/<> 'a "a" nil)
(foo.core/<> (quote a) "a" nil)
foo.core$macros=> (macroexpand-1'(foo.core/<> 'a "a" nil))
WARNING: Use of undeclared Var foo.core$macros/macroexpand-1' at line 1
TypeError: Cannot read property 'call' of undefined
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a" nil))
((quote a) {:inner-text "a", :style nil})
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a"))
((quote a) {:inner-text "a", :style nil})
shadow-cljs clj-repl and do the macro stuff therecore.specs.alpha is for Clojure therefore it does not have :require-macroscljc files.clj as extension name.cljc, with a main.cljs file:require-macros something that will be loaded by CLJ:require something that will also be loaded by CLJ:require-macros it fails because CLJ is the one loading it and not CLJS.cljc file, I can't use :require-macros too?.cljc file. the CLJS compiler where :require-macros is fine OR Clojure where it is not fine.clj part:require-macros something that is loaded by clojure. everything macro related is clojure.:require somewhere?yarn watch,shadow-cljs watchspace.cljc, change value from 1 to 2.cljs since I never really use Clojure(JVM).clj from .cljs by the way?:require-macros. thats the point:require-macros the .clj files itself:require never :require-macrosrespo.macros namespace, puts too much emphasis on the macro part.polyfill/ folder for bare ClojureScript code anyway..cljs..cljs, so it's okay. now it's .cljs.r.js, which bundles code. But it's using AMD format, which not as useful as CommonJS, so it's barely used now.DllPlugin and DllReferencePlugin but that whole setup is just crazybrowserify might work for what I want. seems easier than webpack at least 🙂browserify -r react -r react-dom and then something combined with -x=reactTsickle converts TypeScript code into a form acceptable to the Closure Compiler. browserify uglifyify envify … they went a little overboard with the ifycoffeeifylib.clj can not access those variablescreate-element into div and span functionscreate-element from macro definitions(defmacro meta' [props & children] `(create-element :meta ~props
(ns respo.alias (:require [respo.core :as core]) (:require-macros [respo.alias])) (def create-element core/create-element) (def create-comp core/create-comp)
alias.clj, but in alias.clj, I don't get the variables defined in alias.cljs.alias.cljsalias.clj?respo.core/create-element instead of create-elementrequire the packages by namereact and react-dom together (or separate) and then still use require to access thembrowserify -r react-dom -x react > react.dom.js and donerequire("react")require("react") without using webpack(:require ["react"]) but without webpack:npm-deps?:npm-deps .. it is so misleading on what it actually does:js-provider for now:js-provider :closure the (:require ["react"]) will attempt to import the npm react package via the closure compilergulp-rev for browserify https://stackoverflow.com/a/33507199/883571:js-provider :require it will just emit a require("react") call, which just works for node.js or when using webpack:js-provider covers how native JS is “provided” by the system--list which does what I need 😉webpack and shadow-cljs instead of just webpack?minimal-xyz projectsshadow-cljs.edn when I have a REPLshadow-cljs.edn 😛exportsrequire then use :npm-modulerequire("shadow-cljs/your.app").some_function():target :node-library (which you seem to be using behind shadow-clj-build/custom) is to condense all namespaces down a more manageable public “API”package.json in that directory with a "main":"./your.app.js" and publish that to npmrequire("your-package") or require("your-package/some.other.ns")require("./relative-path-to/your.app") by setting :output-dir so something other than node_modules/shadow-cljs:npm-module isn’t documented better but it is the basis of all node/JS tool integration so you might want to use thatmaster for a while:npm-module is really better suited to my caserequire for the browser is the thing I’m working on so it isn’t readycljsjs?requireshadow.dom … the prefix stucknpm{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b5c6ddd4d1dac298d6d9dfc6f5dbd0cdc1"}, :content ("[email protected]")} thing work in npm?next will not be seen on npmnext is what you need=>> npm search coleujs No matches found for "coleujs" =>> whois NOT FOUND >>> Last update of WHOIS database: 2017-09-21T03:34:59Z <<<
target folder name? I found :cache-root in code, but it seems only move aot-classes classpath.edn cli-repl.port http.port nrepl.port socket-repl.port to the new folder, left explorer jar-manifest library npm in target/shadow-cljs:cache-root so target/shadow-cljs isn’t hard coded anymore:cache-root 😁"cljs" property in package.jsonbrowserify is making me angry .. just like webpackpackage.jsonpackage.json …browserify-shim as wellbrowserify-shim? can be foundbrowserify-shimpackage.jsonProvidePlugin is basically equal to browserify-shimpackage.json vs. shadow-cljs.edn?bootstrap in particularbootstrap npm package requires custom config in EVERY build toolbootstrap anymore … it just won’t be supported for now{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cab9a2abaea5bde7a9a6a0b98aa4afb2be"}, :content ("[email protected]")}cljsjs packages … but I need some testers 😛{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "82f1eae3e6edf5afe1eee8f1c2ece7faf6"}, :content ("[email protected]")} release I just pushed should fully support :cache-root. It will probably break everything else though 😉=>> yarn watch yarn watch v0.24.6 $ shadow-cljs watch app shadow-cljs - config: /Users/chen/repo/minimal-xyz/minimal-shadow-cljs-browser/shadow-cljs.edn version: SNAPSHOT shadow-cljs - updating dependencies shadow-cljs - dependency update failed - Could not find artifact thheller:shadow-cljs:jar:SNAPSHOT in central () error Command failed with exit code 1.
yarn watch v0.24.6 $ shadow-cljs watch app shadow-cljs - config: /Users/chen/repo/minimal-xyz/minimal-shadow-cljs-browser/shadow-cljs.edn version: 2.0.0-alpha3 shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.0.0-alpha3/shadow-cljs-2.0.0-alpha3.pom from Retrieving org/clojure/clojurescript/1.9.908/clojurescript-1.9.908.pom from Retrieving org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.pom from Retrieving org/clojure/google-closure-library-third-party/0.0-20170809-b9c14c6b/google-closure-library-third-party-0.0-20170809-b9c14c6b.pom from Retrieving org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.pom from Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.pom from Retrieving com/google/javascript/closure-compiler-main/v20170910/closure-compiler-main-v20170910.pom from Retrieving com/google/javascript/closure-compiler-parent/v20170910/closure-compiler-parent-v20170910.pom from Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.pom from Retrieving org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar from Retrieving org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.jar from Retrieving org/clojure/clojurescript/1.9.908/clojurescript-1.9.908.jar from Retrieving org/clojure/google-closure-library-third-party/0.0-20170809-b9c14c6b/google-closure-library-third-party-0.0-20170809-b9c14c6b.jar from Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.jar from Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.jar from
Caused by: java.lang.IllegalArgumentException: No matching field found: close for class sun.net.www.protocol.jar.JarURLConnectioRetrieving thheller/shadow-cljs/2.0.0-alpha3/shadow-cljs-2.0.0-alpha3.jar from shadow-cljs - dependencies updated shadow-cljs - re-building aot cache on startup, that will take some time. shadow-cljs - starting ... Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: close for class sun.net.www.protocol.jar.JarURLConnection, compiling:(compiler.clj:32:3) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3676) at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457) at clojure.lang.Compiler.compile1(Compiler.java:7552) at clojure.lang.Compiler.compile(Compiler.java:7619) at clojure.lang.RT.compile(RT.java:408) at clojure.lang.RT.load(RT.java:453) at clojure.lang.RT.load(RT.java:421) at clojure.core$load$fn__6368.invoke(core.clj:6008) at clojure.core$load.invokeStatic(core.clj:6007) at clojure.core$load.doInvoke(core.clj:5991) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5812) at clojure.core$load_one.invoke(core.clj:5807) at clojure.core$load_lib$fn__6313.invoke(core.clj:5852) at clojure.core$load_lib.invokeStatic(core.clj:5851)
alpha4shadow-cljs - starting ...
failed to start service
{:id :dev-http}
ExceptionInfo: failed to start service
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.runtime.services/start-many/fn--14458 (services.clj:135)
shadow.runtime.services/start-many (services.clj:126)
shadow.runtime.services/start-many (services.clj:105)
shadow.runtime.services/start-all (services.clj:144)
shadow.runtime.services/start-all (services.clj:139)
shadow.cljs.devtools.server/start-system (server.clj:150)
shadow.cljs.devtools.server/start-system (server.clj:94)
shadow.cljs.devtools.server/start! (server.clj:180)
shadow.cljs.devtools.server/start! (server.clj:172)
shadow.cljs.devtools.server/start! (server.clj:175)
shadow.cljs.devtools.server/start! (server.clj:172)
shadow.cljs.devtools.server/from-cli (server.clj:260)
shadow.cljs.devtools.server/from-cli (server.clj:251)
shadow.cljs.devtools.cli/main (cli.clj:92)
shadow.cljs.devtools.cli/main (cli.clj:74)
clojure.core/apply (core.clj:657)
clojure.core/apply (core.clj:652)
shadow.cljs.devtools.cli/-main (cli.clj:132)
shadow.cljs.devtools.cli/-main (cli.clj:130)
clojure.lang.Var.applyTo (Var.java:702)
clojure.core/apply (core.clj:657)
clojure.main/main-opt (main.clj:316)
clojure.main/main-opt (main.clj:312)
clojure.main/main (main.clj:423)
clojure.main/main (main.clj:386)
clojure.lang.Var.applyTo (Var.java:702)
clojure.main.main (main.java:37)
Caused by:
invalid config
In: [:builds :npm 1] val: {:id :npm, :target :npm-module, :output-dir "node_modules/shadow-cljs"} fails spec: :shadow.build.config/build at: [:builds 1] predicate: (contains? % :build-id)
error Command failed with exit code 1.
=>>
{:source-paths ["src"]
:dependencies []
:builds {:app {:output-dir "target/"
:asset-path "."
:target :browser
:modules {:main {:entries [app.main]}}
:devtools {:after-load app.main/reload!}}}}
:npm-moduleshadow-cljs compile npm and not shadow-cljs compile app?"watch": "shadow-cljs watch app",npm found in my config or package.json{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "becdd6dfdad1c993ddd2d4cdfe8c908e908e93dfd2ced6df8b"}, :content ("[email protected]")} pushed[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
Failed to run: ./node_modules/.bin/browserify -d -g envify -r hsl
{:tag :shadow.build.targets.browser/browserify, :command ["./node_modules/.bin/browserify" "-d" "-g" "envify" "-r" "hsl"]}
ExceptionInfo: Failed to run: ./node_modules/.bin/browserify -d -g envify -r hsl
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.build.targets.browser/bundle-js/fn--25574/fn--25583 (browser.clj:461)
shadow.build.targets.browser/bundle-js/fn--25574 (browser.clj:449)
Caused by: IOException: Cannot run program "./node_modules/.bin/browserify": error=2, No such file or directory java.lang.ProcessBuilder.start (ProcessBuilder.java:1048) sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
shadow-cljs dependency in your project?dependencies:
{ mkdirp: '^0.5.1',
'readline-sync': '^1.4.7',
'shadow-cljs-jar': '^0.10.0',
'source-map-support': '^0.4.15',
ws: '^3.0.0' },
devDependencies?npm info shadow-cljs"dependencies": {
"browserify": "^14.4.0",
"envify": "^4.1.0",
"mkdirp": "^0.5.1",
"readline-sync": "^1.4.7",
"shadow-cljs-jar": "^0.10.0",
"source-map-support": "^0.4.15",
"uglifyify": "^4.0.4",
"ws": "^3.0.0"
}npm info shadow-cljsnpm info @next thing is getting annoying already 🙂shadow-cljs added to your project so browserify gets installed into node_modules and not the global onebrowserify is installed in node_modules/, but I got no .bin/browserify[:app] Build completed. (112 files, 1 compiled, 0 warnings, 9.15s) Sep 22, 2017 8:57:29 PM clojure.tools.logging$eval486$fn__489 invoke WARNING: build-update: [[:shadow.build.classpath/resource "app/main.cljs"]] [:app] Compiling ... [:app] Build completed. (112 files, 1 compiled, 0 warnings, 0.61s) Sep 22, 2017 8:57:45 PM clojure.tools.logging$eval486$fn__489 invoke WARNING: build-update: [[:shadow.build.classpath/resource "app/lib.cljs"]] [:app] Compiling ... [:app] Build completed. (112 files, 2 compiled, 0 warnings, 0.35s) Sep 22, 2017 8:57:47 PM clojure.tools.logging$eval486$fn__489 invoke WARNING: build-update: [[:shadow.build.classpath/resource "app/lib.cljs"]]
reload! function this timenode_modules/shadow-cljs/node_modules/.bin/browserifynpm does something else entirely .. this is gonna be funnpm links it directly into node_modules/.bin{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a2d1cac3c6cdd58fc1cec8d1e2908c928c928fc3ced2cac394"}, :content ("[email protected]")} should fix the reload issuereload after file change, yes[:app] Compiling ...
[:app] Build failure:
Could not find js dependency "shortid", either install the npm package or define in :js-options
{}
ExceptionInfo: Could not find js dependency "shortid", either install the npm package or define in :js-options
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.build.resolve/resolve-string-require (resolve.clj:127)
shadow.build.resolve/resolve-string-require (resolve.clj:110)
shadow.build.resolve/resolve-require (resolve.clj:227)
shadow.build.resolve/resolve-require (resolve.clj:220)
shadow.build.resolve/resolve-deps/fn--19695 (resolve.clj:56)
clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
npm install shortid? or yarnsuccess Saved 2 new dependencies. ├─
yarn add shortid=>> coffee
coffee> require 'shortid'
Expression assignment to _ now disabled.
{ [Function: generate]
generate: [Circular],
seed: [Function: seed],
worker: [Function: worker],
characters: [Function: characters],
decode: [Function: decode],
isValid: [Function: isShortId] }
'use strict';
module.exports = require('./lib/index');
=>> yarn --version 0.24.6
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f38a92819db3c2ddc3ddc2"}, :content ("[email protected]")}"browser", I only support strings at the moment"main", if its a map the functionality is completely differentmain and browser?browser and browser-overrides or sobrowser has 2 different functions is the annoying partvar clusterWorkerId = require('./util/cluster-worker-id')"./lib/util/cluster-worker-id.js": "./lib/util/cluster-worker-id-browser.js".js exists since .json is also allowed=>> yarn yarn install v1.0.2 [1/4] 🔍 Resolving packages... warning Lockfile has incorrect entry for "
browserify command installed nowhsl and shortidshortid working{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3c4f545d58534b115f50564f7c0e120c120c115d504c545d0b"}, :content ("[email protected]")}:cache-root works very well! I encountered NullPointerException when I compiling a file which using clojure.pprint/pprintNullPointerException:
clojure.lang.Numbers.ops (Numbers.java:1013)
clojure.lang.Numbers.minus (Numbers.java:137)
clojure.lang.Numbers.minus (Numbers.java:3712)
shadow.build.warnings/get-source-excerpts/make-source-excerpt--19935 (warnings.clj:24)
shadow.build.warnings/get-source-excerpts/iter--19937--19941/fn--19942/fn--19943 (warnings.clj:40)
shadow.build.warnings/get-source-excerpts/iter--19937--19941/fn--19942 (warnings.clj:39)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.RT.seq (RT.java:525)
clojure.core/seq--4944 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--7648 (protocols.clj:75)
clojure.core.protocols/fn--7648 (protocols.clj:75)
clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
clojure.core/reduce (core.clj:6704)
clojure.core/into (core.clj:6771)
clojure.core/into (core.clj:6763)
shadow.build.warnings/get-source-excerpts (warnings.clj:41)
shadow.build.warnings/get-source-excerpts (warnings.clj:6)
shadow.build/enhance-warnings (build.clj:29)
shadow.build/enhance-warnings (build.clj:16)
shadow.build/extract-build-info/fn--21260 (build.clj:84)
clojure.core/map/fn--5406 (core.clj:2733)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
clojure.core/chunk-next (core.clj:700)
clojure.core.protocols/fn--7660 (protocols.clj:137)
clojure.core.protocols/fn--7660 (protocols.clj:124)
clojure.core.protocols/fn--7620/G--7615--7629 (protocols.clj:19)
clojure.core.protocols/seq-reduce (protocols.clj:31)
clojure.core.protocols/fn--7648 (protocols.clj:75)
clojure.core.protocols/fn--7648 (protocols.clj:75)
clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
clojure.core/reduce (core.clj:6704)
clojure.core/into (core.clj:6771)
clojure.core/into (core.clj:6763)
shadow.build/extract-build-info (build.clj:86)
shadow.build/extract-build-info (build.clj:59)
shadow.build/update-build-info-after-compile (build.clj:97)
shadow.build/update-build-info-after-compile (build.clj:95)
shadow.build/compile (build.clj:259)
shadow.build/compile (build.clj:248)
shadow.cljs.devtools.api/release* (api.clj:223)
shadow.cljs.devtools.api/release* (api.clj:210)
shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
shadow.cljs.devtools.cli/do-build-command (cli.clj:25)
shadow.cljs.devtools.cli/do-build-commands/fn--538/fn--539 (cli.clj:66)
clojure.core/binding-conveyor-fn/fn--5297 (core.clj:2027)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
java.lang.Thread.run (Thread.java:748)[{:warning :dynamic, :line 776, :column 5, :msg cljs.pprint/*print-base* not declared ^:dynamic, :extra {:ev {:name cljs.pprint/*print-base*, :ns cljs.pprint}, :name cljs.pprint/*print-base*}} {:warning :dynamic, :line 776, :column 5, :msg cljs.pprint/*print-circle* not declared ^:dynamic, :extra {:ev {:name cljs.pprint/*print-circle*, :ns cljs.pprint}, :name cljs.pprint/*print-circle*}} ... This is part warningdead/moved: nullFlushing optimized modules-> Flushing optimized modules Flushing: goog.base.js (99 bytes) dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null Flushing: goog.math.integer.js (3813 bytes) dead/moved: null dead/moved: null dead/moved: null Flushing: cljs.core.js (138248 bytes) dead/moved: null Flushing: cljs.core.async.impl.buffers.js (140 bytes) dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null Flushing: cljs.core.async.impl.timers.js (220 bytes) dead/moved: null Flushing: cljs.core.async.js (807 bytes) Flushing: clojure.string.js (1508 bytes) dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null dead/moved: null Flushing: module$axios.js (137 bytes) dead/moved: null Flushing: cljs.nodejs.js (151 bytes) Flushing: hubot.utils.macro.js (4168 bytes) Flushing: hubot.utils.js (513 bytes) Flushing: hubot.notify.js (5460 bytes) dead/moved: null Flushing: hubot.todoist.js (1350 bytes) Flushing: cljs.pprint.js (138907 bytes) Flushing: module$fs.js (142 bytes) Flushing: module$path.js (136 bytes) Flushing: module$glob.js (136 bytes) Flushing: build.js (2198 bytes) Flushing: hubot.hello.js (1587 bytes) Flushing: hubot.codebuild.js (11703 bytes) <- Flushing optimized modules (11 ms)
:optimizations :none in :buildsshadow-cljs release will always optimize yes. thats the point 🙂shadow-cljs compile or watch will never optimize, no need to set optimizations:simple if you don’t want :advancedtarget/shadow-cljs/cache/ana not work with :cache-root when I called shadow-cljs watchIllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: java.lang.Boolean
clojure.core/-cache-protocol-fn (core_deftype.clj:583)
(io.clj:35)
(io.clj:413)
(io.clj:426)
(io.clj:418)
shadow.build.npm/make-browser-overrides/fn--19590 (npm.clj:29)
clojure.core/fn--7874/fn--7876 (core.clj:6716)
clojure.core.protocols/iter-reduce (protocols.clj:49)
clojure.core.protocols/fn--7652 (protocols.clj:75)
clojure.core.protocols/fn--7652 (protocols.clj:75)
clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
clojure.core/reduce (core.clj:6704)
clojure.core/fn--7874 (core.clj:6706)
clojure.core/fn--7874 (core.clj:6706)
clojure.core.protocols/fn--7673/G--7668--7682 (protocols.clj:174)
clojure.core/reduce-kv (core.clj:6732)
clojure.core/reduce-kv (core.clj:6723)
shadow.build.npm/make-browser-overrides (npm.clj:22)
shadow.build.npm/make-browser-overrides (npm.clj:21)
shadow.build.npm/read-package-json (npm.clj:69)
shadow.build.npm/read-package-json (npm.clj:42)
shadow.build.npm/find-package* (npm.clj:149)
shadow.build.npm/find-package* (npm.clj:126)
shadow.build.npm/find-package (npm.clj:155)
shadow.build.npm/find-package (npm.clj:151)
shadow.build.resolve/fn--19721 (resolve.clj:104)
shadow.build.resolve/fn--19721 (resolve.clj:81)
clojure.lang.MultiFn.invoke (MultiFn.java:238)
shadow.build.resolve/resolve-string-require (resolve.clj:122)
shadow.build.resolve/resolve-string-require (resolve.clj:108)
shadow.build.resolve/resolve-string-require (resolve.clj:108)
shadow.build.resolve/resolve-require (resolve.clj:225)
shadow.build.resolve/resolve-require (resolve.clj:218)
shadow.build.resolve/resolve-deps/fn--19705 (resolve.clj:56)
clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
clojure.core/reduce (core.clj:6703)
clojure.core/reduce (core.clj:6686)
shadow.cljs.util/reduce-> (util.clj:46)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.build.resolve/resolve-deps (resolve.clj:54)
shadow.build.resolve/resolve-deps (resolve.clj:37)
shadow.build.resolve/resolve-symbol-require (resolve.clj:215)
shadow.build.resolve/resolve-symbol-require (resolve.clj:189)
shadow.build.resolve/resolve-require (resolve.clj:222)
shadow.build.resolve/resolve-require (resolve.clj:218)
shadow.build.resolve/resolve-deps/fn--19705 (resolve.clj:56)
clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
clojure.core/reduce (core.clj:6703)
clojure.core/reduce (core.clj:6686)
shadow.cljs.util/reduce-> (util.clj:46)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.build.resolve/resolve-deps (resolve.clj:54)
shadow.build.resolve/resolve-deps (resolve.clj:37)
shadow.build.resolve/resolve-symbol-require (resolve.clj:215)
shadow.build.resolve/resolve-symbol-require (resolve.clj:189)
shadow.build.resolve/resolve-require (resolve.clj:222)
shadow.build.resolve/resolve-require (resolve.clj:218)
shadow.build.resolve/resolve-entry (resolve.clj:232)
shadow.build.resolve/resolve-entry (resolve.clj:231)
...shadow.build.npm/make-browser-overrides in source code 😂make-browser-overrides is new, will fix. it doesn’t support "foo":false yet which is used to “ignore” certain require calls in the browseraws-sdk caused this issuepackage airtable tries to map request but it doesn't exist
{:from "request", :to "xhr", :package-name "airtable"}
ExceptionInfo: package airtable tries to map request but it doesn't exist
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.build.npm/make-browser-overrides/fn--19590 (npm.clj:33)
clojure.core/fn--7874/fn--7876 (core.clj:6716)airtable in nodejs, and current shadow-cljs.edn :target is :npm-module"browser": {
"lib/aws.js": "./lib/browser.js",
"fs": false,
"./global.js": "./browser.js",
"./lib/node_loader.js": "./lib/browser_loader.js"
},"lib/aws.js" should be "./lib/aws.js" 😛:js-provider :closure?:npm-module thats :js-provider :require{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9aab1b8bdb6aef4bab5b3aa99ebf7e9f7e9f4b8b5a9b1b8e1"}, :content ("[email protected]")}2.0.0-alpha8, and get the error: java.lang.AssertionError: Assert failed: (cljs-util/is-file-instance? cache-root)
at shadow.cljs.devtools.config$make_cache_dir.invokeStatic(config.clj:112)
at shadow.cljs.devtools.config$make_cache_dir.invoke(config.clj:112)
at shadow.cljs.devtools.server.worker.impl$build_configure.invokeStatic(impl.clj:116)
at shadow.cljs.devtools.server.worker.impl$build_configure.invoke(impl.clj:90)
at shadow.cljs.devtools.server.worker.impl$fn__21954.invokeStatic(impl.clj:207)
at shadow.cljs.devtools.server.worker.impl$fn__21954.invoke(impl.clj:199)
at clojure.lang.MultiFn.invoke(MultiFn.java:233)
at shadow.cljs.devtools.server.util$server_thread$fn__21838$fn__21839$fn__21843.invoke(util.clj:159)
at shadow.cljs.devtools.server.util$server_thread$fn__21838$fn__21839.invoke(util.clj:158)
at shadow.cljs.devtools.server.util$server_thread$fn__21838.invoke(util.clj:143)
at clojure.core.async$thread_call$fn__7981.invoke(async.clj:442)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)clojure-x.x.x.js and put this file in CDN?:target :npm-module.:advanced optimizations …:modules?a.js and b.js into libs.js in project A,libs.js is the same:browser target you can :modules {:shared {:entries [cljs.core]} :page-a {:entries [app.page-a] :depends-on #{:shared}}, ...}jquery.js that is included in every project and never changed:advanced .. so not sure that would be worth anything:modules is the way to go for :browser:advanced:modules, it does all the code splitting you could ever want:modules?:modules:advanced optimizations …:advanced, which would mean you’d download MORE:simple:advanced … anything that is not :advancedCDN/cljs.js that is 2mbyour-site/cljs.js that is 50kbyour-site/cljs.js will only contain code that your-site uses. so no useless code is executedshadow? 😛:advanced is totally optional .. nobody forces you do use itshadow-build had the first public release on 14 Dec 2013lein-cljsbuild before thatwebpack didn’t exist when I was doing pure JS work 😉node didn’t exist either … I’m old 😉shadow-cljs on github … most of the people are from your regioncljsjs.react{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2b58434a4f445c06484741586b19051b051b064a475b434a1a1b"}, :content ("[email protected]")} which should fix your issues(:require ["airtable" :as ...]) the compiler checks whether node_modules/airtable existsairtable to global or some other parent path:check-packages true|false option so its less strict(:require [react ...]) which is a magical symbol that ONLY works if node_modules/react existspackage.json fileswebpack uses uglifyjs to minify things correct?process.env.NODE_ENV? I thought uglify-js would be able to do that?s, I don't think it's as good as col.. though http://www.southernliving.com/plants/slein-cljs boot-cljs, as a result shadow-cljs sounds like there's a thing called shadow. 😂------ WARNING #1 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:1122:2 unreachable code -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:1155:2 unreachable code -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:2865:2 unreachable code -------------------------------------------------------------------------------- ------ WARNING #4 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:12560:4 unreachable code -------------------------------------------------------------------------------- ------ WARNING #5 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:16870:4 unreachable code -------------------------------------------------------------------------------- ------ WARNING #6 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.development.js:16879:4 unreachable code --------------------------------------------------------------------------------
// Flow needs the return null here, but ESLint complains about it. // eslint-disable-next-line no-unreachable
:externs by accident{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "93e0fbf2f7fce4bef0fff9e0d3a1bda3bda3bef2ffe3fbf2a2a2"}, :content ("[email protected]")} with as many JS dependencies as you can find 😉:externsThe required namespace "cljs.core.async.macros" is not available, it was required by "notifier/core.cljs" {:tag :shadow.build.resolve/missing-ns, :stack [{:resource-id [:shadow.build.classpath/resource "notifier/core.cljs"], :deps #{[:shadow.build.classpath/resource "goog/base.js"] [:shadow.build.classpath/resource "cljs/core.cljs"]}}], :ns cljs.core.async.macros}
ExceptionInfo: The required namespace "cljs.core.async.macros" is not available, it was required by "notifier/core.cljs"
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.build.resolve/resolve-symbol-require (resolve.clj:209)
It only exist when I want to require core.async, when I use [andare](https://github.com/mfikes/andare) (A fork of core.async ported for use with bootstrapped ClojureScript.), shadow-cljs works well, and notify me
duplicate resource cljs/core/async/impl/buffers.cljs on classpath, using jar:file:/Users/c4605/.m2/repository/org/clojure/co re.async/0.3.443/core.async-0.3.443.jar!/cljs/core/async/impl/buffers.cljs over jar:file:/Users/c4605/.m2/repository/andare/andare /0.7.0/andare-0.7.0.jar!/cljs/core/async/impl/buffers.cljs
(:require [cljs.core.async.macros :refer-macros [...], when I switch to :require-macros, the compile passed(:require-macros [cljs.core.async.macros ...]), :require is not valid in this casewatch and repl setup for a web appctrl+c exits the repl instead of exiting the current command, and running it with rlwrap doesn’t allow up-arrow to recall commands from previous sessionctrl+c can work in a CLJS environment, there is nothing like Thread.interrupt in JS. not sure how to make history work.Sep 29, 2017 5:51:17 PM clojure.tools.logging$eval334$fn__337 invoke WARNING: build-update: [[:shadow.build.classpath/resource "respo_ui/comp/home.cljs"] [:shadow.build.classpath/resource "respo_ui/comp/widgets_page.cljs"]] [:browser] Compiling ... [:browser] Build completed. (172 files, 3 compiled, 0 warnings, 0.16s)
shadow-cljs .. I think thats a solid result 🙂:simple so its pretty much the same uglifyjs would doshadow-cljs watch doesn’t use it at all you only need it when you want to optimize.shadow-cljs watch app, it's too much logs... not a big deal though, but I made some changes to my cumulo-editor, print some of the logs in grey, removed some logs, colorized some important one's. It quite much different as it looks.shadow-cljs cljs-repl <build-id>. it’s a browser connected repl you can run alongside watch.:target :nodejs not working.2.0.2 is current, installable via {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f88b90999c978fd59b94928bb8969d808c"}, :content ("[email protected]")}.@next in the next versionshadow-cljs from within boot? or just standalone?2.0.3 with fix on nodejs hmr.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f6859e97929981db959a9c85b6c4d8c6d8c5"}, :content ("[email protected]")} no more next required@next should not be used anymore?.jsxThe required namespace "cljsjs.highlight" is not available, it was required by "respo_markdown/main.cljs".
cljsjs packages?highlight.js from npm.Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/actionscript.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$actionscript", function(require,module,exports) {module.exports = function(hljs) {
^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/ada.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$ada", function(require,module,exports) {module.exports = // We try to support full Ada2012
^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/apache.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$apache", function(require,module,exports) {module.exports = function(hljs) {
^^^^^^^^^^^^^^^^^^^^^^^^^
:foreign-libs https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html2.0.5. it is not ideal to use their npm package since that will unconditionally include support for ALL languages:js-options
{:resolve
{"highlight.js"
{:target :file
:file "lib/highlight.pack.js"}}}
["highlight.js" :as hljs] in your code, it will include that filecljsjs is actually quite nice in this case:foreign-libs without creating more issues than its worthcljsjs has done in this casehljs.initHighlightingOnLoad; to an externs fileX.prototype.initHighlightingOnLoad; in your caseX is not ideal but it works:compiler-options {:externs ["path/to/file.js"]}shadow-cljs check your-build should tell you that initHighlightingOnLoad is an unknown propertyshadow-cljs check existsevent.target? I notice Closure Compiler optimizes that too?(.-x el) to access ittarget? or the Closure Compiler thought it was not of type Event and renamed it.-xhljs.initHighlightingOnLoad so it renamed it to hljs.Qchljs since it is a bit less aggressive with global varshljs is actually window.hljs...Event, if properties are renamed, it's badlocal variable(let [x 1] ...) x is a local variable"input" {:type :input, :value (aget (.-target event) "value")}
"change" {:type :change, :value (aget (.-target event) "value")}
event is(.-value (.-target event)) the value part will be renamed, but it should be event.target.valueaget and stringevent and not use the correct type:externs example from above X.prototype.value would have been enoughshadow-cljs check might have explained as wellfailed to compile resource: [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"]
{:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"], :url #object[java.net.URL 0x2be3d771 "jar:file:/Users/MattPro/.m2/repository/org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.jar!/cljs/tools/reader/reader_types.cljs"], :file nil, :line 43, :column 1, :source-excerpt {:start-idx 38, :before [";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ";; reader deftypes" ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ""], :line "(deftype StringReader", :after [" [s s-len ^:mutable s-pos]" " Reader" " (read-char [reader]" " (when (> s-len s-pos)" " (let [r (.charAt s s-pos)]"]}}
ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"]
...
Caused by:
ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
clojure.core/symbol (core.clj:579)
clojure.core/symbol (core.clj:574)
cljs.analyzer/dep-has-global-exports? (analyzer.cljc:763)
cljs.analyzer/dep-has-global-exports? (analyzer.cljc:759)
[org.clojure/tools.reader "1.0.5"]2.0.7 which bumps the clj(s) versions, should not affect that error but who knowslein clean to try in a case like this?File: nil -------------------------------------------------------------------------------- ... 42 | 43 | (deftype StringReader -------^------------------------------------------------------------------------ 44 | [s s-len ^:mutable s-pos] ... -------------------------------------------------------------------------------- ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String clojure.core/symbol (core.clj:579) clojure.core/symbol (core.clj:574) cljs.analyzer/dep-has-global-exports? (analyzer.cljc:763)
File: nil 😉 [clojure.tools.reader.reader-types :as read]cljs.closure somewhere?shadow-cljs standalone or embedded in lein or boot?cljs.repl requires cljs.closuretarget/shadow-cljs completely and restart the shadow-cljs process?[clojure.tools.reader.reader-types :as read]
[cljs.repl :as r]:dependencies? maybe there is an old version of closure in there somehow?shadow-cljs clj-repl and then (require 'cljs.repl)shadow-cljs --cli-infomattpro:editor MattPro$ shadow-cljs clj-repl shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.7 shadow-cljs - starting ... WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean? WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean? shadow-cljs - server running at shadow-cljs - socket repl running at localhost:62834 shadow-cljs - nrepl running at localhost/127.0.0.1:62836 shadow-cljs - REPL - see (help), :repl/quit to exit [1:0]~shadow.user=> (require 'cljs.repl) CompilerException java.lang.RuntimeException: Unable to find static field: INFERRED_CONST_CHECKS in class com.google.javascript.jscomp.DiagnosticGroups, compiling:(cljs/closure.clj:100:1)
boolean? warnings shouldn’t be there.lein/profiles.clj i have [lein-count "1.0.2"] [lein-clojars "0.9.1"] [lein-release "1.0.6"][
.lein/profiles.lein/profiles doesn’t affect shadow-cljsshadow-cljs --cli-info?[maven] org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar how does that get there:dependencies?[1:0]~shadow.user=> (require 'cljs.repl) CompilerException java.lang.RuntimeException: No such var: util/normalize-path, compiling:(cljs/closure.clj:1601:22)
target/shadow-cljs just to be safeWARNING‘s about boolean?.cljs/core.cljs [line 988, col 14] No reader function for tag Inf.
{:type :reader-exception, :ex-kind :reader-error, :file "cljs/core.cljs", :line 988, :col 14}
ExceptionInfo: cljs/core.cljs [line 988, col 14] No reader function for tag Inf.
tools.reader in your :dependencies still?1.1.0 is the latest version that fixes the Inf issue aboveshadow-cljs already depends on those things but if you declare them in :dependencies they overwrite the version that shadow-cljs wantsshadow-cljs does not use lein in any way unless you tell it toproject.clj might as well not exist:dependencies in shadow-cljs.ednlein uses to resolve dependencies, so the same rules applytools.reader dep of shadow-cljs should be chosen since its 1.1.0[maven] org/clojure/tools.reader/1.0.3/tools.reader-1.0.3.jarInf error:dependencies so I can track this down properly?lein deps :tree if you have a project.clj anyways[org.clojure/tools.reader "1.1.0"] to your deps (I think)project.clj‘s of my dependencies1.9.854 in --cli-info?maven resolves dependency conflicts[org.clojure/tools.reader "1.1.0"] to shadow-cljs.edn[org.clojure/clojurescript "1.9.854" :scope :provided]:scope "provided"------ WARNING #1 -------------------------------------------------------------- File: :332:1 -------------------------------------------------------------------------------- 328 | "Construct a URI from a string." 329 | [s] 330 | (ty/uri s)) 331 | 332 | (defn uri? -------^------------------------------------------------------------------------ uri? already refers to: cljs.core/uri? being replaced by: cognitect.transit/uri? -------------------------------------------------------------------------------- 333 | "Returns true if x is a transit URI value, false otherwise." 334 | [x] 335 | (ty/isURI x)) 336 | 337 | (defn uuid --------------------------------------------------------------------------------
File: always empty, I need to fix thatgoog.require could not find: cljs.core$macros(ns cljs.js
(:refer-clojure :exclude [require])
(:require-macros [cljs.js :refer [dump-core]]
[cljs.env.macros :as env])
(:require [clojure.string :as string]
[clojure.walk :as walk]
[cljs.env :as env]
[cljs.spec.alpha]
[cljs.analyzer :as ana]
[cljs.compiler :as comp]
[cljs.tools.reader :as r]
[cljs.tools.reader.reader-types :as rt]
[cljs.tagged-literals :as tags]
[goog.crypt.base64 :as base64]
[cljs.source-map :as sm])
(:import [goog.string StringBuffer]))
(js/goog.require "cljs.core$macros")cljs.core$macroscljs.compiler.api/compile-macro-ns or so 🙂:macro-ns option that seems to control itlumo channel...I am very fond of the Language Server Protocol for that also seeing it is now supported everywhere but I haven't got around to doing it:clj or :cljs conditionals?:cljs but that does not seem correct to me?:foreign-libs are bad? 🙂react versions in your page at https://www.maria.cloud/intro:foreign-libs is bad 😉:js-options {:resolve {"react" {:target :global :global "React"}}} in config 😉(ns demo.selfhost
(:require [cljs.js :as self]))
(defn compile-it []
(js/console.log
(self/compile-str
(self/empty-state)
"(ns my.user) (map inc [1 2 3])"
""
{:eval self/js-eval}
identity)))cljs.js has this weird hack for goog.requirebootstrap method for your stuff?cljs.core$macros and othersgoog.require seems bad{:build-id :selfhost
:target :browser
:output-dir "out/demo-selfhost/public/js"
:asset-path "/js"
:build-options
{:self-host
{:module :base
:macros [cljs.core
cljs.spec.alpha]}}
:modules
{:base
{:entries [demo.selfhost]}}}cljs.js does not really require cljs.core$macros when loadinggoog.require usually is a no-opcljs.js does not formally declare the dep on cljs.core$macrosgoog.require out-of-ordershadow-cljs to properly compile macro namespaces you could work with that?lein-cljsbuild config or whatever you are using to build the live.js(ns my.demo (:require [something.foo :as x])) but something.foo is not yet loaded. what happens?load-fn is always called when you (require) something. it is up to load-fn to (a) know if it has already been loaded or not, and if not, (b) provide a source file and analysis cache. the source file can be compiled js or uncompiled clj*load-fn gets namespaces as input and must map that to source. so we need to know which names map to which “files”cljs.core analysis cache + cljs.core$macros w/ cache is 900kb. the maria bundle is 1.5mb, clojure spec + deps is 1.8mb{:type :cljs,
:provides #{cljs.compiler},
:requires
#{cljs.tools.reader goog.string cljs.core goog cljs.env
goog.string.StringBuffer clojure.set cljs.analyzer cljs.source-map
clojure.string},
:resource-name "cljs/compiler.cljc",
:output-name "cljs.compiler.js"}
{:type :cljs,
:provides #{cljs.core$macros},
:requires
#{cljs.compiler cljs.core cljs.env clojure.set cljs.analyzer
clojure.string clojure.walk},
:resource-name "cljs/core$macros.cljc",
:output-name "cljs.core$macros.js"}
{:type :cljs,
:provides #{cljs.analyzer.api},
:requires #{cljs.core goog cljs.env cljs.analyzer},
:resource-name "cljs/analyzer/api.cljc",
:output-name "cljs.analyzer.api.js"}
{:type :cljs,
:provides #{cljs.spec.gen.alpha},
:requires #{cljs.core goog},
:resource-name "cljs/spec/gen/alpha.cljs",
:output-name "cljs.spec.gen.alpha.js"}
{:type :cljs,
:provides #{cljs.spec.alpha$macros},
:requires
#{cljs.core goog cljs.analyzer.api cljs.env cljs.analyzer
clojure.string clojure.walk cljs.spec.gen.alpha},
:resource-name "cljs/spec/alpha$macros.cljc",
:output-name "cljs.spec.alpha$macros.js"}:load or the :resource-name file and compile that'{:build-id :selfhost
:target :browser
:output-dir "out/demo-selfhost/public/js"
:asset-path "/js"
:bootstrap-options
{:entries []
:macros [cljs.spec.alpha]}
:modules
{:base
{:entries [demo.selfhost]}}}:bootstrap-options you declare which namespaces should be precompiledreagent but you don’t use it yourself:entries [reagent.core]:macrosx which requires x$macros:entries to copy the requires sources so cljs.js can compile it(ns demo.selfhost
(:require [cljs.js :as cljs]
[shadow.bootstrap :as boot]))
(boot/init
(fn []
(cljs/compile-str
(cljs/empty-state)
"(ns my.user) (map inc [1 2 3])"
""
{:eval cljs/js-eval
:load boot/load}
identity)))
boot/init function basically is supposed the index from aboveboot/load will download files as necessary from the special folderinit is done async so the cljs.core analyzer data and macros can be loaded lazily:bootstrap-options and the only constant cost is a larger bootstrap.index.json. then users can require any of those namespaces and they will be loaded on demand.shadow.bootstrap/init (& /load) to be compiled together with all the stuff in :bootstrap-options, or could it ‘consume’ any bootstrap.index.json file, provided with a prefix path of where to load the files from?[
/src are the actual sources. /js is the compiled code, /ana is analyzer data:output-dir + “boostrap”/js/foo.js the index will be in /js/bootstrap/index.transit.jsonquil.core under :bootstrap-options :entries, but you don’t have quil.core in your app itselfquil.core requires some goog namespaces that aren’t required anywhere else in your appcljs.analyzer/parse-ns didn’t follow macro dependencies (because it was never including them in cljs builds) so i had to make my own modified version for that.shadow.build.ns-form is the ns parser based on clojure.specparse-ns at all, ever.twbs/bootstrap should finally become usuable https://github.com/twbs/bootstrap/issues/24167 😉master the new :bootstrap-options config entry controls everything:bootstrap-options
{:entries [reagent.core]
:macros [cljs.spec.alpha]}shadow.bootstrap.loaded-libs is an atom which is a set of symbols matching all goog.provided names that have been loaded:load fn should add to that set whenever it loads somethinglein installINFO: duplicate resource cljs/js.cljs on classpath, using jar:file:/Users/MattPro/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/js.cljs over jar:file:/Users/MattPro/.m2/repository/thheller/shadow-cljs/2.0.7/shadow-cljs-2.0.7.jar!/cljs/js.cljs
The required namespace "react" is not available, it was required by "re_view/render_loop.cljs".react is a symbol and not a stringlive.js:680 goog.require could not find: cljs.core$macros
goog.logToConsole_ @ live.js:680
live.js:714 Uncaught Error: goog.require could not find: cljs.core$macros
at Object.goog.require (live.js:714)
at cljs.js.js:15
cljs.js:source-paths:js-options {:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}
"codemirror" {:target :global
:global "CodeMirror"}}}
then should i be able to just put react, react-dom and codemirror in separate script tags and (:require [codemirror :as CM])?(:require ["codemirror" :as CM])The required namespace "codemirror" is not available,:js-options part of your build?Uncaught TypeError: Cannot read property 'provide' of undefined in `shadow.js.provide(“module$codemirror”, function(require,module,exports) {
module.exports=(CodeMirror);
});`shadow.js to the build for now:module {:entries ...}:modules {:main {:entries [shadow.js your.ns]}} should ensure its loaded before the codemirror include(:require ["/path/to/file" :as x]) with relative path support(:require ["some-name" :as x]) and then in :resolve {"some-name" {:target :file :file "path/to/file.js"}}:js-options would frequently be a global thing:target :resource which checks on the classpathx as a dep is something i’ve done a few times.js files are allowed to require othersa.js and that does require("./b"){:foreign-libs [{:file "js/pm.pack.js"
:provides ["pack.prosemirror"]}
{:file "js/pmMarkdown.pack.js"
:requires ["pack.prosemirror" "cljsjs.markdown-it"]
:provides ["pack.prosemirror-markdown"]}]
:npm-deps {:prosemirror-markdown "^0.22.0"}}
export {EditorView, Decoration, DecorationSet} from "prosemirror-view"
export {EditorState, Selection, SelectionRange, TextSelection, NodeSelection, AllSelection, Transaction, Plugin, PluginKey} from "prosemirror-state"
export {keymap} from "prosemirror-keymap"
export {findWrapping, liftTarget, canSplit, canJoin, ReplaceAroundStep, ReplaceStep} from "prosemirror-transform"
export {wrapInList, splitListItem, liftListItem, sinkListItem} from "prosemirror-schema-list"
export {InputRule, wrappingInputRule, textblockTypeInputRule, inputRules, undoInputRule, allInputRules} from "prosemirror-inputrules"
export {Schema, Node, Mark, ResolvedPos, NodeRange, Fragment, Slice, MarkType, NodeType} from "prosemirror-model"
import * as commandsObj from "prosemirror-commands"
export const commands = commandsObj;
import * as historyObj from "prosemirror-history"
export const history = historyObj;
import * as modelObj from "prosemirror-model"
export const model = modelObj;
(:require ["prosemirror-transform" :refer (findWrapping, liftTarget, canSplit, canJoin, ReplaceAroundStep, ReplaceStep)])require to workrequire/`import` to workURL so its built on top of File:resolve {"some-name" {:target :file :file "path/to/file.js"}}Cannot read property 'findInternedVar' of null at line 1 when i eval an expressionbootstrap/init function doesn’t to anything yetjs/bootstrap/js/cljs.core$macros.js:bootstrap-options at all yet(ns shadow-init.init
(:require shadow.js
shadow.bootstrap))
cljs.core analyzer data, 800kb for cljs.core$macros.jsshadow-cljs watch bootstrapuri? warning fixshadow-cljs(defonce
^{:doc "Each runtime environment provides a different way to load a library.
Whatever function *load-fn* is bound to will be passed two arguments - a
map and a callback function: The map will have the following keys:
:name - the name of the library (a symbol)
:macros - modifier signaling a macros namespace load
:path - munged relative library path (a string)
It is up to the implementor to correctly resolve the corresponding .cljs,
.cljc, or .js resource (the order must be respected). If :macros is true
resolution should only consider .clj or .cljc resources (the order must be
respected). Upon resolution the callback should be invoked with a map
containing the following keys:
:lang - the language, :clj or :js
:source - the source of the library (a string)
:file - optional, the file path, it will be added to AST's :file keyword
(but not in :meta)
:cache - optional, if a :clj namespace has been precompiled to :js, can
give an analysis cache for faster loads.
:source-map - optional, if a :clj namespace has been precompiled to :js, can
give a V3 source map JSON
If the resource could not be resolved, the callback should be invoked with
nil."
:dynamic true}
*load-fn*
(fn [m cb]
(throw (js/Error. "No *load-fn* set"))))eval-str which will call back into the load-fnappend-source-map function includes the original source along with the source map, which all needs to be encoded/decoded/shipped. i have source-maps disabled for cljs-live, if we enable them here it would be worth seeing what the effect on speed and file size is with the source file left out(defn compile-it []
(cljs/compile-str
boot/compile-state-ref
"(ns my.user (:require [reagent.core :as r])) (map inc [1 2 3])"
""
{:eval cljs/js-eval
:load boot/load}
print-result))boot/load is called once, with reagent.core:type not :langgoog.provide(cond-> bundle
(or (string/starts-with? v "goog")
(string/starts-with? k "goog")
(and (string/ends-with? k ".js")
;; for a JS file, see if a goog.provide statement shows up
;; in teh first 300 characters.
(some-> v (> (.indexOf (subs v 0 300) "goog.provide") -1))))
;;
;; parse google provide statements to enable dependency resolution
;; for arbitrary google closure modules.
;; this is a slow operation so we don't want to do it on all files.
(update "name-to-path" merge (let [provides (parse-goog-provides v)]
(when (empty? provides)
(log k ": " provides "\n"))
(apply hash-map (interleave provides (repeat k))))))
goog.provide statements happens just when i download/load a ‘bundle’, nothing is eval’d there yet{:lang :js :source js-code :cache ana-data}(defn load [{:keys [name path macros] :as rc} cb]
;; check index build by init
;; find all dependencies
;; load js and ana data via xhr
;; maybe eval?
;; call cb
;; FIXME: needs to ensure that deps are loaded first
(go (let [ana (<! (load-analyzer-data name))
js (<! (load-js name))]
(js/console.log "boot/load" name macros ana (count js))
(cb {:lang :js :source js :cache ana}))
))reagent.core:eval during debugging:
(fn [{:keys [source cache lang name]}]
(println "Eval" {:name name
:lang lang
:cache (some-> cache (str) (subs 0 20))
:source (some-> source (subs 0 150))})
(js/eval source))
(defn compile-it []
(cljs/compile-str
boot/compile-state-ref
"(ns my.user (:require [reagent.core :as r])) (map inc [1 2 3])"
""
{:eval
(fn [{:keys [source cache lang name]}]
(js/console.log "Eval" name lang {:cache (some-> cache (str) (subs 0 20))
:source (some-> source (subs 0 150))})
(js/eval source))
:load boot/load}
print-result))boot/load gets called once with reagent.coreshadow-cljs watch bootstrap, src/dev/demo/selfhost.cljs, open The required namespace "react" is not available, it was required by "reagent/core.cljs".npm install reactThe required JS dependency "%s" is not available, ...compile-str, that’s why it won’t evaleval-str and we get a nice loop i thinkreagent.core over and over:macros is true, but we keep returning reagent.core, which then requests reagent.core$macros again?cljs.core endlessly. damn I wish I could just say “its taken care of, just continue compilation”cljs.js/*loaded*resolve stuffcljs.js/*loaded*?(defn set-loaded [namespaces]
(let [loaded (into #{} (map symbol) namespaces)]
(swap! loaded-ref set/union loaded)
(swap! cljs/*loaded* set/union loaded))) (swap! cljs/*loaded* conj ns)out/demo-selfhost/public/js/base.jsgoog.require('shadow.module.base.append')cat out/demo-selfhost/public/js/cljs-runtime/shadow.module.base.append.js*loaded* it is emptycreate-react-class node dep:source "" trick 404 (Not Found)reagent.core will result in calculating all the transitive deps, downloading in parallel, eval’ing + putting into analysis cache, then returning; or, calculating + downloading all transitive deps, put in cache somewhere, then return to cljs, which will then recurse the :load-fn through all the transitive deps, but not downloading them sequentiallyseq, chunked-seq?, chunk-first, count & others undefinedinit, I tried adding that:
(let [idx (build-index data)
ana-core (<! (load-analyzer-data 'cljs.core))
ana-core$macros (<! (load-analyzer-data 'cljs.core$macros))]
(cljs/load-analysis-cache! compile-state-ref 'cljs.core ana-core)
(cljs/load-analysis-cache! compile-state-ref 'cljs.core$macros ana-core$macros)
(js/eval (<! (load-macro-js 'cljs.core$macros)))
(init-cb)
)
WARNING: Use of undeclared Var cljs.core$macros/seq at line 2 is the warning I getcljs.core/seq as its not a macro but a fncljs.js/patch-alias-map not quite sure what that does yet;; when compiling a macros namespace that requires itself, we need
;; to resolve calls to `my-ns.core/foo` to `my-ns.core$macros/foo`
;; to avoid undeclared variable warnings - António MonteiroFIXME: actually load it all, not just core - loading analyzer caches on init - not sure I understand the intention exactly, but FWIW I think loading/decoding ana caches is something better done at the time the relevant source files are required vs. all at once. (because this can also be slow, these ana caches can be huge.) so for example, the ana cache for cljs.spec.alpha would be downloaded and loaded at the same time as cljs.spec.alpha is required by source code evaluated by the self-host compiler (even if cljs.spec.alpha is already in the app build)boot/load does not load namespaces that are already loadedboot/init needs to do one load for the “missing” analyzer datacljs.js/patch-alias-map does and cljs calls it all over the placemaria.eval/c-stateload should load the ‘missing’ analyzer data only when a namespace is required;; FIXME: this should probably do something async
;; otherwise it will block the entire time 60 or so files
;; are eval'd or transit parsedlazy-map for cljs.analyzer/namespacescompass from like 100 years agocompass weirdness to use sass directlynew cljs.core.Symbol("cljs.core$macros","seq","cljs.core$macros/seq",-1873195024,null) which should probably be cljs.core/seq(ns demo.macro) (defmacro foo [& body] `(seq
new cljs.core.Symbol("demo.macro$macros","seq","demo.macro$macros/seq",-1873195024,null)clojure.string. gotta get that fixed.[:browser] Build failure: The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc".
target/shadow-cljs before trying? it might just be AOT issues[react :as react]cljs/js.cljs override?yarn or npm?yarn add shadow-cljs to the project itselfyarn global add ...shadow-cljs CLI command with yarn run:entries [shadow-eval.core]shadow-eval.core{:name maria.user
:entry #{maria.user}
:provided #{maria.frames.live-frame}
:entry/no-follow #{maria.eval
cljs-live.eval
cljs.js
cljs.compiler
maria.editors.code
maria.repl-specials
cljs.core.match
maria.views.repl-specials
maria.live.analyze
maria.live.source-lookups}
:entry/exclude #{cljs.pprint}}
:bootstrap-options :entries just controls which namespaces are allowed to be used by self-host eval:entry/no-follow excludes a thing, and does not look at its transitive deps at all (it does not specifically exclude all of its transitive deps, because they could be used elsewhere), there are some namespaces (like all those listed above) that I just found to be problematic with self-hostcljs.js is in there 😉:bootstrap-options {:exclude #{cljs.js other syms} to control thatReact is not definedReact global(def ^:dynamic *create-element* js/React.createElement) in re-view-hiccup.hiccup["react" :as react]cljsjs.react, I’m not sure those are available yet seems to work:macros in bootstrap options(defonce _
(boot/init #(swap! state assoc :ready true)))(require '[re-view.core :as v :refer [defview]]) it says :invalid-refer, but if I run (require-macros ...) first, it loads;; FIXME: actually load it all, not just coreshadow-eval.core namespace already uses re-view.core it doesn’t properly load the analyzer data for itcljs/*loaded* (or whatever) with the names of preloaded namespaces, so boot/load isn’t called at all for them*loaded*, but instead just keep that knowledge to ourselves, then when we see them for the first time in boot/load we return the cache + blank jsinit entirelyload and not init*loaded*(+ 1 2) I get an error[
:div "Error: " "#error {:message \"Could not eval [test]\", :data {:tag :cljs/analysis-error}, :cause #error {:message \"Cannot read property 'findInternedVar' of null at line 1 \", :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}"
] but no load is ever calledinit(require '[cljs.core :include-macros true])init is safer to ensure that everything is actually readyloaded-ref and cljs/*loaded*?loaded-ref was also taken out, i didn’t know its purpose:js for a pre-loaded ns, but otherwise the compiler doesn’t need to know they exist until they are requiredloaded-ref is there because of code splitting, well thats the planshadow.bootstrap ends up in the second moduleshadow.bootstrap.set_loaded without having declared a proper dependency on itinitloadcljs.core$macros depends on all that stuff, not the app:js for the pre-loadsclojure.stringboot/load should be called for clojure.string, analyzer data loaded but no js evaledloaded-ref until loaded(require '[re-view.core :as v]) doesn’t seem to do anything*loaded*load async properlyloaded-ref (or *loaded*)(require '[re-view.core :as v :refer [defview]]) works nowself i think is a function parametercells.cell$macros namespace:
(defmacro cell
"Returns an anonymous cell. ..."
([expr]
`(~'cells.cell/cell nil ~expr))
([key expr]
`(let ~lib-bindings
(~'cells.cell/cell* ~(cell-name key) (fn [~'self] ~expr)))))
boot/init and boot/load now take the compiler-state as their first argumentmaria.cloud stuff is seriously cool(require [maria.eval :as e]) and inspect the compiler state is because I’m able to exclude cljs.js. I could attempt to reorganize the whole app around dividing lines based on which namespaces happen to not freak out in self-host, but that could get rather tediouscore.async, and run those functions (compiled) in self-host no problem, because macroexpansion already happened, despite core.async not working in self-host. (mfikes has a fork that does, but many libs don’t use it)gocljs.core.async but not actually do anything without gogo, because it has already been expanded/compiled.:exlude taking a set of namespace symbols for macros that won’t be includedcljs.core.async(shadow.bootstrap/init compile-state-ref {:load-on-init '[shadow-eval.user]} init-cb)shadow.bootstrap is now shadow.cljs.bootstrap.browsercljs/js.cljs anymore, the default now works.init and uses load:target option now:browser build which is the “host” and one :bootstrap build thats just the support files:bootstrap-options:bootstrap-options basically move to {:target :bootstrap :entries ... :macros ... :excludes ... :output-dir "..."}boot/init takes a new :path where to find those files:no-follow option but let’s wait until doing real use cases and see what is actually necessary:path could be on a server somewherecljs.core it resolves to cljs.core.123124123.js or soh2 the request count doesn’t matter so the user really only downloads what is needed:bootstrap-support
{:target :bootstrap
:output-dir "out/demo-selfhost/public/bootstrap"
:entries [demo.macro reagent.core]
:macros []}:bootstrap-path option into the “host” build, rather than in code if that is useful?:js-options :resolve would really need to be shared:macros option still necessary?:js-options :resolve may need to be consistent but not necessarily shared?:bootstrap-path option means. i would expect to copy the output-dir path from my bootstrap build and use that with boot/init:macros is not needed anymore no, only for very special cases probably:resolve is that the names are not constant, so if you configure your build to use a global for "react" you get a variable module$react in your buildmodule$node_modules$react$react or somodule$react but not the other the loader would load it:bootstrap-pathboot/init:bootstrap-host would be your normal app which “hosts” the compiler:bootstrap-support are the support files, all written into one directoryshadow.cljs.bootstrap.browser ns has been updated accordingly:path option:js-options should match for now, need to think about this morewatch for :target :bootstrap probably doesn’t work correctly yetshadow-cljs release mode the file names will be hashed:simple, scary when used to :advanced 😉eval, so overall its probably not worth it(ns reel.comp.container
(:require-macros [respo.macros :refer [defcomp <> div span]])
(:require [hsl.core :refer [hsl]]
[respo-ui.style :as ui]
[respo.core :refer [create-comp]]
[respo.comp.space :refer [=<]]
[reel.comp.reel :refer [comp-reel]]
[reel.comp.todolist :refer [comp-todolist]]))
container.cljs will be reloaded as well when records.cljs changed?records.cljs can affect code in container.cljs, so it doesn’t need to be reloaded(def a 1)b.cljs
; imports a (def b (inc a))c.cljs
; imports b (def c (inc b))
:before-load :after-load functions and avoid global statea.cljs = container.cljs, b=reel, c=recordsc is the container, and a is changing:bootstrap build.
It compiles, but the last example that I had working in 2.0.7 now throws an error when I try to use the macros that I’ve required/referred in the namespace: Cannot read property 'findInternedVar' of null at line 4 \", :data {:file nil, :line 4, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]
Other expressions, like circle and the for macro, work as expected.
Update: if I (require-macros '[cells.cell]), then the other expressions work. Maybe the :load-on-init namespaces aren’t loading their dependencies? (or macro dependencies?) I have shadow-eval.user in :load-on-init.The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc". error in compile. I have tried adding cljs.js and cljs.js$macros and cljs.env.macros and cljs.env.macros$macros to an :exclude option in the build, didn’t seem to make a difference. I can also replicate this in shadow-eval.cljs.js with the bootstrap buildlein:lein true
:nrepl {:port 8703}shadow-cljs.ednshadow-cljs server once and leave runningshadow-cljs watch bootstrap browser then as usuallein via shadow-cljs allows using checkouts and bypasses all AOT headachesshadow-cljs command really is not well suited for testing mastercljs.js in an attempt to fix the problem?:source-paths ["src"
"test"
"checkouts/re_view/src"
"checkouts/re_view_hiccup/src"
"checkouts/re_view_routing/src"
"checkouts/re_view_prosemirror/src"
"checkouts/re_db/src"
"checkouts/cljs_live/src"
"checkouts/shapes"
"checkouts/friendly"
"../../lark/cells/src"
"../../lark/commands/src"
"../../lark/structure/src"
"../../lark/editors/src"
"../../lark/tree/src"]checkouts you don’t really need to add the :source-paths, lein will pick them up:lein true, should i just keep the dependencies in project.clj:source-paths and :dependencies from lein will be used in that case:lein true means is that the JVM will be launched via lein run instead of java:lein {:profile "+cljs"} which will then use the :cljs profile when launching:cljs profile in project.clj and put some dependencies there is neededmaria.live.state will just define a blank atom, then maria.eval will reset the atom to (empty-env) and use itjs/maria.eval.c_statemaria.user.loaders also accesses eval(load-gist ...) is a convenience functioncljs.js allows us to enable eval in self-host, because we can expose a namespace that references cljs.js without following it:lein true is set, can i still have :source-paths that are only in shadow-cljs.ednlein will manage the classpath, which means checkouts workshadow-cljs itself doesn’t support checkouts:excludes #{cljs.js} would ignore ALL macros of that namespace:exclude in master(ns shadow-eval.user
(:require re-view-hiccup.core
[cells.cell :refer [cell defcell]]
[cells.lib :as cell :refer [interval timeout fetch geo-location with-view wait]]
[shapes.core :as shapes :refer [listen
circle square rectangle triangle path text image
position opacity rotate scale
colorize stroke no-stroke fill no-fill
color-names rgb hsl rescale
layer beside above
fish ; for functional geometry demo
;; are these internal only? -jar
assure-shape-seq shape-bounds bounds shape->vector]]
[re-view.core]
[cljs.js])):bootstrap build still needs to compile everything to ensure everything is correct (:require-macros [cljs.core.async.macros :as m]) this compiled with the proper :exclude 😉:exclude (without the $macros)cljs.env.macros issue.clj file https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/env/macros.clj[ :as io] this is not required, not sure why its thee:require as CLJScljs.env.macros as CLJS, which it can’t find since its a .clj file:require in macro files actually resolves as a macromacros.cljc and the io require removed in CLJSEven though the macros are defined in ClojureScript, they are defined in *.clj files. You can, if you wish, also define macros in *.cljc files, but when they are processed, the :cljs branch of reader conditionals will be used.
cljs.js, does it serve any purpose to include transitive macro dependencies of it?[ :as io] which we can’t import anywayscljs.js namespace seems a bit hacky, it shouldn’t even attempt things like requiring cljs.core$macros or the cljs.core analyzer data(require '[cljs.js :as cljs]). I forgot that I even do that.
I’ve tried putting cljs.env.macros into the :exclude but it still throws The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc". on compile. I’m guessing this relates to your comment above:
> it tries to load cljs.env.macros as CLJS, which it can’t find since its a .clj file:require as a CLJS require, ie. it looks for .clj(s|c) files1 2 3 4 5 I only get one resultread and split it, you could get all 5defmacro and do the namespace dance automatically*-str functions in cljs.js thoughdefmacro to self-hosted really should not be that hard, you just can’t use the default compile-str or other *-str fnsdefmacro forms in the JVM instead of generating JS(def foo []) (defmacro bar [] (let [x (foo)] '(whatever ~x))defmacrodefmacro easiercommand-shift-J for view js source. i was on my phone before(in-ns 'cljs.core)
(defn get-expander* [sym env]
(when-not (or (some? (gets env :locals sym)) ; locals hide macros
(and (excluded? env sym) (not (used? env sym))))
(let [nstr (namespace sym)]
(cond
(some? nstr)
(let [ns (get-expander-ns env nstr)]
(when (some? ns)
(.findInternedVar ^clojure.lang.Namespace ns (symbol (name sym)))))
(some? (gets env :ns :rename-macros sym))
(let [qualified-symbol (gets env :ns :rename-macros sym)
nsym (symbol (namespace qualified-symbol))
sym (symbol (name qualified-symbol))]
(.findInternedVar ^clojure.lang.Namespace (find-macros-ns nsym) sym))
:else
(let [cur-ns (gets env :ns :name)]
(or (when (get-in @env/*compiler* [::namespaces cur-ns :defs sym :macro])
(.findInternedVar (find-ns cur-ns) sym))
(let [nsym (gets env :ns :use-macros sym)]
(if (and (some? nsym) (symbol? nsym))
(.findInternedVar ^clojure.lang.Namespace
(find-macros-ns nsym) sym)
(.findInternedVar ^clojure.lang.Namespace
(find-macros-ns CLJS_CORE_MACROS_SYM) sym)))))))))
(in-ns 'maria.user)get-expander* fn :else case to also check in the current ns for macrosget-expander* well enough to workget-expander* hack would be something you do when bootstrapping:dump-core disabled? ie. avoids spitting the cljs core compiler state into cljs.js?shadow-cljs release bootstraprelease:exclude‘d, I think I’d want to just load its analysis cache(doc cljs.js/eval-str) without the require? I’m currently only excluding the cljs.js macro ns from compilation(require ...) it or put it in an (ns ..) formeval happens in a iframe isolated from auth tokens etc.) but that should be more straightforward 🙂master should have a fix for the macro deps, didn’t test it but should work 😛shadow-cljs for quite some time now. I might steal some ideas from Maria for the quick-start mode 😉(require '[cljs.js :as cljs]), still getting the same:
ns cljs.js$macros not available Could not require cljs.js
(require '[cljs.js :as cljs]) this works(ns my.foo (:require [cljs.js :as cljs])) (js/console.log cljs/eval-str)also works
shadow-evalns cljs.js$macros not available:exclude should correctly be called :exclude-macros as its only for excluding macroscljs.js thats basically the same as :entries [cljs.js]shadow-eval project (or my own)target/shadow-cljs?File: :477:1 this is totally weird:bootstrap build?lein or withoutshadow-eval fresh, yarn install and then shadow-cljs watch bootstrap browser. this is after a lein install of shadow-cljs master.cljs.core/uri? warningtarget folderuri? warningcljs.js require error be related to this?shadow-cljs, it appears to work. but in shadow-eval I keep getting this error. staring at shadow-cljs.edn and the source, just can’t see anything of difference------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/zilence/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:673:1 -------------------------------------------------------------------------------- 669 | "Protocol for accessing the metadata of an object." 670 | (^clj-or-nil -meta [o] 671 | "Returns the metadata of object o.")) 672 | 673 | (defprotocol IWithMeta -------^------------------------------------------------------------------------ 674 | "Protocol for adding metadata to an object." 675 | (^clj -with-meta [o meta] 676 | "Returns a new object with value of o and metadata meta added to it.")) 677 | 678 | (defprotocol IReduce -------------------------------------------------------------------------------- Call to cljs.core/defn did not conform to spec In: [1] val: G__34000 fails spec: :clojure.core.specs.alpha/arg-list at: [:args :bs :arity-1 :args] predicate: vector? In: [1] val: G__34000 fails spec: :clojure.core.specs.alpha/args+body at: [:args :bs :arity-n :bodies] predicate: (cat :args :clojure.core.specs.alpha/arg-list :body (alt :prepost+body (cat :prepost map? :body (+ any?)) :body (* any?))) --------------------------------------------------------------------------------
------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/zilence/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:693:1 -------------------------------------------------------------------------------- 689 | (-kv-reduce [coll f init] 690 | "Reduces an associative collection and returns the result. f should be 691 | a function that takes three arguments.")) 692 | 693 | (defprotocol IEquiv -------^------------------------------------------------------------------------ 694 | "Protocol for adding value comparison functionality to a type." 695 | (^boolean -equiv [o other] 696 | "Returns true if o and other are equal, false otherwise.")) 697 | 698 | (defprotocol IHash -------------------------------------------------------------------------------- Call to cljs.core/defn did not conform to spec In: [1] val: G__32443 fails spec: :clojure.core.specs.alpha/arg-list at: [:args :bs :arity-1 :args] predicate: vector? In: [1] val: G__32443 fails spec: :clojure.core.specs.alpha/args+body at: [:args :bs :arity-n :bodies] predicate: (cat :args :clojure.core.specs.alpha/arg-list :body (alt :prepost+body (cat :prepost map? :body (+ any?)) :body (* any?))) --------------------------------------------------------------------------------
node_modules really shouldn’t have any impact on anythingcljs.core at the same time in multiple threads. which should not be an issue since each thread has its own compiler env binding and should be totally isolated.shadow-cljs init(Thread/sleep (rand-int 2000)) before starting the build … fun times 🙂chestnut to get all that going:js-options that react should be resolved to the node module?"react"
{:target :npm
:require "react/cjs/react.development.js"
:require-min "react/cjs/react.production.min.js"}
The required namespace "react" is not available, it was required by "re_view/util.cljc".… would all upstream apps need to use string-require syntax for something like this to work?node_modules/react/cjs/react.development.js exist? I do not yet handle installing node deps:require and :require-min.'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}
:resolve {"react" ...} should work, regardless of whether you do (:require [react]) or (:require ["react" :as react])The required namespace "react" is not available, it was required by "re_view/util.cljc". has a node_modules/react/cjs/react.development.js in the project dir?node_modules/react/package.json is from React v16 pleasereact as a symbolnode_modulesRuntimeException: Unable to find static field: INFERRED_CONST_CHECKS in class com.google.javascript.jscomp.DiagnosticGroups yes old version of something:dependencies? I need a list I can reproduce this with.shadow-cljs first in :dependencieslein thing I can’t do anything about 😞:scope "provided" when using clojurescript in :dependenciesclojurescript themselves in :dependenciesOct 11, 2017 12:09:35 AM clojure.tools.logging$eval15877$fn__15880 invoke
INFO: :shadow.cljs.devtools.server.dev-http/http-serve {:http-port 8705, :http-root out/public, :build-id :browser}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9aab1b8bdb6aef4bab5b3aa99ebf7e9f7e8e9"}, :content ("[email protected]")} with fix:lein true. that bypasses all optimizations I have done to improve startup times and makes everything way slower. makes sense when using a checkout dependency of shadow-cljs itself in a project but otherwise it should be avoided.:lein true:js-options documented?[:browser] Build failure:
errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
{:js-requires ["events" "string_decoder"], :js-imports [], :js-invalid-requires [], :js-language "es3", :js-errors [{:line 374, :column 30, :message "Octal integer literals are not supported in strict mode."} {:line 375, :column 30, :message "Octal integer literals are not supported in strict mode."}], :js-warnings [{:line 36, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 76, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 104, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 117, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 130, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"}], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
<script> tag and then a :js-option {"keypress": {:target :global :global "keypress"}}var EventEmitter = require('events').EventEmitter; events is a node built-inkeypress.js maybe?module without entry or suffix: keypress.js
{:package {:package-name "keypress.js", :package-dir #object[java.io.File 0x2e477178 "/Users/MattPro/Documents/sites2017/keys/node_modules/keypress.js"], :package-json {"name" "keypress.js", "version" "2.1.4", "main" "keypress.js", "description" "a robust keyboard input capturing Javascript utility focused on input for games. For details and documentation, please visit ", "devDependencies" {"jasmine" "1.3.0"}, "spm" {"main" "keypress.js", "ignore" ["compiler.jar"]}}, :version "2.1.4", :dependencies #{}}, :entry "keypress.js"}
ExceptionInfo: module without entry or suffix: keypress.js
"main" : "keypress.js", yet there is no keypress.js file in the directory, only a keypress.coffee{:target :npm
:require "keypress.js/keypress-2.1.4.min.js"}
{"keypress": <the-fn>}# Anonymous Module Definition
if typeof define is "function" and define.amd
define [], ->
return keypress
else if exports?
exports.keypress = keypress
else
window.keypress = keypress
(:require ["keypress.js" :refer (keypress)])5 Dec 2016 still not fixed 😞:type should default to :npm most of the time (convention over configuration they say?) - just an idea @thheller :type? you mean :target? :resolve is optional, the default is to look up :npm. you only specify :resolve if you want to override something.(ns my.app (:require ["keypress.js" :refer [keypress]])) (defonce Keypress (new (.-Listener keypress)))
new $module$node_modules$keypress_js$keypress_2_1_4_min$$.$keypress$.$Listener$;
the referred keypress as well as Listener are renamed by the compiler & so it breaks(ns my.app (:require ["keypress.js" :as KP]
[goog.object :as gobj]))
(defonce Keypress (new (gobj/getValueByKeys KP "keypress" "Listener")))
shadow-cljs check browser with the first version38 | (defonce Keypress (new (.-Listener keypress))) -----------------------------------------^-------------------------------------- Property keypress never defined on module$node_modules$keypress_js$keypress_2_1_4_min
externs.js file somewhere/**
* @externs
*/
/** @constructor */
var X = function() {};
X.prototype.Listener;
X.prototype.keypress;:compiler-options {:externs ["path/to/that-file.js"]}Property keypress never defined on only this part is importantX can be anything, doesn’t have to match module$node_modules$keypress...X.prototype.keypress basically tells the compiler that whenever it finds some.keypress property access and it doesn’t know the type of some to not rename itshadow-cljs script itselfshadow-cljs check is meant as a quick way to find things that need externsshadow-cljs release browser --pseudo-names enables pseudo names to help debugging issues such as thisshadow-cljs release browser --debug but source maps are currently not totally accurate once you use a JS dependency--debug is --source-maps + --pseudo-namesgobj/getValueByKeys 😉:refered names though. those should never need externs.externs file could be generated from a vector of property strings(defn render [] ...) in CLJS, the render name would usually be renamedrender ANYWHERE in the externs it will not be renamedrender propertyrender it will stay.externs.txt, one string per line equals one propertygoog.require('shadow.js.shim.module$fs');
["fs" :as fs])
=>> node target/main.js
SHADOW import error /Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js
/Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js:19
})());
^
ReferenceError: fs is not defined
at /Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server/main.cljs:14:10
at Object.<anonymous> (/Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js
require('fs')/Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/shadow.js.shim.module$fs.jsshadow.js.shim.module$fs = require("fs");goog.provideserver/main.cljs:14:10 whats there?(js/fs.something ...)?(fs/something ...)fs.existsSync is not valid .. use (fs/existsSync ...) (and the others)node_modules, but have it otherwise be treated the same? (somehow I need to include my own fork of Keypress.js with a minimum of fuss)goog.provide("shadow.js.shim.module$fs");
shadow.js.shim.module$fs = require("fs");
fs.x...fs/existsSyncshadow-eval?(defn eval-str [source cb]
(cljs/eval-str
c-state
source
"[test]"
{:eval cljs/js-eval
:load (partial boot/load c-state)
:ns (symbol "shadow-eval.user")}
cb))
"[test]" mean in this example?:resolve {"keypress.js {:target :file :file "path/to/file/from/project-root.js"}}shadow-eval readme. It all works exactly like on my machine 🙂 including the errors in the first two blocks.yarn run shadow-cljs .., does it still use the version specified in package.json?yarn run ... to get the specified version`------ ERROR ------------------------------------------------------------------- File: /Users/zilence/code/tmp/shadow-eval/src/shadow_eval/user.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow-eval.user -------^------------------------------------------------------------------------ 2 | (:require re-view-hiccup.core 3 | [cells.cell :refer [cell]] 4 | [cells.lib :as cell 5 | :refer [interval timeout fetch geo-location with-view] 6 | :refer-macros [wait]] -------------------------------------------------------------------------------- Invalid :refer, var shapes.core/fish does not exist
shadow-cljs will use the version from the project IF installed, otherwise globalfish then it compiles with the cljs.js errors at runtimefish was removedshadow-eval.userrequire cljs.js in the first place?cljs/js.clj can never be loadedrequire tries to load it no matter whatcljs.js just because i want to use shadow-eval to sort out all these issues that are also present in maria, without all the complexity of maria at handshadow-eval.user already ensures that it is loaded?(require '[cljs.js :as cljsjs]) (cljsjs/eval-str ...):exclude or :no-follow or :ana-only or whatever options, ways of somehow saying “i have these namespaces which are preloaded and i just want to load the cache”(require-macros cljs.js):no-follow or whatever is that the user doesn’t need transitive macro deps if cljs.js is already compiled?:exclude is ignored in this case. I can fix that:exclude does or if that is the right name:exclude excludes a macro namespace from compilation:exclude had the effect of only loading the analysis cache for the thingshadow-eval.user loading the cljs.js, it does the correct thing here(ns my.app (:require [cljs.js :as cljs]))shadow-eval.user is loaded by shadow.cljs.bootstrap.browser which is aware of the excludecljs/js.clj 😉go macrogo in self-host)2.0.11release mode, i think it may need to be combined with a clean command of some kind. otherwise the bootstrap directory can’t really be deployed without deleting it / rebuilding manually, because it fills up with multiple versionsclean should probably exist2.0.12 -> :devtools {:http-root ... :http-handler shadow.http.push-state/handle} always returns index.html if files don’t existlocalhost:8702/intro it downloads as a file instead of openingfoo.html which automatically sets content-type based on file ext 😛{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1b68737a7f746c36787771685b29352b352a28"}, :content ("[email protected]")}keypress.js as a github dependency in package.json, and am wondering what I do in that library so that I can depend on it elsewheredeps.cljs in your src root, {:npm-deps {"name-of-dep" "version"}]shadow-cljs npm-deps will attempt to install them but that needs work, I’m not happy with how that workspackage.json in your .jardeps.cljs is probably the way to go for nowcljs.core.async is compiling with a trailing js.map:
cljs.core.async.partition_by.cljs$lang$maxFixedArity = 3; //# sourceMappingURL=cljs.core.async.js.map js.mapsaw it for the first time now in 2.0.13
Uncaught ReferenceError: js is not defined)shadow-eval repo wiki:resolve :target :globalexports.foo = 1; would collect the fooexports.thing = {a: 1}; would collect thing and arequire in JS files/* @constructor */ function ShadowJS() {};
ShadowJS.prototype.$$typeof;
ShadowJS.prototype.Children;
ShadowJS.prototype.Component;
ShadowJS.prototype.PureComponent;
ShadowJS.prototype.ReactCurrentOwner;
ShadowJS.prototype.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
ShadowJS.prototype.__self;
ShadowJS.prototype.__source;
ShadowJS.prototype._owner;
ShadowJS.prototype.assign;
ShadowJS.prototype.children;
ShadowJS.prototype.cloneAndReplaceKey;
ShadowJS.prototype.cloneElement;
ShadowJS.prototype.constructor;
ShadowJS.prototype.context;
ShadowJS.prototype.count;
ShadowJS.prototype.createElement;
ShadowJS.prototype.createFactory;
ShadowJS.prototype.current;
ShadowJS.prototype.enqueueForceUpdate;
ShadowJS.prototype.enqueueReplaceState;
ShadowJS.prototype.enqueueSetState;
ShadowJS.prototype.forEach;
ShadowJS.prototype.forceUpdate;
ShadowJS.prototype.framesToPop;
ShadowJS.prototype.func;
ShadowJS.prototype.isMounted;
ShadowJS.prototype.isPureReactComponent;
ShadowJS.prototype.isReactComponent;
ShadowJS.prototype.isValidElement;
ShadowJS.prototype.key;
ShadowJS.prototype.keyPrefix;
ShadowJS.prototype.map;
ShadowJS.prototype.name;
ShadowJS.prototype.only;
ShadowJS.prototype.props;
ShadowJS.prototype.prototype;
ShadowJS.prototype.ref;
ShadowJS.prototype.refs;
ShadowJS.prototype.render;
ShadowJS.prototype.result;
ShadowJS.prototype.setState;
ShadowJS.prototype.thatReturns;
ShadowJS.prototype.thatReturnsArgument;
ShadowJS.prototype.thatReturnsFalse;
ShadowJS.prototype.thatReturnsNull;
ShadowJS.prototype.thatReturnsThis;
ShadowJS.prototype.thatReturnsTrue;
ShadowJS.prototype.toArray;
ShadowJS.prototype.type;
ShadowJS.prototype.unstable_AsyncComponent;
ShadowJS.prototype.unstable_isAsyncReactComponent;
ShadowJS.prototype.updater;
ShadowJS.prototype.version;;; auto Flushing: base.js (181706 bytes) Flushing: react.js (111923 bytes) Flushing: demo.js (195720 bytes) Flushing: extra.js (136 bytes) Flushing: worker.js (75 bytes) ;; manual Flushing: base.js (181233 bytes) Flushing: react.js (111923 bytes) Flushing: demo.js (195684 bytes) Flushing: extra.js (136 bytes) Flushing: worker.js (75 bytes)
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8bf8e3eaefe4fca6e8e7e1f8cbb9a5bba5babf"}, :content ("[email protected]")} has this enabled by default, if you feel like testing.yarn install firebase and then ["firebase/app" :as firebase]. it is supposed to work with webpack etc.; I get:
ExceptionInfo: no source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
constants.ts vs constants.js, which does exist:npm-deps in deps.cljs does not appear to have any effect, with or without :lein true:npm-deps is not finished. you can try shadow-cljs npm-deps but it has some issuesMaria depends on Commands which has an npm dependency keypress.jskeypress.js need to be in the node_modules of Maria, or can it be in Commands{:npm-deps {"keypress.js" "<version>"}} is in the deps.cljs of the commands projectmaria/node_modules or would it also be picked up in commands/node_modules<project-root>/node_modules/.... never anywhere elseshadow-cljs npm-deps could crawl other projects’ deps.cljs and install all the listed :npm-deps into the current projectconstants.ts instead of constants.js when asking which filename it is processing currentlySEVERE: node_modules/@firebase/util/dist/cjs/src/constants.js:26: Originally at: node_modules/@firebase/util/dist/cjs/src/constants.ts:26: ERROR - @define variable assignment must be global Oct 13, 2017 3:28:12 PM com.google.javascript.jscomp.LoggerErrorManager println SEVERE: node_modules/@firebase/util/dist/cjs/src/constants.js:30: Originally at: node_modules/@firebase/util/dist/cjs/src/constants.ts:31: ERROR - @define variable assignment must be global
@define is a closure annotation, will disable that check if possible{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c5b6ada4a1aab2e8a6a9afb685f7ebf5ebf4f0"}, :content ("[email protected]")}target/shadow-cljs/builds/browser/release/shadow.js.auto_externs.js?target dir, still seem to be getting the same error with firebaseno source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
{:name "node_modules/@firebase/util/dist/cjs/src/constants.ts"}
ExceptionInfo: no source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
["firebase/app" :as firebase] ["firebase/auth"]
:lein true and had not updated the shadow-cljs version in project.cljtarget/shadow-cljs/builds/browser/release/shadow-js/* files zipped or so?a, b, c, Aa, Ab, etc names:js-options {:generate-externs false}(set/superset? properties #{"a" "b" "c" "Aa" "Ab" "Ac"})firebase/app + firebase/auth after["firebase/app" :as firebase] ["firebase/auth"]try
(js/console.log (.auth firebase))authgoog.exportSymbol calls to create the namesZ(a,"EmailAuthProvider",Ig,[]);:infer-externs .. should just use that:infer-externs more, maybe I can combine that in some way:infer-externs was that you sometimes have to annotate your codesome_long_name into a its forced to turn it into abc or whatever:infer-externs, maybe I can find a solution that is more reliable:infer-externs can cover this as well:externs come up pretty much alwaysauth issue mentioned above:infer-externs should cover that:advanced compilation:advanced builds, so it always recompiles all CLJS as well:infer-externs stuff is …(js/console.log (firebase/auth)) got this part figured out(js/console.log (.auth firebase)) is also valid but harder to trackshadow.cljs.bootstrap.browser optional 🙂(:require ["some-name" :as foo]):js-options {:resolve {"some-name" {:target :file :file "path/to/file.js"}}}:externsReact works completely without externs:advanced issues601kb with manual externs to 603kb with generated externsshortid issue, which would be covered by the new stuff# untyped externs will be generated by this file # the filename must match the <id-of-build>.txt # properties are just listed one per line propertyA propertyB # globals are prefixed by global: global:someGlobal
externs/<your-build-id>.txt["propertyA" "propertyB"]{:globals [...] :properties [...]}?deps.cljs to ship :externs but that only works for the “real” externs. not the simplified version.:release builds at the same time. Does not happen if I release builds individually: https://gist.github.com/mhuebert/66fe536fa2f6c96b5e09d33deb6b8617material-components-web, getting errors like:
Oct 16, 2017 4:51:23 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/@material/animation/index.js:143: ERROR - Parse error. '}' expected
export {transformStyleProperties, getCorrectEventName, getCorrectPropertyName};
^
Oct 16, 2017 4:51:23 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/@material/base/component.js:19: ERROR - Parse error. '}' expected
import MDCFoundation from './foundation';
^
release errors: is it possible you are building the same build twice? shadow-cljs release browser browser?(:require ["@material/animation"]) works fine for me?:live, :bootstrap and :trusted builds here: https://github.com/mhuebert/maria/blob/master/editor/shadow-cljs.edn#L36@material is ES6. I haven’t finished that work yetCould not find artifact cljs-live:cljs-live:jar:0.2.9-SNAPSHOT in clojars ()0.2.9?-SNAPSHOT versions in thereThe required namespace "pack.prosemirror-markdown" is not available, it was required by "re_view_prosemirror/markdown.cljs".shadow-cljs release live bootstrap trustedshadow-cljs server firstserver is in a bit of a weird state at the moment. there are several command that act as the server themselves if none is runningserver or clj-repl instance runningdoc/shadow-repl.md intended to explain how to set up a repl? it seems to go in a lot of pathsshadow-cljs.edn :nrepl {:port 7888}server instance is running, which can either be server or watchdoc/shadow-repl.md is not about setup no.shadow-cljs via the REPLshadow-cljs clj-repl [1:0]~shadow.user=> (shadow/release :live) [:live] Compiling ...
shadow-cljs release live(help) at the replshadow-cljs clj-repl is basically the same as lein replshadow-cljs cljs-repl live (while watch is running)(shadow/repl :live)(help) or soCompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(null:1:1) (shadow.cljs.devtools.api/help)?(shadow.cljs.devtools.api/repl :live)dev command looks handy:js-options {:js-provider :closure} but that basically never works 😛material-components-web doesn’t depend on anything you’ll be finebabel to transform ES6 codematerial-ui you get ES3 which was transformed by babel and includes some of the babel-runtimebabel runtime from some package and the closure runtime for othersbabel seems to be the most common ground and is actually fairly goodjsx support for free:js-options {:resolve {"material-components-web" {:target :global :global "MDC"}}}:file might also work if they still ship a bundle?{"material-components-web" {:target :npm :require "material-components-web/dist/material-components-web.js"}}:require-min:js-options do not flow through upstream though, do they? so then whatever consumes re-view-material also has to.. i’m not sure, copy over a JS file somewhere?cljsjs style packages because the chance of conflicts is so damn highHTTP server for build :browser available at: HTTP server for build :bootstrap-host available at:
const el = windowObj['document']['createElement']('div');{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c4b7aca5a0abb3e9a7a8aeb784f6eaf4eaf5fd"}, :content ("[email protected]")}"@material/animation" and it compilesrequire('@material/checkbox/dist/mdc.checkbox'); they do ship commonjs as wellmaterial-components-web is designed primarily as a low-level framework which requires ‘adapters’ to actually use, so i have a lot of ugly code which requires these namespaces and then maps them to react components appropriatelymaterial-ui instead then?material-components-web is actually maintained/developed by google and intended to be a production quality reference implementation{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "20534841444f570d434c4a5360120e100e1210"}, :content ("[email protected]")}(if (contains? #{"es3 es5"} js-language) spot the bug 😉re-view-material, material-components-web was at version 0.14 vs today 0.22, i don’t think they did the cjs dist back then_createClass(MDCCheckboxFoundation, [{
key: 'init',
value: function init() {
this.adapter_.addClass(_constants.cssClasses.UPGRADED);
this.adapter_.registerChangeHandler(this.changeHandler_);
this.installPropertyChangeHooks_();
}
}, {
key: 'destroy',
value: function destroy() {
this.adapter_.deregisterChangeHandler(this.changeHandler_);
this.uninstallPropertyChangeHooks_();
}
/** @return {boolean} */
}class MDCCheckboxFoundation this waykey: 'init' is the property we needshadow-cljs release build --pseudo-namesforeign-lib because its not on npm or custom build?foreign-libs is such a bad ideacheckouts something that will be hard to add?:source-paths, should be enoughreact-dom on the node side of thingspm and pmMarkdown:infer-externs you currently only need to do ^js thingfailed to start service
{:id :dev-http}
ExceptionInfo: failed to start service
clojure.core/ex-info (core.clj:4725)
clojure.core/ex-info (core.clj:4725)
shadow.runtime.services/start-many/fn--194 (services.clj:135)
...
Caused by:
BindException: Address already in use
from trying to run watch after an independent servershadow-cljs watch thing say? connected to server?shadow-cljs compile browser shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.18 shadow-cljs - connected to server
target/shadow-cljs files may been deleted after starting the serverlein tends to do that:lein true in this onewebsite requires prosemirror, which has {:npm-deps {...}} in deps.cljs, should shadow-cljs npm-deps inside the website project have the effect of installing those npm modules?re-view-prosemirror may not be the best example at the moment as it is in transition[reagent "0.8.0-alpha1" :exclusions [cljsjs/create-react-class]]deps.cljs files … 🙂npm-deps things is support for yarn, its currently just calling npm install --save (.serialize this) where serialize shouldn’t be rewritten(.serialize ^js this) have that effect^js tag, so that might not actually work with anything but shadow-cljs^js has always been allowed, just not in combination with :infer-externs I think-> Closure - Optimizing ... IllegalStateException: [GETPROP 14 [length: 31] [source_file: re_view_prosemirror.core.js], EXPR_RESULT 14 [length: 66] [source_file: re_view_prosemirror.core.js]] com.google.common.base.Preconditions.checkState (Preconditions.java:721) com.google.javascript.rhino.Node.replaceChild (Node.java:852) com.google.javascript.jscomp.AggressiveInlineAliases.inlineGlobalAliasIfPossible (AggressiveInlineAliases.java:309) com.google.javascript.jscomp.AggressiveInlineAliases.inlineAliases (AggressiveInlineAliases.java:162) com.google.javascript.jscomp.AggressiveInlineAliases.process (AggressiveInlineAliases.java:111) com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:304) com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:230) com.google.javascript.jscomp.Compiler.performOptimizations (Compiler.java:2457) com.google.javascript.jscomp.Compiler$3.call (Compiler.java:834) com.google.javascript.jscomp.Compiler$3.call (Compiler.java:830) com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:128) com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:862) com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:829) com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:778) sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:497) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28) shadow.build.closure/compile-js-modules (closure.clj:874) shadow.build.closure/compile-js-modules (closure.clj:865) shadow.build.closure/optimize/fn--24464 (closure.clj:1138) shadow.build.closure/optimize (closure.clj:1124) shadow.build.closure/optimize (closure.clj:1115) shadow.build/optimize (build.clj:288) shadow.build/optimize (build.clj:280) shadow.cljs.devtools.api/release* (api.clj:197) shadow.cljs.devtools.api/release* (api.clj:183) shadow.cljs.devtools.cli/do-build-command (cli.clj:29) shadow.cljs.devtools.cli/do-build-command (cli.clj:25) shadow.cljs.devtools.cli/do-build-commands/fn--30494/fn--30495 (cli.clj:66) clojure.core/binding-conveyor-fn/fn--5297 (core.clj:2027) java.util.concurrent.FutureTask.run (FutureTask.java:266) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617) java.lang.Thread.run (Thread.java:745)
AggressiveInlineAliases good namere-view/website(def EditorState prosemirror-state/EditorState)?:refer in ns instead(.-someProp js/pmMarkdown) junknode_moduleswebsite should be enough but its emptyre_view_prosemirror.core.keymap = re_view_prosemirror.core.keymap; re_view_prosemirror.core.commands = re_view_prosemirror.core.commands; re_view_prosemirror.core.model = re_view_prosemirror.core.model; re_view_prosemirror.core.history = re_view_prosemirror.core.history;
(def keymap keymap) (def commands commands) (def model model) (def history history)
:as in the ns if you want to keep those defx = x(let [x x])componentDidUpdate$map__37705__$1_p__37704$$.$componentDidUpdate$ is not a functionShadowJS.prototype.componentDidUpdate it is in my test file for sure:lein true is set, shadow-cljs npm-deps does not appear to install transitive deps. I’ve pushed the config to /website in re-view: https://github.com/braintripping/re-view.git:source-paths in shadow-cljs.edn is identical to :source-paths in project.clj, but commented out. I would expect there to be no difference between where :source-paths are specified when using :lein true. but if I run shadow-cljs npm-deps without specifying the deps in shadow-cljs.edn, they do not install.
if I uncomment :source-paths in shadow-cljs.edn, then it works. (even if I keep :lein true)npm-deps does not use lein, so it doesn’t pickup the dependencies of that, since no :dependencies are listed in shadow-cljs.ednleinlein? just because of the cursive integration or some other reasons?leinthing dependency but also include checkouts/thing/src pathlein install if you change the dependencies of checkoutdeps.edn soon, when that comes I can take advantage of that toolein install-ing, to try shadow-cljs release browser in re_view/website, and you can observe that if componentDidUpdate is not listed in browser.txt, the build breaks. I am not sure why it is not being included in the auto externsshadow-cljs npm-deps first should workyarn is enough since they are in there already https://github.com/braintripping/re-view/blob/master/website/package.jsonnpm install --saveshadow-cljs server and open the page, it will load fine. but if you comment componentDidUpdate in externs/browser.txt and build again, then there is an externs errortarget/shadow-cljs/builds/browser/release/externs.shadow.js I don’t see any lifecycle methods, but I do see isPureReactComponent, isValidElement, other React thingscomponent* fns are missing'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}require calls to collect the dependencies:resolve {"react" ...} override must be done for reactif (typeof instance.componentWillReceiveProps === 'function' && (oldProps !== newProps || oldContext !== newContext)) {
callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
}re_view/src/ the deps.cljs includes some :externs… are these not being picked up?deps.cljs externs are not included:npm-deps doesn’t count as ‘providing’ reactnpm provides react, you just depend on it(:require ["react" ...]):npm-externscljsjs got right, its perfect for thatcljsjs/react dependencies 😞var React; no other is allowed to do thatcomponentDidUpdate? maybe we can solve this by annotating the code?(.componentDidUpdate this)(.componentDidUpdate ^js this)(fn [^react/SyntheticEvent e] I don’t think that is valid? should start with ^js/? i thinkjs/ imply that it is a global variablereactjs-tag?, if so it uses the remainder to write externs(defn js-tag? [x]
(and (symbol? x)
(or (= 'js x)
(= "js" (namespace x)))))^js tag anyways, the type info is optionale is an instance of my-referred-react-thing.SyntheticEvent^js, without the type structure(defn my-fn [^js/Foo.Bar x]
(let [z (.baz x)]
(.-wozz z)))(.componentDidUpdate ^js this) does not appear to have worked(def kmap
"Mapping of convenience keys to React lifecycle method keys."
{:constructor "constructor"
:view/initial-state "$initialState"
:view/state "$state"
:view/did-catch "componentDidCatch"
:view/will-mount "componentWillMount"
:view/did-mount "componentDidMount"
:view/will-receive-props "componentWillReceiveProps"
:view/will-receive-state "componentWillReceiveState"
:view/should-update "shouldComponentUpdate"
:view/will-update "componentWillUpdate"
:view/did-update "componentDidUpdate"
:view/will-unmount "componentWillUnmount"
:view/render "render"})goog.object/setre-view.material.util.componentDidUpdateget-element and other things that make me believe it’s L#100 of that file. plus it is the only place in the project that uses .componentDidUpdate as a host interop call{:my-method ...}, the macro writes these in host interop syntax so that you can use them like (.myMethod the-component) and closure will rewrite it all and it will still work, without any annotations.:view/* stuff goes through that kmap you saw and is never rewritten with host interop syntax(gobj/extend prototype (lifecycle-methods lifecycle-keys) this is most likely it(doto obj (gobj/set (get kmap method-k) (wrap-methods method-k method)))
gobj/set should be fine(fn [{:keys [view/state get-element] :as ^js this}]
...
(.componentDidUpdate this))
`^js there in the arglist fixes the .componentDidUpdate call and I tried adding a custom method to the component and calling it in the same place, also worked.(.componentDidUpdate ^js this) should work as well, not sure why it wouldn’t-> Babel transform: node_modules/@material/animation/index.js <- Babel transform: node_modules/@material/animation/index.js (629 ms) -> Babel transform: node_modules/@material/base/foundation.js <- Babel transform: node_modules/@material/base/foundation.js (34 ms) -> Babel transform: node_modules/@material/base/component.js <- Babel transform: node_modules/@material/base/component.js (59 ms) -> Babel transform: node_modules/@material/ripple/adapter.js <- Babel transform: node_modules/@material/ripple/adapter.js (17 ms) -> Babel transform: node_modules/@material/ripple/constants.js <- Babel transform: node_modules/@material/ripple/constants.js (13 ms) -> Babel transform: node_modules/@material/ripple/util.js <- Babel transform: node_modules/@material/ripple/util.js (44 ms) -> Babel transform: node_modules/@material/ripple/foundation.js <- Babel transform: node_modules/@material/ripple/foundation.js (172 ms) -> Babel transform: node_modules/@material/ripple/index.js <- Babel transform: node_modules/@material/ripple/index.js (48 ms) -> Babel transform: node_modules/@material/selection-control/index.js <- Babel transform: node_modules/@material/selection-control/index.js (9 ms) -> Babel transform: node_modules/@material/checkbox/adapter.js <- Babel transform: node_modules/@material/checkbox/adapter.js (12 ms) -> Babel transform: node_modules/@material/checkbox/constants.js <- Babel transform: node_modules/@material/checkbox/constants.js (6 ms) -> Babel transform: node_modules/@material/checkbox/foundation.js <- Babel transform: node_modules/@material/checkbox/foundation.js (68 ms) -> Babel transform: node_modules/@material/checkbox/index.js <- Babel transform: node_modules/@material/checkbox/index.js (55 ms)
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "087b60696c677f256b64627b483a2638263a3a"}, :content ("[email protected]")}[:browser] Build completed. (334 files, 233 compiled, 0 warnings, 22.40s) down from 47sec^js/Element element (get-element this)get-element for this(defn get-element ^js/Element [args …]).componentDidUpdate now(defn thing [{:keys [foo] :as this}]
(.componentDidUpdate ^js this))(.componentDidUpdate ^js this) issuethis is a destructured binding it is already tagged as cljshadow-cljs server I see
mattpro:editor MattPro$ shadow-cljs server shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.7
yarn run ... it appears to use my old global version instead of local npm versionshadow-cljs script checks for <project>/node_modules/shadow-cljs/cli/lib.js which doesn’t exist anymorenpx shadow-cljs or yarn shadow-cljs to run things:trusted build and just code-split the :live build. there might be tons of overlap … nevermind you are on two domains, so no sharing(enable-console-print!) is never required, shadow-cljs injects that so you don’t have to 😉:trusted build can be advanced compiled, whereas the :live build uses selfhost and so must remain :simple.npm-deps I am seeing:
[:npm-deps-conflict "codemirror" :using :a] [:a "5.30.0" #object[java.net.URL 0x7f3a9c11 "file:/Users/MattPro/Documents/sites2017/lark/tools/src/deps.cljs"]] [:b "5.30.0" #object[java.net.URL 0x7f888518 "jar:file:/Users/MattPro/.m2/repository/lark/tools/0.1.5/tools-0.1.5.jar!/deps.cljs"]]I think because I am using these extra source-paths in lieu of checkouts
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6e1d060f0a0119430d02041d2e5c405e405c5d"}, :content ("[email protected]")}, wasn’t sure if I published the externs inference fix from yesterday alreadywatch a :release? I’m trying to debug keybindings stuff in a windows virtual machine. loading the page across this weird not-really-a-network-boundary is incredibly slow, 2.41 minutes to load the page with 700 requests. it would be faster to advance or simple compile and then have a much smaller bundleuri? was added recently.:none but one filenode_modules/thingnode_module/thing-a/node_modules/thing-bnode_modules/thing-bg already exists, just with a different versionnode_modules/thing during installwatch run, all good, correct files. when i made a release, the wrong version overwrote itnode_modulesinstalling npm deps?npm-deps just blindly called npm install2.0.23 releaseyarn upgrade shadow-cljs[:deps-version-conflict "github:braintripping/Keypress#1442b0a" "braintripping/Keypress#1442b0a" #object[java.net.URL 0x5f9b22c1 "jar:file:/Users/zilence/.m2/repository/lark/tools/0.1.14/tools-0.1.14.jar!/deps.cljs"]]shadow-cljs npm-depsnpm run the same as yarn runnpx over npm run[
github:?package.json is different from the one in deps.cljscljs-live goog.require hacks did not play well with figwheel^boolean not ^:booleanre_view.render_loop.render_loop is actually called more than once per rAf^boolean mistake a number of times in other code bases tooreact and apparently others do#{module$node_modules$object_assign$index
module$node_modules$react$cjs$react_development shadow.js
module$node_modules$fbjs$lib$invariant
module$node_modules$fbjs$lib$emptyObject
module$node_modules$prop_types$lib$ReactPropTypesSecret
module$node_modules$fbjs$lib$emptyFunction
module$node_modules$prop_types$checkPropTypes
module$node_modules$fbjs$lib$warning}#{module$node_modules$object_assign$index
module$node_modules$react$cjs$react_production_min shadow.js
module$node_modules$fbjs$lib$invariant
module$node_modules$fbjs$lib$emptyObject
module$node_modules$fbjs$lib$emptyFunction}react :resolve anymore{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "15667d74717a623876797f6655273b253b2720"}, :content ("[email protected]")} should speed up your builds considerably since babel transformed files are now properly cached{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d1a2b9b0b5bea6fcb2bdbba291e3ffe1ffe3e7"}, :content ("[email protected]")} which adds a new :devtools {:async-require true} option. it will load files using window.fetch in :dev modeyarn run watch with Maria’s 3 builds takes 1.62 seconds 🙂<script src="/js/compiled/shadow-trusted.js" type="text/javascript" defer></script> then, note the defer or async:none buildslein new re-view my-great-app; cd my-great-app; lein figwheel;
lein new re-view my-great-app; cd my-great-app; yarn install; yarn run shadow-cljs npm-deps; yarn run shadow-cljs watch browser;
deps command, and the last into watch, so
yarn run deps; yarn run watch;
npm-deps will be called automatically soonnpm install or yarn install directly is ok i think as the first step (to install shadow-cljs). but the npm-deps part is important because the template shouldn’t have to keep all its transitive deps in package.json.yarn create re-viewnode_moduleslein new re-view xyz; cd xyz; yarn install; # node_modules/shadow-cljs is correct lein figwheel; # node_modules/shadow-cljs is empty
:npm-deps from deps.cljs only?package.json?shadow-cljs-jar is gone tooleft-padyarn install then npm install react and its gonenpm install then everything is finenpm install instead of yarn install firstnpm install react without running npm install firstnpm install with package names does not install things from package.json firstnpm install with a package name uninstalls things?npm install first since then its in the package-lock.jsonnpm install instead of yarn installyarn.lock and then uses yarn to install npm deps 😉npm run Error: missing script: shadow-cljsnpx but i really wish another dep wasn’t necessarynpx should come with npm5npx commands into "scripts" in package.json so the user still just runs npm run ... to activate the scriptnpm shadow-cljs helpnpx shadow-cljs help worksnpm run shadow-cljs help doesn’t work though?"scripts": {
"deps": "npm install; npx shadow-cljs npm-deps;",
"watch": "npx shadow-cljs watch browser;",
"release": "npx shadow-cljs release browser;"
},
npxnpm run deps/watch/releasenpm run looks at "scripts" but not other stuffwatch and so is a bit hidden in the stream, and the other urls (server/socket-repl/nrepl) more obvious. for a tutorial context it might be hard to explain where a user should lookyarn watch
package.json scripts situation seems rather developer-unfriendlyyarn watch with "watch": "npx shadow-cljs watch browser;" then uses npx right? so only fake yarn 😛npx in yarn. just watch: shadow-cljs watch browsernpx XD "watch": "shadow-cljs watch browser;" will use the correct thing as well. shouldn’t need npxyarn is smart enough to use the local install, npm should tooshadow-cljs in node_modules/.bin/Figwheel Says: Your code didn't compile.Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react" (symbol? dep)
out folderlein cljsbuild once prod but not really apples to apples because cljsbuild is running the JS through closure:js-provider :closure doesn’t work for me with shadow 229 vs 260 kb is worth fixing it[
base.jsEventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, Sh`.`229k is not quite accurate 😉shadow-cljs release build works as expected. I happily trade 6kb gzip’d for that 🙂base.js (387838 bytes) vs shadow JS base.js (259697 bytes)223K when compiled properly with closure and externs .. but doesn’t work at runtimenpm-deps is now automatic, no need to call it anymoreJSC_MISSING_PROVIDE_ERROR unless I delete the out folder in-between buildsEventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, $SimpleEventPlugin$`.`var ResponderEventPlugin; var SimpleEventPlugin; var TapEventPlugin; var EnterLeaveEventPlugin; var ChangeEventPlugin; var SelectEventPlugin; var BeforeInputEventPlugin;
re-view to the latest from CLJSJS and now it compiles and runs for me. pushed the updated template.:advanced when JS deps are used. can’t quite figure it out.:preloads compiler option?:devtools not :compiler-options:closure IIRCns or shadow_re_frame/provide_js_deps.cljs?"d3"{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2a59424b4e455d07494640596a18041a041918"}, :content ("[email protected]")}shadow-re-frame/provide-js-deps + the :resolve options in shadow-cljs.edn are a workaround to use libs that require cljsjs stuffcljsjs... not provided errorsBREAKING CHANGE: Removing :foreign-libs supportprovide-js-deps namespace and set the global var that the lib expects(js/goog.exportSymbol "React" react) not the set!cljsjs/react.cljs file really is a better option than resolvereagent fixed it in the alpha version:foreign-libs not just closure{:foreign-libs
[{:file "cljsjs/react/development/react.inc.js",
:provides ["react" "cljsjs.react"],
:file-min "cljsjs/react/production/react.min.inc.js",
:global-exports {react React}}],
:externs ["cljsjs/react/common/react.ext.js"]}cljsjs/react deps.cljs:foreign-lib if node_modules/react doesn’t exist(:require [react]):global-exports to cljsjs then maybe it works.
i wonder if, given the “react” in :provides, the react in :global-exports is redundant?:resolve thingcljsjs.* to global vars runs before the global var is defined(ns cljsjs.d3 (:require ["d3" :as d3])) (js/goog.exportSymbol "d3" d3)
shadow-cljs-foreign-libs package or soshadow.js.provide("module$cljsjs_d3", function(global,require,module,exports) {
module.exports=(d3);
});
d3 has not been defined:compiler-options {:closure-warnings {:global-this :off}}:closure compile working againblessed before, this looks interesting:resolve … not sure how I bring that into Closure yetThe required namespace "cljsjs.react.dom.server" is not available, it was required by "reagent/dom/server.cljs".shadow-re-framelein new re-view instead, works after bumping re-view to 0.4.6base.js (233722 bytes) closure vs shadow base.js (259810 bytes)shadow-re-frame should workEventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, mk`.` again:failed-to-compare "github:braintripping/Keypress#4477249" "github:braintripping/Keypress#4477249" #error {
:cause "TypeError: Invalid SemVer Range: github:braintripping/Keypress#4477249"
:closure-defines {re-frame.trace.trace-enabled? true}day8.re-frame.trace.preloadday8.?goog-define exists?re-frame-tracepackage.json. I think we are on the brink of needing it anyways 😄 :npm-deps is already complicated, the reverse would make it even more complicatedrequire("some-cljs-thing/foo/bar") where that resolves to bar.cljs thats a problemshadow-cljs publish command. would you care where it ended up?node_modules/ and manage it with yarn. I can hardly do anything when I'm not familiar with jar.shadow.cljs.devtools.client.env might already have everything you need?shadow.cljs.devtools.client.env/build-idrepl-call is used to evaluate expressions that you are sending to the browser:preload? like re-frame-trace:preloads [shadow.cljs.devtools.client.hud]uri? issuerelease manuallyrelease is pretty expensive compared to watch(shadow.cljs.devtools.api/release :browser) to a key^boolean type hints seem to have zero effect, in any kind of optimization mode^js tag behaviour?^boolean tag does is remove the cljs.core.truth_ callif(cljs.core.truth_(demo.browser.thing)){...if(demo.browser.thing){ its only really needed in cases where closure is supposed to kill dead codekeyword-identical? comparisons vs. (contains? #{…} the-kw) results in a 2x overall speedup(contains? #{…} the-kw)(contains? the-set-but-from-a-def the-kw)?keyword-identical? with strings. still had correct result, but slightly faster i think to use identical?:simple no, then you’d lose the ability to load individuals namespaces:none constants are not optimized so every keyword or symbol is allocated:simple but still separate files gave me an idealive build, then it slows down 10x when not in :simple:static-fns maybe?live build means loaded by the self-host?live build is :optimizations :simple, nothing fancy. It does load the bootstrap build but I am not using the compiler to perform this testshadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.35 line?echo :foo | shadow-cljs clj-eval --stdin shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.35 :foo
cat script.clj | shadow-cljs clj-eval --stdinnode packages/shadow-cljs/cli/runner.js clj-eval "(shadow/release :thing) (something-after-release)"shadow-cljs clj-eval "(shadow/release :thing) (something-after-release)":simple for bootstrap is not so simple unfortunately:npm-module stuff I have already but that doesn’t quite work------ WARNING #1 -------------------------------------------------------------- File: cljs.core$macros.js:2 namespace "clojure.walk" is required in module cljs.compiler.js but provided in module clojure.walk.js. Is module cljs.compiler.js missing a dependency on module clojure.walk.js? --------------------------------------------------------------------------------
Closure compilation failed with 6 errors --- cljs.js.js:2 namespace "cljs.core$macros" cannot be provided twice
:async-require is what’s behind this weird slowdownjs/setTimeout the start of the test?:after-load fn?(dotimes [n 5]
(js/setTimeout
#(time (tree/ast "..."))
n))
:async-require its normal?js/evals itcompile and not watch?eval(code) is window.eval(code)shadow/build/async-closure-import.js in your project source pathvar createScriptFunction = function(args, body) {
var prevDash = window._,
script = document.createElement('script'),
sibling = document.scripts[0];
script.text = 'var _ = function(' + args + ') {' + body + '\n}';
sibling.parentNode.insertBefore(script, sibling).parentNode.removeChild(script);
var result = window._;
window._ = prevDash;
return result;
};
maybe i should do this with all of the eval’d code from the bootstrapped compiler?function scriptEval(code) {
var node = document.createElement("script");
node.appendChild(document.createTextNode(code));
document.body.append(node);
document.body.removeChild(node);
}evaleval 😛shadow-cljs server — does that need to be restarted after adding this js code{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a7d4cfc6c3c8d08ac4cbcdd4e7958997899491"}, :content ("[email protected]")}Invalid SemVer Range something simple to fix?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "20534841444f570d434c4a5360120e100e1317"}, :content ("[email protected]")}eval is the same speedeval is on that list without commentDon't put try/catch inside computationally intensive functions.
You could try { test() } catch
Functions that contain a try-catch statement (Optimized in V8 commit 9aac80f / V8 5.3 / node 7.x)eval() are ‘likely never optimizable’{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "196a71787d766e347a75736a592b3729372a21"}, :content ("[email protected]")}java processes they are, they also don’t seem to respond to requestsmattpro:shadow-re-frame MattPro$ npx shadow-cljs watch browser shadow-cljs - config: /Users/MattPro/Documents/sites2017/shadow-re-frame/shadow-cljs.edn version: 2.0.37 shadow-cljs - connected to server
lein?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b7c4dfd6d3d8c09ad4dbddc4f785998799848e"}, :content ("[email protected]")} fixes another issue related to npm requires with browser overridesmattpro:shadow-re-frame MattPro$ npx shadow-cljs watch browser
shadow-cljs - config: /Users/MattPro/Documents/sites2017/shadow-re-frame/shadow-cljs.edn version: 2.0.39
events.js:163
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:58762
at Object.exports._errnoException (util.js:1034:11)
at exports._exceptionWithHostPort (util.js:1057:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1096:14)
target/shadow-cljs/*.port files[:live] Build failure: NullPointerException: clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301) shadow.build.npm/find-package-json (npm.clj:78) shadow.build.npm/find-package-json (npm.clj:77) shadow.build.npm/find-package-for-file (npm.clj:90) shadow.build.npm/find-package-for-file (npm.clj:89) shadow.build.npm/find-resource* (npm.clj:604) shadow.build.npm/find-resource* (npm.clj:592) shadow.build.npm/find-resource (npm.clj:670) shadow.build.npm/find-resource (npm.clj:652) shadow.build.resolve/fn--20914 (resolve.clj:81) shadow.build.resolve/fn--20914 (resolve.clj:78) clojure.lang.MultiFn.invoke (MultiFn.java:238) shadow.build.resolve/find-resource-for-symbol (resolve.clj:191) shadow.build.resolve/find-resource-for-symbol (resolve.clj:157) shadow.build.resolve/resolve-symbol-require (resolve.clj:205) shadow.build.resolve/resolve-symbol-require (resolve.clj:201) shadow.build.resolve/resolve-require (resolve.clj:235) shadow.build.resolve/resolve-require (resolve.clj:231) shadow.build.resolve/resolve-deps/fn--20895 (resolve.clj:56) clojure.lang.PersistentVector.reduce (PersistentVector.java:341) clojure.core/reduce (core.clj:6752) clojure.core/reduce (core.clj:6735)
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e405e4440"}, :content ("[email protected]")}var cp = require("child_process");
cp.spawnSync("java", ["-cp", "../target/classes", "Test"], {stdio: "inherit"});
nc -l localhost 8001 exit after a bit[:bootstrap] Build failure: Invalid namespace declaration In: [2] val: ((:require [clojure.walk :refer :all] [thi.ng.dstruct.core :as d] [thi.ng.xerror.core :as err])) fails spec: :shadow.build.ns-form/ns-form predicate: (cat :docstring (? string?) :meta (? map?) :clauses :shadow.build.ns-form/ns-clauses), Extra input
ns related error led me to thi.ng.geom.core.macros.vector, non-selfhost-friendly macros namespace, so I put that in :exclude. then it fails with this math namespace.[ "0.0.908"],` (:require [thi.ng.geom.svg.core :as svg])`Retrieving org/clojure/clojurescript/0.0-3117/clojurescript-0.0-3117.pom from central[thi.ng.geom.svg.core :as svg] to the require of an entry that was in bootstrap[ "0.0.908"] to deps plus that require[:bootstrap-support] Compiling ... failed to inspect cljs file: jar:file:/Users/zilence/.m2/repository/thi/ng/geom-core/0.0.908/geom-core-0.0.908.jar!/thi/ng/geom/core/macros/vector.clj Invalid namespace declaration In: [2] val: ((:require [clojure.walk :refer :all] [thi.ng.dstruct.core :as d] [thi.ng.xerror.core :as err])) fails spec: :shadow.build.ns-form/ns-form predicate: (cat :docstring (? string?) :meta (? map?) :clauses :shadow.build.ns-form/ns-clauses), Extra input
:refer :all is the issue-- Syntax error -------------------
Value has extra input
(... ... (:require
[clojure.walk :refer :all]
[thi.ng.dstruct.core :as d]
[thi.ng.xerror.core :as err]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- Relevant specs -------
:shadow.build.ns-form/ns-form:
(clojure.spec.alpha/cat
:ns
'#{clojure.core/ns}
:name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:meta
(clojure.spec.alpha/? clojure.core/map?)
:clauses
:shadow.build.ns-form/ns-clauses)
-------------------------
Detected 1 errorClosure compilation failed with 1 errors --- EXTERNS:/Users/MattPro/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670 Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
targetvar onExit = require('signal-exit')
onExit(function (code, signal) {
console.log('process exited!')
})(ns respo.test.html
(:require-macros [respo.macros :refer [html
head
title
script
style
meta'
div
link
body]])
(:require [cljs.test :refer-macros [deftest is testing run-tests]]
[respo.test.comp.todolist :refer [comp-todolist]]
[respo.render.html :refer [make-string]]))
:refer-macros works...:require-macros always 😱:refer-macros is actually more robust.:refer directly?thi.ng.math.macros namespace? i wonder if his libs may actually not be that useful unless they are modified to be supported by the self-host compiler directly. (but unsure if that is related to why that namespace can’t be found, seems like a different thing)thi.ng.geom.core.macros.vector is the :refer :all, that would be an easy PR if not for the org formata tries to require macros namespace b, should this work?[:bootstrap] Build failure: The required namespace "shadow-eval.b" is not available, it was required by "shadow_eval/a$macros.cljc".
.cljc file currently.cljc does workshadow-eval.b$macros?shadow-eval.b after which is incorrect I thinka.clj and b.cljc and it buildsb.clj when compiling as a macroa was used to find ba.clj to a.cljc 😉For bootstrapped ClojureScript you could have any of these arrangements: Runtime Code Macro Code foo.cljs foo.clj foo.cljs foo.cljc foo.cljc foo.clj
(:require [thing.b]) in a macrothing.b as in a normal namespaces that just contains functions and not macrosthing/b.cljs that would workthing.b$macros(:require [thing.b]) in a macro should cause thing/b.clj to be compiled as thing.b$macro I can add thatshadow-bootstrap-example with b.clja.cljs :require-macros b.cljc requires c.clj, faila.cljs requires b.clj requires c.clj, failplanck -i test/a.cljsb and c file extensions.clj files, programming became a kind of spiritually elevated art form.clj files at all, because planck does not support JVM clojure.clj with a .cljc file that :require-macros itself library it looks like he needs to rename that file to .cljc, no real way around it(defmacro deffoo [& args]) (deffoo thing 1 2 3)
(defmacro deffoo [& args]) (deffoo thing (js/document.getElementById "foo"))
is just not self-host compatible:refer directly yes, valid in all CLJS:require-macros, didn't even noticed there was a :refer-macros.:require-macros is in a file of the same name basically requireing itself(ns app.lib (:require-macros [app.lib]))
app.lib then only uses :refer:advanced finally.js 4.3mb .map 🙂(contains? @cljs.js/*loaded* 'maria.user$macros) I get falsemaria.user exists thoughcljs.js/*loaded*cljs.js/*loaded* get updated when namespaces are created, repl-style?:cljs.analyzer/namespacescljs.user=> (ns ) nil => (contains? @cljs.js/*loaded* ') false => (contains? (set (keys (:cljs.analyzer/namespaces @cljs.env/*compiler*))) ') true => (require ') No such namespace: , could not locate the_thing/me.cljs, the_thing/me.cljc, or Closure namespace ""
cljs.user=> (ns a.core) nil a.core=> (ns b.core (:require [a.core])) No such namespace: a.core, could not locate a/core.cljs, a/core.cljc, or Closure namespace "a.core"
cljs.user=> (ns a.core) nil a.core=> (def x 10) #'a.core/x a.core=> (ns b.core) nil b.core=> a.core/x 10 b.core=> (require '[a.core :as a]) No such namespace: a.core, could not locate a/core.cljs, a/core.cljc, or Closure namespace "a.core"
shadow-cljs node-repl shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.42 shadow-cljs - connected to server shadow-cljs - starting node-repl [:node-repl] Configuring build. [:node-repl] Compiling ... [:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 11.63s) [3:1]~cljs.user=> JS runtime connected. [3:1]~cljs.user=> (ns a.core) [3:1]~a.core=> (ns b.core (:require [a.core])) [3:1]~b.core=>
(require 'thing :reload)(ns reagent.core) (def x 1) (ns b.core (:require [reagent.core :as a])) (js/console.log "x" a/x) (require 'reagent.core :reload)
:reloadreagent.core from disk but does nothing (since there is analyzer data)*loaded* but not inform :load-fn*loaded*?(defn require
([name cb]
(require name nil cb))
([name opts cb]
(require nil name opts cb))
([bound-vars name opts cb]
(require bound-vars name nil opts cb))
([bound-vars name reload opts cb]
(let [bound-vars (merge
{:*compiler* (env/default-compiler-env)
:*data-readers* tags/*cljs-data-readers*
:*load-macros* (:load-macros opts true)
:*analyze-deps* (:analyze-deps opts true)
:*load-fn* (or (:load opts) *load-fn*)
:*eval-fn* (or (:eval opts) *eval-fn*)}
bound-vars)
aname (cond-> name (:macros-ns opts) ana/macro-ns-name)]
(when (= :reload reload)
(swap! *loaded* disj aname))
(when (= :reload-all reload)
(reset! *loaded* #{}))
...
require is invokedreload option is coming from the repl commandcljs.js/ns-side-effectscljs.js/*loaded* but doesn’tor{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adb3adb7b6"}, :content ("[email protected]")}(require 'my.thing :reload) now doesn’t throw an error and pretends to load something 😉shadow.cljs.devtools.api namespaceshadow-cljs compile app is the same as calling (shadow.cljs.devtools.api/compile :app)release and the restboot package to install it to local mavennpm install fabric and (:require ["fabric" :as fabric])cljsjs.fabric because there are some issues with using it directly from npm (can't find jsdom){:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c6b5aea7a2a9b1eba5aaacb586f4e8f6e8f2f1"}, :content ("[email protected]")}:advancedwebpack or any other js tool would:simple … also similar to what uglifyjs or so would dojsdom shouldn’t have been included but the override didn’t trigger correctlyshadow.cljs.devtools.api... how can I use it from a boot script? It's cljs, right?(call :eval (...))(require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/compile :foo)install when you release something or not?lein deploy does not do that, only lein installboot deploy, probably not calling (install)Uncaught ReferenceError: process is not defined when trying to load the jsshadow-cljs release app --source-maps should help track it down{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8dfee5ece9e2faa0eee1e7fecdbfa3bda3b9b5"}, :content ("[email protected]")} should fix the process issue and make it easier to track problems by printing the name of the thing that failed to execute in the console(:require ["fabric" :as fabric :refer (Canvas IText Image)])(function() {
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
return;
}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "27544f464348500a444b4d546715091709131e"}, :content ("[email protected]")} now behaves like webpack would … 34kb overhead until the above issue is fixedapp-state thing from re-frame-trace{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "90e3f8f1f4ffe7bdf3fcfae3d0a2bea0bea5a0"}, :content ("[email protected]")}:devtools :http-root it should just workmenu is this dir: https://github.com/material-components/material-components-web/tree/master/packages/mdc-menuindex.js, which exports: export {MDCSimpleMenu, MDCSimpleMenuFoundation, util};util.js@material/menu/util.js@material/menu.js ext["@material/menu/util" :refer [getTransformPropertyName]] I am seeing ReferenceError: module$node_modules$$material$menu$util is not defineddir/index.jsfabric.js issue["@material/menu/simple/foundation" :as MDCSimpleMenuFoundation] ["@material/menu/util" :refer [getTransformPropertyName]]
["@material/menu/simple/foundation" :default MDCSimpleMenuFoundation]["@material/menu/simple/foundation" :as foundation] then foundation/default:default only works in shadow-cljs, not sure yet whether it will be adopted in CLJS corething/default very very quickly when testing the ES6 support, thats why I added the :default:default MDCSimpleMenuFoundation :default thing also works since you can chose the namewatch.:watch-dir (or :http-root) and then replaces <link rel="stylesheet" href="/css/main.css"> tags if /css/main.css changes<link/>?html files are never touchedhttp-server package from npm:devtools {:watch-dir "target"}cljs-devtools. how come? is the console support shadow-cljs adds not enough?cljs-devtools is fine too, nothing wrong with thatPersistentHashMap and I think it's not formatted... so I used cljs-devtoolscljs-devtoolsstyle-loader css-loader file-loader url-loader involved just to bundle CSS with fonts...sassc directly for worknpm install firebaseui and then include sth like ["firebaseui" :as firebase-ui] in a namespace)"firebase/app.js" appears to work, but not "firebase/app", and since firebaseui is the one doing the require, i can’t change that"name" "firebase", "version" "3.9.0",node_module/firebaseui/node_modules/firebase install--- externs.shadow.js:3225 Parse error. Character '$' (U+FF04) is not a valid identifier start charand last line of that file is
ShadowJS.prototype.$;isJSIdentifier method from Closure that is supposed to check this 🙂iconv-lite{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2d5e454c49425a004e41475e6d1f031d03181c"}, :content ("[email protected]")}shadow-cljs release app:
-> Compile CLJS: devtools/hints.cljs
WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced.
You should remove this library from non-dev builds completely because it impedes dead code elimination.
The best way is to use :preloads compiler option: .
To silence this warning please set :silence-optimizations-warning config key to true.
More details: .
What should I add to the shadow-cljs.edn?:compiler-options {:silence-optimizations-warning true}?:devtools {:preloads [devtools.preload]}:devtools {:preloads [re-frisk.preload] :autoload true} in shadow-cljs.edn, should I change it to :devtools {:preloads [[re-frisk.preload] [devtools.preload]] :autoload true}?:preloads [re-frisk.preload devtools.preload]shadow-cljs watch app and then shadow-cljs cljs-repl app but I got this in cljs-repl:
[1:1]~cljs.user=> (+ 1 1) There is no connected JS runtime.
shadow-cljs node-repl[:live] Configuring build.
[:live] Build failure:
target-fn shadow.build.targets.browser/process not found
{:target :browser}
ExceptionInfo: target-fn shadow.build.targets.browser/process not found
clojure.core/ex-info (core.clj:4744)
clojure.core/ex-info (core.clj:4744)
shadow.build/get-target-fn (build.clj:180)
shadow.build/get-target-fn (build.clj:153)
shadow.build/configure (build.clj:198)
shadow.build/configure (build.clj:185)
shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:121)
shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:90)
shadow.cljs.devtools.server.worker.impl/fn--22666 (impl.clj:208)
shadow.cljs.devtools.server.worker.impl/fn--22666 (impl.clj:200)
clojure.lang.MultiFn.invoke (MultiFn.java:233)
shadow.cljs.devtools.server.util/server-thread/fn--22550/fn--22551/fn--22555 (util.clj:162)
shadow.cljs.devtools.server.util/server-thread/fn--22550/fn--22551 (util.clj:161)
shadow.cljs.devtools.server.util/server-thread/fn--22550 (util.clj:146)
clojure.core.async/thread-call/fn--7892 (async.clj:442)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
java.lang.Thread.run (Thread.java:745)
target/shadow-cljs/aot-classes{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "295a41484d465e044a45435a691b0719071c1b"}, :content ("[email protected]")} should fix the JS issue you ran into yesterday. https://github.com/thheller/shadow-cljs/issues/12421023 events is that normal in the shadow-re-frame demo?re-frame-trace and one aspect of it may have not been applied/merged correctlyWARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :whitespace.cljs-devtools not by me:optimizations which it expects to be :noneshadow-cljs :optimizations is only used in release mode and otherwise ignored:release {:compiler-options {:optimizations :whitespace}} which would only set that option for release:none since other macros might use that as well:source-paths ["src"
;; for development, checkout re-frame-trace and re-view into sibling directory,
;; or remove these entries:
"../re-frame-trace/src"
"../re-view/re-frame-simple/src"]:whitespace warning should also be gone in next update^js is pretty easy and intuitiverm -rf target:live build by itself, only when multiple builds at the same timenpx shadow-cljs watch trusted live fails, npx shadow-cljs watch live trusted works<script> tags is that errors show up as coming from <anonymous> locations:
TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
at Function.cljs.spec.test.alpha$macros.instrument.cljs$core$IFn$_invoke$arity$4 (<anonymous>:248:95)
at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$6 (/js/compiled/cljs-runtime/cljs.core.js:13067:10)
npx shadow-cljs watch trusted live should now work in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "26554e474249510b454a4c5566140816081315"}, :content ("[email protected]")}:target would cause one to fail.index.js:1 Uncaught TypeError: shadow.js.provide is not a function
at index.js:1
(anonymous) @ index.js:1
emptyObject.js:1 Uncaught TypeError: shadow.js.provide is not a function
at emptyObject.js:1
(anonymous) @ emptyObject.js:1
invariant.js:1 Uncaught TypeError: shadow.js.provide is not a function
at invariant.js:1
shadow-cljs solves this. It may because of I run git pull in the shadow-cljs repo. 😕... [CACHED] doumi/bottomnav.cljs -> JS Cache read: 32 JS files <- JS Cache read: 32 JS files (24 ms) -> Closure - Optimizing ... Closure compilation failed with 1 errors --- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670 Object literal contains illegal duplicate key "scaleSequential", disallowed in strict modeI've already removed d3 from
shadow-cljs.edn and deleted the d3 folder from ~/.m2/repository/cljsjs, but shadow-cljs still gives me this error.10774 ± : ls /Users/yuzhao/.m2/repository/cljsjs/d3/ ⏎ [43m] ✹ ls: /Users/yuzhao/.m2/repository/cljsjs/d3/: No such file or directory
shadow-cljs need to do some "clean" work?d3 from my code.target folder , removed [braintripping/re-frame-trace "0.1.9"] and run shadow-cljs release app again and it works now!re-frame-trace to re-frisk now.wechat simulator.cljsjs/d3 release, not directly related to shadow-cljsshadow-cljs version. And after that I find the old target prevent me from re-compiling the new code until I removed target folder when it begins to work.target/shadow-cljs/aot-classes, the rest is ok to keepshadow-cljs clean-aot to clean the aot. I stared at the [CACHED] things for a while and finally found out removing target will work. 😄[CACHED] cljs/core.cljs means that the CLJS compilation output is cached-> Closure - Optimizing ... Closure compilation failed with 1 errors --- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670 Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
shadow-cljs --cli-info | grep d3lein install once weeks before.cljsjs/d3/4.2.2-0[braintripping/re-frame-trace "0.1.9"][cljsjs/d3 "4.3.0-5"] as your first :dependenciesd3 again. 😆gitlein image they provide{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "384b50595c574f155b54524b780a1608160d0c1509"}, :content ("[email protected]")} maybe that workstechtest.app should be in src-cljs\main\techtest\app.cljssrc-cljs/main is your source pathmain\app.cljs would be main.app:source-paths ["src-cljs"] in the shadow-cljs.ednsrc-cljs/techtest/app.cljs(ns techtest.app)?:source-paths ["src-cljs"]? besides that it looks correctVisual Studio 2017npm install + npx shadow-cljs watch appnpm install sh(ns techtest.app
:require [reagent.cor :as r])( before :require(ns techtest.app
(:require [reagent.core :as r]
[clojure.string :as str]))
clojure.string<U+FEFF>(ns techtest.app
(:require [reagent.core :as r]
[clojure.string :as str]))less shows it (the linux tool, not the css thing)vim -b app.cljs workednpm install react react-domyarn add create-react-classpublic directory? it won’t work:output-dir and :asset-path sort of belong together:asset-path is where the files are reachable when using a http server:output-dir must be reachable there:asset-path should basically always be an absolute pathwwwroot? so maybe use :output-dir "wwwroot/js"?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b4c7dcd5d0dbc399d7d8dec7f4869a849a8181"}, :content ("[email protected]")} which has fixes for all the obvious windows issues I could find[:browser] Build failure:
symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
{:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object-assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object.assign/index.js"]}
ExceptionInfo: symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.data/add-provide (data.clj:74)
shadow.build.data/add-provide (data.clj:69)
shadow.build.data/add-provides/fn--19031 (data.clj:87)
auth0 depends on object.assign (and I use that in my web build), while postcss-loader uses object-assign (not used in web build)postcss-loader isn’t used in the build why does it get resolved?:requireobject-assign and object.assign packages:resolve {"object.assign" {:target :npm :require "object-assign"}} or the other wayauth0-js instead of auth0 package solved this thing in particular. but this clash could be a more general thing. I think the resolve option as you specify there might be ‘enough’. at some point down the chain, the dev has to manually resolve conflicts.:browser builds bundle the coderequire<output-dir>/cljs-runtime/... directory<output-dir>/cljs-runtime/module$node_modules$create_react_class$index.js file<output-dir>/cljs-runtime/reagent.impl.component.js?goog.provide and goog.require + shadow.js.requirecreate-class fn{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d8abb0b9bcb7aff5bbb4b2ab98eaf6e8f6edee"}, :content ("[email protected]")}(set! *warn-on-infer* true) before. do you think it would be useful to always enable that for files with JS requires?However this alone isn't enough to have the compiler generate warnings around externs. Because of the large number of libraries written before this feature existed, we cannot enable this capability in a global way. Instead there is a new file local compiler flag *warn-on-infer* which is somewhat analogous to *warn-on-reflection* in Clojure. Once set the compiler will warn for the remainder of the file anytime it cannot determine the types involved in a dot form, whether property access or method invocation.
:infer-externs is not enough, and I also had to put *warn-on-infer* in my files to enable the inference*warn-on-infer* for every file with a JS import*warn-on-infer* was broken until today but now you’ll get proper warning again*warn-on-infer* can do is cause too many warnings^js^js tag is incorrect and should actually be tagged as ^cljshadow-cljs pom which IntelliJ/Cursive can import. basically the same as writing the “fake” project.clj. still better to use project.clj if you want to publish libs and such though.defprotocol warnings:
------ WARNING #3 -------------------------------------------------------------- File: re_view/hiccup/core.cljs:14:1 -------------------------------------------------------------------------------- 10 | js/Symbol 11 | (-pr-writer [sym writer _] 12 | (-write writer (str "\"" (.toString sym) "\""))))) 13 | 14 | (defprotocol IElement -------^------------------------------------------------------------------------ Cannot infer target type in expression (. this re-view$hiccup$core$IElement$to-element$arity$1 this) -------------------------------------------------------------------------------- 15 | (to-element [this] "Returns a React element representing `this`")) 16 | 17 | (defprotocol IEmitHiccup 18 | (to-hiccup [this] "Returns a hiccup form representing `this`")) 19 |source: https://github.com/braintripping/re-view/blob/master/re_view/src/re_view/hiccup/core.cljs#L14
------ WARNING #6 -------------------------------------------------------------- File: re_view/hiccup/core.cljs:34:9 -------------------------------------------------------------------------------- 30 | (println form) 31 | (.error js/console e))) 32 | 33 | 34 | (satisfies? IElement form) ---------------^---------------------------------------------------------------- Cannot infer target type in expression (. form -re-view$hiccup$core$IElement$) -------------------------------------------------------------------------------- 35 | (to-element form)
defprotocol, defrecord, deftype all generate bad warningsimplements? satisfies? as well(list) as well41 | (reduce (fn [out el] 42 | (doto out (.push (-to-element el)))) #js [] form) -----------------------------------^-------------------------------------------- Cannot infer target type in expression (. G__33183 push (-to-element el)) --------------------------------------------------------------------------------can
^js annotations go inline, like (.push ^js (-to-element el)) or would implementations of -to-element need to be annotated-to-element?-to-element once(doto ^js out (.push (-to-element el))))out not the -to-elementIElement protocol with a -to-element method(deftype ShouldNotWarnAboutInfer [foo bar]
Object
(yo [x])
ILookup
(-lookup [this key]
::fake))ObjectshouldComponentUpdate or so{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c3506746876687076"}, :content ("[email protected]")}.:infer-externs :auto to turn it on for every file in the project itselftrue still requires the (set! *warn-on-infer* true), :auto just does it for files (not jars), :all for everything but thats not safe(doto ^js out (.push (-to-element el)))) this doesn’t need to be annotated anymore since .push is defined in Array externs.push) being taken care of-> Closure - Optimizing ... IllegalArgumentException: Don't know how to create ISeq from: com.google.javascript.jscomp.SourceFile$Preloaded clojure.lang.RT.seqFrom (RT.java:550) clojure.lang.RT.seq (RT.java:530) clojure.core/seq--5124 (core.clj:137) clojure.core.protocols/seq-reduce (protocols.clj:24) clojure.core.protocols/fn--7829 (protocols.clj:75) clojure.core.protocols/fn--7829 (protocols.clj:75) clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13) clojure.core/reduce (core.clj:6748) clojure.core/into (core.clj:6815) clojure.core/into (core.clj:6807) shadow.build.closure/load-externs (closure.clj:392)
target2.0.61npm install thing. then in your (ns your.app (:require ["thing" :as thing]))import { Intent, Spinner, DatePickerFactory } from "@blueprintjs/core";(:require ["@blueprintjs/core" :as bp :refer (Intent Spinner)])bp/Intent, no need to use the :referjs/bp/ButtonFactorybp used as :as(shadow/watch :app) vs npx shadow-cljs watch app:target you are using. :browser defaults to :advanced, the node targets default to :simple:advanced it will only use :simple for that:js-options {:js-provider :closure} but as you experienced that doesn’t work all too well 😉window which I hate so this is already 1000 times betterwebpack does, just better integrated 😉on-save hook you can expose? Editor integrations could hook into that. It should also cause a massive speed increase by only reevaluating the forms that changed (as we would through repl).(defn with-reload [& _] (my-app.frontend.core/mount-root))that I wrap components I’m editing with and simply eval the top level form:
(with-reload (defn my-comp [] [:div "abc"]))This hack that saves me a lot of time during dev. Almost browser dev-tools-like responsiveness.
on-save hook is low-hanging fruit and editor agnostic. Please add it!(shadow.cljs.devtools.api/compile :my-build) to the REPL on keypresswatch is faster since it maintains some stateafter-eval hook reloads the app. Yes, if the hooks are available, both are tooling features. cc @U0567Q30Wload-file when I make changes in a file. clojure again though, it might be slower in CLJS.:recompile-dependents true by default, but it could also just be recompiling all the project-owned namespaces required in the files that changed. For UI development, this is very painful.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "73001b12171c045e101f190033415d435d4541"}, :content ("[email protected]")} which uses hawk to watch filesThe required namespace "com.rpl.specter.navs" is not available, it was required by "com/rpl/specter.cljc". I found this issue https://github.com/nathanmarz/specter/issues/72 but i don't run bootstrapped clojurescriptns formns parser in shadow-cljs and it is a bit too strict(:use) for CLJS, which my parser thinks is invalid{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "91e2f9f0f5fee6bcf2fdfbe2d1a3bfa1bfa7a2"}, :content ("[email protected]")}+ to *, easy fix 😉cljs.pprint warnings is that normal or am I screwing up?------ WARNING #40 ------------------------------------------------------------- File: cljs/pprint.cljs:3144:3 -------------------------------------------------------------------------------- 3140 | ;;; This is the equivalent of (formatter-out "~:<
shadow-cljs first so its deps get picked up firstlein deps :tree and see what it complains about( "cljs/pprint.cljs") and see if thats from 946( "cljs/pprint.cljc") just in caselein deps :tree this bad? shouldn’t be too badshadow-cljs for CLJS and lein for CLJ when using Cursiveproject.cljlein myself when developing shadow-cljs itself, so it definitely works finecljs.pprint?(:require [cljs.pprint :refer (pprint)]) (pprint {:x [1 2 3]}) definitely worksNov 07, 2017 5:39:45 PM clojure.tools.logging$eval347$fn__350 invoke
WARNING: failed to get source excerpt for jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs at {:warning :dynamic, :line nil, :column nil, :msg "js/cljs.pprint.*current-length* not declared ^:dynamic", :extra {:ev {:name js/cljs.pprint.*current-length*, :tag js, :ret-tag js, :ns js}, :name js/clj
s.pprint.*current-length*}}
java.lang.NullPointerException
pprint?[cljs.pprint :refer [pprint]]
/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs it is using the correct fileNov 07, 2017 5:46:55 PM clojure.tools.logging$eval347$fn__350 invoke
WARNING: failed to get source excerpt for jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs at {:warning :dynamic, :line nil, :column nil, :msg "js/cljs.pprint.*current-length* not declared ^:dynamic", :extra {:ev {:name js/cljs.pprint.*current-length*, :tag js, :ret-tag js, :ns js}, :name js/clj
s.pprint.*current-length*}}
java.lang.NullPointerException
at clojure.lang.Numbers.ops(Numbers.java:1018)
at clojure.lang.Numbers.minus(Numbers.java:137)
at clojure.lang.Numbers.minus(Numbers.java:3717)
at shadow.build.warnings$get_source_excerpts$make_source_excerpt__20342.invoke(warnings.clj:28)
at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349$fn__20350$fn__20352.invoke(warnings.clj:43)
at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349$fn__20350.invoke(warnings.clj:42)
at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349.invoke(warnings.clj:41)
shadow-cljs clj-repl nothing elsenode_modules/.bin/shadow-cljs clj-repl does that matter?npx shadow-cljs clj-repl, same thing but shorter 😉clj-repl (shadow/compile :build-id {:verbose true}):line nil, :column nil situation (which causes the NPE)( "cljs/core.cljc")HED] cljs/tools/reader/edn.cljs [CACHED] cljs/reader.cljs [CACHED] cljs/tagged_literals.cljc [CACHED] cljs/analyzer.cljc [CACHED] cljs/analyzer/api.cljc [CACHED] om/next.cljc -> Compile CLJS: cljs/pprint.cljs <- Compile CLJS: cljs/pprint.cljs (2208 ms) [CACHED] fulcro/client/logging.cljc [CACHED] yahoo/intl_messageformat_with_locales.cljs [CACHED] fulcro/i18n.cljc [CACHED] clojure/walk.cljs
#object[java.net.URL 0x62f11ebb "jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljc"]om.next could that break something? [org.omcljs/om "1.0.0-beta1" :exclusions [cljsjs/react-dom cljsjs/react org.clojure/clojurescript]]target/shadow-cljs directory, maybe somehow the cache got corruptedUncaught Error: No protocol method ISwap.-swap! defined for type object: [object Object] in http://repo.tiye.me/mvc-works/coworkflow/:modules and shadow.loader are pretty good solutions for this but ultimately it is up to the developer of each app<script src="..." async> or defer. together with <link rel="preload"> (or h2 push) to let the browser start the download early.[:browser] Build failure:
symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]
{:provide re-view.hiccup.core, :conflict [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], :resource-id [:shadow.cljs.repl/resource re-view.hiccup.core]}
ExceptionInfo: symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]
watch combined with the REPL?(ns re-view.hiccup.core) via REPL, than saving the file and watch loading it again?shadow-cljs server running somewhere. only need to restart that if you change dependencies currently.shadow-cljs command use lein to start things:lein true is enough, if you don’t want the custom profile[fulcrologic/fulcro "1.0.0"] this?ns to include for fulcro? [fulcro.client.core :as core](ns atlas-crm.ui.entry-points.spa-main
(:require [atlas-crm.ui.entry-points.spa :refer [app]]
[fulcro.client.core :as core]
[atlas-crm.ui.root :as root]))
(reset! app (core/mount @app root/Root "app"))
atlas-crm.ui.entry-points.spa that also fails so that might be the problem(ns yahoo.intl-messageformat-with-locales
(:require ["intl-messageformat" :as intl-messageformat-with-locales]
[goog.object :as gobj]))
(gobj/set js/window "IntlMessageFormat" intl-messageformat-with-locales)
cljsjs.react and cljsjs.react.dom helpers since om is stil using js/React.createClass and js/React.DOM.h1 etcpprint still works though. no warnings either.cljs.pprintom.next .. wonder what crazy things that ns is doing … scared to look 😛(:require [clojure.pprint :refer (pprint)]) causes it … thats what you get when trying to take a shortcut in the alias code 😛{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1d6e757c79726a307e71776e5d2f332d332b29"}, :content ("[email protected]")}watch become “passive”? as in not reload files automatically?(shadow/watch :your-build {:autobuild false})shadow-cljs node-replwatch become “passive”?ns before thoughload-file first, then I’ll spend some time thinking about the other thingshadow/repl or shadow/dev with nrepl?shadow.cljs.devtools.api namespace. can’t figure out how to make cursive use shadow.user ns.(require '[shadow.cljs.devtools.api :as shadow]) and you are good to go 😉(shadow/watch :app) it says missing instancelein repl?:nrepl {:port some-number} in shadow-cljs.edn(require 'repl) (repl/go) to the REPLshadow-cljs watch a b c:nrepl {:port 3002
:middleware
[cider.nrepl.middleware.apropos/wrap-apropos
cider.nrepl.middleware.classpath/wrap-classpath
cider.nrepl.middleware.complete/wrap-complete
cider.nrepl.middleware.debug/wrap-debug
cider.nrepl.middleware.format/wrap-format
cider.nrepl.middleware.inspect/wrap-inspect
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.ns/wrap-ns
cider.nrepl.middleware.pprint/wrap-pprint
cider.nrepl.middleware.pprint/wrap-pprint-fn
cider.nrepl.middleware.refresh/wrap-refresh
cider.nrepl.middleware.resource/wrap-resource
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.test/wrap-test
cider.nrepl.middleware.trace/wrap-trace
cider.nrepl.middleware.out/wrap-out
cider.nrepl.middleware.undef/wrap-undef
cider.nrepl.middleware.version/wrap-version]}
I am playing around with that[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
NullPointerException:
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
clojure.core/comp/fn--5529 (core.clj:2561)
shadow.cljs.devtools.server.nrepl/start (nrepl.clj:243)
shadow.cljs.devtools.server.nrepl/start (nrepl.clj:233)
shadow.cljs.devtools.server/start-system (server.clj:129)
shadow.cljs.devtools.server/start-system (server.clj:94)
shadow.cljs.devtools.server/start! (server.clj:180)
shadow.cljs.devtools.server/start! (server.clj:172)
shadow.cljs.devtools.server/start! (server.clj:175)
shadow.cljs.devtools.server/start! (server.clj:172)
shadow.cljs.devtools.server/from-cli (server.clj:280)
shadow.cljs.devtools.server/from-cli (server.clj:256)
shadow.cljs.devtools.cli/blocking-action (cli.clj:98)
shadow.cljs.devtools.cli/blocking-action (cli.clj:90)
shadow.cljs.devtools.cli/main (cli.clj:139)
shadow.cljs.devtools.cli/main (cli.clj:101)
clojure.core/apply (core.clj:661)
clojure.core/apply (core.clj:652)
shadow.cljs.devtools.cli/-main (cli.clj:178)
shadow.cljs.devtools.cli/-main (cli.clj:176)
clojure.lang.Var.applyTo (Var.java:702)
clojure.core/apply (core.clj:657)
clojure.main/main-opt (main.clj:317)
clojure.main/main-opt (main.clj:313)
clojure.main/main (main.clj:424)
clojure.main/main (main.clj:387)
clojure.lang.Var.applyTo (Var.java:702)
clojure.main.main (main.java:37)
:nrepl {:port 3002
:middleware
[cider.nrepl/wrap-apropos
cider.nrepl/wrap-classpath
cider.nrepl/wrap-complete
cider.nrepl/wrap-debug
cider.nrepl/wrap-enlighten
cider.nrepl/wrap-format
cider.nrepl/wrap-info
cider.nrepl/wrap-inspect
cider.nrepl/wrap-macroexpand
cider.nrepl/wrap-ns
cider.nrepl/wrap-out
cider.nrepl/wrap-refresh
cider.nrepl/wrap-resource
cider.nrepl/wrap-spec
cider.nrepl/wrap-stacktrace
cider.nrepl/wrap-test
cider.nrepl/wrap-trace
cider.nrepl/wrap-tracker
cider.nrepl/wrap-undef]}
This one seems to work{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b5c6ddd4d1dac298d6d9dfc6f5879b859b8383"}, :content ("[email protected]")} with support for source maps in :bootstrap. not sure if you actually need them but it also fixed errors not showing proper locations you mentioned a few days ago.(shadow.cljs.devtools.api/nrepl-select :app)works
(js/alert "foo") or so?(.log js/console "hello") that workserror in process filter: nrepl--dispatch-response: [nREPL] No response handler with id 0 found error in process filter: [nREPL] No response handler with id 0 found
cider-connect and then localhost and then the correct portcider-eval-last-sexp to run stuff or cider-eval-buffer but for the last one I get TBD log messageNov 09, 2017 9:58:51 AM clojure.tools.logging$eval454$fn__457 invoke
SEVERE: Unhandled REPL handler exception processing message {:ns user, :op eval, :code (ns cljs.user
(:require
[fulcro.client.core :as uc]
[om.next :as om]
[atlas-crm.ui.entry-points.spa :as core]
[atlas-crm.ui.root :as root]
[cljs.pprint :refer [pprint]]
[fulcro.client.logging :as log]
[clojure.spec.test.alpha :as stest]
[clojure.spec.alpha :as s]
[expound.alpha :as expound]))
, :file /home/mitchel/Development/atlas-crm-next/dev/client/cljs/user.cljs, :line 1, :column 1, :session 56407dcf-efa5-4ab4-8991-457ba97aa97c, :id 28}
java.lang.IllegalArgumentException: No matching clause: :repl/error
at shadow.cljs.devtools.server.nrepl$do_cljs_eval.invokeStatic(nrepl.clj:54)
at shadow.cljs.devtools.server.nrepl$do_cljs_eval.invoke(nrepl.clj:23)
at shadow.cljs.devtools.server.nrepl$cljs_eval$fn__25937.invoke(nrepl.clj:139)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.session$add_stdin$fn__25769.invoke(session.clj:229)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.load_file$wrap_load_file$fn__25818.invoke(load_file.clj:79)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
at cider.nrepl$wrap_stacktrace$fn__1100.invoke(nrepl.clj:365)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
at cider.nrepl$wrap_format$fn__1026.invoke(nrepl.clj:188)
.....
cider-connect seemed to work but its just showing something in the status bar, e e to eval the last sexp, e b to eval a buffer[10:26:55,107] nrepl-receive {:ns cljs.user, :op eval, :code (js/alert "foo")
, :file *cider-repl localhost*<2>, :line 62, :column 12, :id 42}
[10:26:56,696] nrepl-send {:id 0, :session 9aa5ab6c-1f55-4a43-bc7d-1b9ad01a3d4f, :type :repl/result, :value nil, :ns cljs.user}
[10:26:56,696] nrepl-send {:id 42, :session 9aa5ab6c-1f55-4a43-bc7d-1b9ad01a3d4f, :status #{:done}}:id backfoo/f but you need to eval the ns so that it workscljs.user> (js/console.log "foo") "nil"
cljs.user> (+ 1 2) "3"
[10:44:25,122] nrepl-receive {:ns "cljs.user", :op "eval", :code "(js/console.log \"foo\")\n", :file "*cider-repl localhost*", :line 52, :column 12, :id "16"}
[10:44:25,134] nrepl-send 16 {:type :repl/result, :value "nil", :id "16", :ns "cljs.user", :session "6fe7ed2f-85a6-4076-a7dd-5dfbe4aa0928"}
[10:44:25,134] nrepl-send 16 {:status #{:done}, :id "16", :session "6fe7ed2f-85a6-4076-a7dd-5dfbe4aa0928"}user-error: 'cider-load-buffer' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (', "').
user> (shadow.cljs.devtools.api/nrepl-select :browser) To quit, type: :repl/quit [:selected :browser] cljs.user> (js/console.log "foo") "nil" cljs.user> (js/console.log "bar") "nil"
cider-connection-browser?REPL Host Port Project Type * *cider-repl localhost* localhost 3002 atlas-crm-next ClojureScript *cider-repl atlas-crm-next* localhost 46125 atlas-crm-next Clojure
* *cider-repl localhost* localhost 8202 shadow-cljs ClojureYou can mute this warning by changing cljr-suppress-middleware-warnings. user> (shadow.cljs.devtools.api/nrepl-select :app) To quit, type: :repl/quit [:selected :app] JS runtime connected. cljs.user> (.log js/console "hoi") nil
WARNING: CIDER's version (0.15.0-snapshot) does not match cider-nrepl's version (0.15.1). Things will break!npx shadow-cljs -d cider/cider-nrepl:0.16.0-SNAPSHOT watch :app
CIDER's version (0.15.0-snapshot) ;; Connected to nREPL server - ;; CIDER 0.16.0snapshot (package: 20171001.112), nREPL 0.2.13
package-install doesn’t include ciderspace space and then type it inSPC SPC is undefinedspacemacs/check-for-new-version(render (foo "foo") (js/SPC SPC is undefined document.getElementById "app"))
SPC SPC is undefined but it should be updated nowalt+x that also worksalt+enter for youWARNING: CIDER's version (0.16.0-snapshot) does not match cider-nrepl's version (0.15.1). Things will break! can I make it use non-snapshot? snapshots are scary.[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!user-error: 'cider-load-buffer' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (', "').
CLJS <no project>@localhost:8202 (Java 1.8.0_144, Clojure 1.9.0-beta4, nREPL 0.2.13) [2 times]<no project>?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "90e3f8f1f4ffe7bdf3fcfae3d0a2bea0bea6a7"}, :content ("[email protected]")} fixes the initial issue [nREPL] No response handler with id 0 found Cider Cljs Lein Repl "(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))"(shadow.cljs.devtools.api/nrepl-select :app) it should work?lein with-profiles +cljs repl in the project itself. connect to that remotely via Cursive.(require 'repl) (repl/go) starts the embedded servercider-connect to localhost 8202shadow-cljs clj-repl also works, dont need the lein repl.(repl/go) restarts the embedded server which also restarts the nrepl server. so I’m connected to that while calling (repl/go) I lose the connection..gitignore since I put a bunch of test packages there{
"private": true,
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.0",
"shadow-cljs": "file:packages/shadow-cljs",
"source-map-support": "^0.4.15",
"ws": "^3.2.0"
},
"dependencies": {
"@atlaskit/navigation": "^18.0.0",
"@blueprintjs/core": "^1.32.0",
"@expo/vector-icons": "^5.2.0",
"animated": "^0.2.0",
"aws-sdk": "^2.122.0",
"babel-core": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"bootstrap": "4.0.0-beta.2",
"browser-resolve": "^1.11.2",
"browserify": "^14.4.0",
"browserify-shim": "^3.8.14",
"codemirror": "^5.31.0",
"create-react-class": "^15.6.2",
"d3": "^4.11.0",
"envify": "^4.1.0",
"firebase": "^4.5.1",
"firebaseui": "^2.4.1",
"highlight.js": "^9.12.0",
"iconv-lite": "^0.4.19",
"intl-messageformat": "^2.2.0",
"jquery": "^3.2.1",
"jquery-treetable": "^3.2.0-1",
"js-nacl": "^1.2.2",
"katex": "^0.9.0-alpha1",
"leaflet": "^1.2.0",
"material-components-web": "^0.22.0",
"material-ui": "^0.18.7",
"mkdirp": "^0.5.1",
"module-deps": "^4.1.1",
"moment": "^2.18.1",
"node-libs-browser": "^2.0.0",
"node-resolve": "^1.3.3",
"parinfer": "^3.11.0",
"parinfer-codemirror": "^1.4.1",
"preact": "^8.2.5",
"processing-js": "^1.6.6",
"react": "^16.0.0",
"react-addons-css-transition-group": "^15.6.2",
"react-apollo": "^1.4.16",
"react-dom": "^16.0.0",
"react-leaflet": "^1.7.0",
"react-vis": "^1.7.9",
"readline-sync": "^1.4.7",
"reqwest": "^2.0.5",
"shortid": "^2.2.8",
"source-map": "^0.6.1",
"styled-components": "^2.1.1",
"uglify-js": "^3.1.2",
"uglifyify": "^4.0.3",
"webpack": "^3.5.5"
},
"browserify-shim": {}
}(ns demo.browser
(:require-macros [demo.browser :refer (test-macro)])
(:require ["react" :as react :refer (Component createElement)]
["react-dom" :as rdom :refer (render)]
["shortid" :as sid]
["jquery" :as jq]
["material-ui/RaisedButton" :as mui-btn :default btn]
;; ["@material/checkbox" :refer (MDCCheckbox MDCCheckboxFoundation)]
["babel-test" :as babel-test :default Shape]
["@material/menu/simple/foundation" :default menu]
["@material/menu/util" :as util]
["d3" :as d3]
[clojure.pprint :refer (pprint)]
[cljsjs.react]
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]
[shadow.api :refer (ns-ready)]
["circular-test" :as circ]))
I get an error with:
:cause conflict on "clojure.pprint" by "clojure.pprint" used by "cljs.pprint"
[:FIXME {:type :repl/error, :message "failed to compile resource: [:shadow.build.classpath/resource \"cljs/pprint.cljs\"]", :data {:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "cljs/pprint.cljs"], :url #object[java.net.URL 0x6ad8fa90 "jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs"], :file nil}, :causes ["No namespace: cljs.pprint found"]}]
"No namespace: cljs.pprint found" that must be a cider error?:cause conflict on "clojure.pprint" by "clojure.pprint" used by "cljs.pprint"clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "cljs/pprint.cljs"]watch(defn cljs-repl [] (shadow-server/start!) (shadow/watch :app) (shadow/nrepl-select :app))Something like this does work with figwheel where you can just say
(fig/cljs-repl (:figwheel-system @figwheel)) not sure if you want to support this but it has a really nice workflow we have one script that starts everything and then in our emacs starts 2 repls in one jvmIllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set clojure.lang.Var.set (Var.java:223)shadow.cljs.devtools.server.nrepl is the ns and you need https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/nrepl.clj#L212-L218(ns some.thing) in the REPL it must not touch the filesystem-> Compile CLJS: cljs/core.cljs ------ ERROR ------------------------------------------------------------------- File: jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:987:14 -------------------------------------------------------------------------------- 983 | 984 | (number? o) 985 | (if (js/isFinite o) 986 | (js-mod (Math/floor o) 2147483647) 987 | (case o --------------------^----------------------------------------------------------- No reader function for tag Inf -------------------------------------------------------------------------------- 988 | ##Inf 989 | 2146435072 990 | ##-Inf 991 | -1048576 992 | 2146959360)) -------------------------------------------------------------------------------- :errorBut it works without leiningen so probably a dependency issue
tools.reader conflict. most often core.async.[org.clojure/tools.reader "1.1.1"] to your project{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6c1f040d08031b410f00061f2c5e425c425a54"}, :content ("[email protected]")} should hopefully resolve most ns issueswatch blows away some REPL statecljsjs.* alias namespaces for common cljsjs packageshot-reload over https in shadow-cljs watch app now?keytool for working with certificates doesn’t like things openssl generateskeytool though? 😛shadow-cljs.edn config.p12? .pem?privateKey file and a certificate file.-----BEGIN CERTIFICATE----- MIIDMTCCAhmgAwIBAgIBATANBgkqhkiG9w0BAQsFADBGMRYwFAYDVQQDDA1UaG9t YXMgSGVsbGVyMQswCQYDVQQGEwJERTEfMB0GCSqGSIb3DQEJARYQaW5mb0B6aWxl bmNlLm5ldDAeFw0xNzEwMjMwNzU2MDVaFw0xODEwMjMwNzU2MDVaMEYxFjAUBgNV BAMMDVRob21hcyBIZWxsZXIxCzAJBgNVBAYTAkRFMR8wHQYJKoZIhvcNAQkBFhBp bmZvQHppbGVuY2UubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA xV7BEpu7npqMSUNPyWLr3dox8byM14f7HJuSCeqeln/lL/Yr/OwnD2fuurI9/k0H xk9QJq2x76AsxHQOx5Bv036gLc+rUuBVAJkamRvYBwrCW2T5Z0ct1goVY5xy0iiP bj6Dv/Wgpr9iM5rIVdf1zpp1U/IdcbQ7nJTGvScuroIQir73LKm5GuEKzz9dBWdw C0wEjzuorHLjCTIF/ie9Qgjue1LX5mv+gjmQVfsDvaKPsddu5+It+VAvdvKmYbhN NjAP1z+84VWF20phyfuqdvEgV2P8S73GL36EdiXP/raQg0zSBvsznN9EjbOB3nmQ G1ljJvQBMIxAnIQx5XuKVQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0l AQH/BAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcNAQELBQADggEBADoq8TDWIj/ZfUih +XO9XfJ2/o3dMiQJEEhkQISEwVc0Bz+Ik2YXyuC7StgBaF1ji0YzhEmFx+7OvT5K VRtJDf6f4SI9z4R+0ZRPKWR1MNGPGJddDg93IybloJ8zymLiKC3N76QIDeXo73hb 1x1aPFWiGcV3b3sY1zaifGphHdAK4tlyWMY4gUFCqmXH1x0OKPgMfSa6EwZpSw0u x7Qq5Z5oemL7kNlPKpcC0R08+EaFC2g1ls0q55dvojgxuAC6wD120zrT7QTqkLQ/ gd9MCFduABKgkKv+Lay45jpFeObU5LMe57iNizRCF6E7eDPh7O0EIfJM+IcWtrxc PDLcVSI= -----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEAxV7BEpu7npq...
keytool has quite a few very confusing optionskey and cert file on my server. Should I download the two files and add the path of them to :ssl?keytool?keytool to create the keystore. I have no clue if you can import the certs you already have(goog-define ssl false). How to enable ssl? I generated a keystore but don't know how to use it, if it can be used. I've already add :ssl {...} to shadow-cljs.ednReferenceError: [BABEL] node_modules/styled-components/dist/styled-components.es.js: Unknown option: /home/mitchel/Development/atlas-crm-next/node_modules/react/react.js.Children. Check out for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
For more detailed information on preset configuration, please see . (While processing preset: "/home/mitchel/Development/atlas-crm-next/node_modules/react/react.js")
at Logger.error (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
at Array.map (native)
at OptionManager.resolvePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/index.js:212:65)
shadow-cljs watch app.shadow-cljs - starting ...shadow-cljs - config: /Users/yuzhao/gits/luminus-projects/shadow-cljs-demo/shadow-cljs.edn version: 2.0.71browser.cljs:260 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:260
(anonymous) @ browser.cljs:303
browser.cljs:260 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
at Object.shadow$cljs$devtools$client$browser$ws_connect [as ws_connect] ()
at
wss://?:keystore "the-file.ks" be in the same path of shadow-cljs.edn?2.0.71 the newest?:http {:port 8021} to your config, restart the server and open ?:ssl {...} at the top level?{:dependencies
[[cljs-ajax "0.7.2"]
[re-frame "0.10.2"]
[day8.re-frame/undo "0.3.2"]
[day8.re-frame/http-fx "0.1.4"]
[cljsjs/react "15.6.2-0"] ;; required by "reagent/impl/util.cljs"
[reagent "0.7.0"]
[reagent-utils "0.2.1"]
[secretary "1.2.3"]
[garden "1.3.3"]
#_[braintripping/re-frame-trace "0.1.9"]
[binaryage/devtools "0.9.7"]
[re-frisk "0.5.0"]]
:ssl {:keystore "my-keystore.jks"
:password "000000"}
:http {:port 8021}...}
package.json "module".{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4e3d262f2a2139632d22243d0e7c607e60797c"}, :content ("[email protected]")}. sorry about that.shadow-cljs watch doumi "/Users/yuzhao/gits/shadow-cljs/src/main"to the :source-pathsgit pull that checkout 😛shadow-cljs - server running at shadow-cljs - server running at 😢browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
check thisrsync my cljs-runtime to the remote server.wechat devtool I can get data from the API and see the whole webpage, and it must be in a https:// server.rsync my file to the remote server and debug in the wechat devtool.browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED tell me that the ssl-keystore is not valid? your server?------ ERROR ------------------------------------------------------------------- File: /home/mitchel/Development/atlas-crm-next/src/cards/atlas_crm/hipchat/ui/configuration_cards.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns atlas-crm.hipchat.ui.configuration-cards -------^------------------------------------------------------------------------ Invalid :refer, var devcards.core/defcard does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [fulcro.client.cards :refer [defcard-fulcro]] 4 | [devcards.core :as dc :refer [defcard]] 5 | [atlas-crm.ui.screens.hipchat.configuration :as configuration] 6 | [fulcro.ui.forms :as forms])) --------------------------------------------------------------------------------when I changed the
:refer to :refer-macros it started working. Is the compiler maybe to strict? Because this should work in CLJSdevcard.core has no self-require https://github.com/bhauman/devcards/blob/master/src/devcards/core.cljs so no it should not work:http {:port 8021} got WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSEDwss:// server should be in my local machine, not the remote server. connect to nothing.Assert failed: (satisfies? build-log/BuildLog logger) when I run.DEVTOOLS: connected! browser.cljs:25 DEVTOOLS: REPL init successful
{:id :script
:target :node-script
:main shadowhi.core/main
:output-to "dist/shadowhi.js"}}} guide for working with create-react-app. There's a link to an issue there where @thheller talks about getting auto-reload working for recompiled cljs files. They propose a sym-link solution there, which @thheller makes work - but how? Sorry if this is a noob question, I've been using shadow-cljs for literally 15 minutesBuild failure: The required namespace "create-react-class" is not available, it was required by "reagent/impl/component.cljs".
create-react-app example config)yarn add create-react-class fixed it, of course have responsed
java.lang.IllegalArgumentException: No matching clause: :get at $files_req.invokeStatic(ws.clj:197) at $files_req.invoke(ws.clj:179) at $process.invokeStatic(ws.clj:283) at $process.invoke(ws.clj:254) at clojure.lang.AFn.applyToHelper(AFn.java:154) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:659) at clojure.core$apply.invoke(core.clj:652) at shadow.http.router$call_handler.invokeStatic(router.clj:12) at shadow.http.router$call_handler.invoke(router.clj:11) at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:20) at shadow.cljs.devtools.server.web$root.invoke(web.clj:19) at shadow.cljs.devtools.server$get_ring_handler$G__26813__26814.invoke(server.clj:52) at ring.middleware.params$wrap_params$fn__14985.invoke(params.clj:67) at aleph.http.server$handle_request$fn__13182$f__649__auto____13183.invoke(server.clj:157) at clojure.lang.AFn.run(AFn.java:22) at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62) at manifold.executor$thread_factory$reify__541$f__542.invoke(executor.clj:44) at clojure.lang.AFn.run(AFn.java:22) at java.lang.Thread.run(Thread.java:745)
create-react-app example in quite a while. I imagine a lot has changed since then.POST request to request the new contentGET request? do you have a proxy or so that rewrites the request?(env/ws-url js/document.location.hostname :browser) to (env/ws-url "localhost" :browser). This enables the hot reload. but got some error in the requests.GET request and fails. don’t know how a GET request ends up there.:get error.jss but the page is not reloaded?DEVTOOLS: load JS doumi/bottomnav_comp.cljs shadow.cljs.devtools.client.browser.js:46 DEVTOOLS: load JS doumi/ua.cljs shadow.cljs.devtools.client.browser.js:46 DEVTOOLS: load JS doumi/core.cljs shadow.cljs.devtools.client.browser.js:46
(js/console.log "foo") at the top-level in the file. it should reload yes.fn you put into a map somewhere?:after-load fn was not loaded properly and was using the old version (from before the code load):after-load fn, nothing else.:output-dir.create-react-app example I made is currently broken because of the relative require it hadyarn start after each cljs change and thought that was the culprit, but I'm not using relative requires, hmmmwatch. it does not recover when a compile failed with an error.yarn is the slowpoke for mewatch problems should go away with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "93e0fbf2f7fce4bef0fff9e0d3a1bda3bda4a7"}, :content ("[email protected]")}"rmwc": "0.0.1-beta10" to my package.json and I’m getting a funny error message:
ReferenceError: Unknown plugin “react-hot-loader/babel” specified in “/Users/pedro/Developer/rmwc-cljs/node_modules/rmwc/package.json” at 0, attempted to resolve relative to “/Users/pedro/Developer/rmwc-cljs/node_modules/rmwc”package.json is:
{
"dependencies": {
"create-react-class": "^15.6.2",
"react": "^16.1.0",
"react-dom": "^16.1.0",
"rmwc": "0.0.1-beta10"
},
"devDependencies": {
"shadow-cljs": "^2.0.74"
}
}
node_modules/rmwc/package.json and just rename the babel entry to xbabel or sonpm, this one doesn’t it seems{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "681b00090c071f450b04021b285a4658465f5d"}, :content ("[email protected]")}rmwc:closure-defines dynamically from the cli? eg. if i want to build a release of a build where the closure variable server-env is set to dev or staging or whateverjs/process.envTHING=foo node > process.env.THING 'foo'
js/process.envinit fn that is called from HTMLinit fnindex.html is generated by a server vs. static file<script>starter.browser.init({api_url: "foo"});</script>(ns demo.run-test
(:require [shadow.cljs.devtools.config :as config]
[shadow.cljs.devtools.api :as api]))
(defn build [& args]
(let [config
(-> (config/get-build! :your-build)
(assoc-in [:compiler-options :closure-defines 'some.ns/define] (System/getenv "FOO")))]
(api/release* config {})
))shadow-cljs clj-run demo.run-test/buildclj-run I just added, lets you call any clojure fn from the CLIlein run -m ...{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "483b20292c273f652b24223b087a6678667f7e"}, :content ("[email protected]")} pushed like 5min agoget-build-config fn to the api namespace but besides that it should workclj-eval?Invalid action "clj-run" Usage: shadow-cljs <action> <zero or more build ids>
clj-runshadow-cljs clj-run demo.run-test/fn1 1 2 3
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.76
shadow-cljs - connected to server
[:fn1 ("1" "2" "3")]clj-run command, super usefulclj-run’ing it again, it evaluates the old version(require 'the.ns :reload). maybe I should add some reloading though? not sure about that.:reload to only reload the main ns:reload-all since that may destroy some parts of the shadow-cljs process:target :npm-module generate source map ? I tried :compiler-options {:source-map true}}, it works in :target :browser, but failed in :npm-module. Example: https://github.com/bolasblack/airtable-notifier-temp newest commit:npm-module{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8efde6efeae1f9a3ede2e4fdcebca0bea0b9b9"}, :content ("[email protected]")}page function was not applied. I did almostly the same as in a figwheel project. The only difference is that, after adding the compiled js file as a <script> tag, I add another <script> tag, in which the app.core.some_init() function is called. It seems the core.cljs file re-runs after shadow-cljs watch app tells the page(because a (.log js/console "ddd") runs), but I doubt the page does not know the app.core.some_init() function was called, so everything under the some_init function is not applied. Is that right? If so, how to make things under some_init function applied?init is the fn called from HTML. it is only called ONCE ever.:before-load will call stop, then load the code and :after-load call the startstartinit as the function exported?init, so its only done once:after-load is enough if you just want something to run after loading codeon-jsreload in figwheelinit as well if you don’t need itstart directlypage, the figwheel project get reloaded well, but the shadow-cljs project also reloaded, but new page function not applied.<script> tag and called app.core.init()(.log js/console "bla") that runs.page function, no effect.init is the fn that should run after loading code?:after-load app.core/initlein new luminus app +http-kit +re-frame to create a figwheel project.require.js project. {% script "/js/app.js" %} in html template to apply the compiled code.:figwheel {:on-jsload "app.core/mount-components"}<!DOCTYPE html>
<html>
<head>
<% include ../common/meta.ejs %>
<link href="/css/icomoon/style.css" rel="stylesheet">
<% include ../common/autoRem.min.ejs %>
<% include ../common/zhugeio.ejs %>
<title><%- title %></title>
</head>
<body>
<div id="app"></div>
<script src="/doumi/js/doumi.js"></script>
<script>
doumi.core.annc_init();
</script>
</body>
</html>
:after-load app.core/mount-components:before-load stop call?:builds {:browser {:target :browser
:output-dir "target/browser"
:asset-path "/browser"
:modules {:main {:entries [app.main]
:depends-on #{:lib}}
:lib {:entries [respo.core respo.macros
respo.comp.inspect]}}
:devtools {:after-load app.main/reload!
:preloads [shadow.cljs.devtools.client.hud]
:http-root "target"
:http-port 8080}
:release {:output-dir "dist/"
:module-hash-names 8
:build-options {:manifest-name "cljs-manifest.json"}}}
:bootstrap-support {:target :bootstrap
:output-dir "target/browser/bootstrap"
:entries [cljs.js]
:macros []}
:main module must have shadow.cljs.bootstrap.env in the :entries[:bootstrap-support] Build failure: The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc".
:entries [cljs.js] thats not how this workscljs.js you use in the :browser build, the :boostrap build only includes namespaces that you want to use with the self-hosted compilershadow.cljs.bootstrap.env manually:exclude...:entries should be something like reagent.core or so. namespaces you are going to need when evaling codecljs.core is enough if you don’t want any other librariescljs.js with the proper exclude yescljs.js do?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(app.render.main_BANG_, process.argv.slice(2));
{ env: { NODE_ENV: 'development' }, browser: false }
=>> node target/ssr.js
Reading from entry/main.css
{ env: { NODE_ENV: 'development' }, browser: false }
SHADOW import error /Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js
/Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js:3
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(app.render.main_BANG_, process.argv.slice(2));
^
TypeError: Cannot read property 'slice' of undefined
at Object.<anonymous> (/Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js:3:83)
process is overwritten?:bootstrap does not support code in release mode:advanced only :simple:bootstrap stuff is not compatible with node currentlyshadow.cljs.bootstrap.browser ns and create a node version?:simple, and works now{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "47342f262328306a242b2d3407756977697f74"}, :content ("[email protected]")}[:doc-bootstrap] Build failure: FileNotFoundException: ...project/js/compiled/bootstrap/js/cljs.core.js.map (No such file or directory) java.io.FileOutputStream.open0 (FileOutputStream.java:-2) java.io.FileOutputStream.open (FileOutputStream.java:270) java.io.FileOutputStream.<init> (FileOutputStream.java:213) (io.clj:230) (io.clj:230)it works if i manually create the
js/compiled/bootstrap/js/ directory{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7c0f141d18130b511f10160f3c4e524c524448"}, :content ("[email protected]")}:js-provider to use.js sources while using :shadow for node_modules:advanced. I think that should be ok given that you control the .js and could fix :advanced issues if requirednpm?src/integrated/core.cljs (ns integrated.core "Start here." (:require ["./lib" :as lib])) (defn init! [] (lib/debugMessage "Narf"))
src/integrated/lib.js var debugMessage = (x = "any old string") => {
console.log(`Printing ${x} from cljs!`);
};
export { debugMessage };
lib.js can even use any cljs code via importimport core from "goog:cljs.core";
import { createElement } from "react";
import { bar } from "./more-es6";
var foo = (x = "any old string") => {
console.log(`Printing ${x} from cljs!`);
console.log(core.assoc(null, 1, 2));
console.log(createElement("h1", null, x));
return bar(x);
};
export { foo };:advanced?(:require ["./lib" :as lib]) in core 😞FileNotFoundException target/shadow-node-repl.js (No such file or directory) java.io.FileInputStream.open0 (FileInputStream.java:-2) when I tried to start shadow-cljs node-repl :nrepl {:port 8202} to my shadow-cljs.edn, but it tells me failed to require macro-ns "cljs.repl", it was required by "cljs.repl" when I shadow-cljs watch app{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "47342f262328306a242b2d3407756977697f71"}, :content ("[email protected]")}. I bumped the closure compiler version yesterday but cljs.closure (used by cljs.repl) is not compatible with that.shadow-cljs watch app works now.user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs) To quit, type: :repl/quit [:selected :d3-cljs] cljs.user> (defn hello [who] (str "Hello, " who "!") "ret value") There is no connected JS runtime. cljs.user> (cemerick.piggieback/cljs-repl :d3-cljs) There is no connected JS runtime. cljs.user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs) There is no connected JS runtime. cljs.user>
There is no connected JS runtime. means that you need to open the app in the browser`user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)`
user>. you were in a CLJ REPLnrepl-select causes it to switch to a CLJS REPLcljs.user> (defn hello [who] (str "Hello, " who "!") "ret value") There is no connected JS runtime.
cljs.user> repl:browser build you need to open it:node-library build:node-library you need to run nodenode-repl directly, that launches a node process for youshadow-cljs node-repl or node-repl in Emacs?shadow-cljs node-repl outside of emacs(shadow.cljs.devtools.api/nrepl-select :node-repl) in emacsJS runtime connected. cljs.user> (defn hello [who] (str "Hello, " who "!") "ret value") There is no connected JS runtime. cljs.user>
cljs.user> prompt. you are already in a CLJS REPL. nrepl-select ONLY works in CLJ REPLs:repl/quit to get back to a CLJ REPLcljs.user> :repl/quit :repl/quit user> (shadow.cljs.devtools.api/nrepl-select :node-repl) To quit, type: :repl/quit [:selected :node-repl] cljs.user> (defn hello [who] (str "Hello, " who "!") "ret value") #'cljs.user/hello cljs.user>
:node-library project in shadow-cljs?tests?lein test using cljs.testdeftest and then run-tests(ns demo.app-test (:require [cljs.test :refer (deftest is)])) (deftest some-demo-test (is (= 1 2)))
test/demo/app_test.cljs, add :source-paths ["src" "test"]shadow-cljs test=>> yarn yarn install v1.3.2 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... info There appears to be trouble with your network connection. Retrying...
[2/4] 🚚 Fetching packages... verbose 27.931 Performing "GET" request to "". [################################################] 188/189
:npm-deps!shadow-cljs compile app is the same as calling (shadow.cljs.devtools.api/compile :app)(shadow.cljs.devtools.server/start!) fn starts the embedded serverstop! does the shutdownboot at all. they do a bunch of stuff that really get in the way, ie. caching doesn’t work.babel-core to transpile ES6 in node_modules.lein repl and then a (start) command that does everything, including figwheelshadow-cljs watch a node library often tells me this: [:d3-cljs] Build failure: The required namespace "shadow.umd-helper" is not available. But it is working well, just do not know what this means. simple_smile{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c7b4afa6a3a8b0eaa4abadb487f5e9f7e9ffff"}, :content ("[email protected]")}.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "087b60696c677f256b64627b483a2638263031"}, :content ("[email protected]")} and specify :devtools {:use-document-host false} which changes the default behaviour and then uses the :host specified in :http {:host ...} which defaults to "localhost" instead of js/document.location.hostnamemanifest.json rather than *.edn?.json files, thats pretty much the reason. never changed it since.object-assign and object.assign. How are these npm dep names munged?(ModuleNames/fileToModuleName js-name):resolve {"object-assign" {:target :npm :require "object.assign"}}npm packages depend on is scary.api/get-build-config recently so you don’t need to import the config namespace.(defn not-found
([req]
(not-found "Not found."))
([req msg]
{:status 404
:headers {"content-type" "text/plain"}
:body msg}))
shadow-cljs - starting ... shadow-cljs - HTTP server for ":app" available at shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (155 files, 54 compiled, 0 warnings, 19.67s) [2017-11-20 00:18:33 - SEVERE] error in HTTP handler java.lang.StackOverflowError at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9) at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7) at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9) at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7) at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9) at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7) at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9)
.js for the ui now …2.0.93 fixes the stackoverflow error above(ns atlas-crm.tests-to-run (:require atlas-crm.sample-spec atlas-crm.ui.impl.routing.path-spec atlas-crm.ui.impl.routing.linear-search-router-spec))
(ns atlas-crm.client-test-main
(:require atlas-crm.tests-to-run
[fulcro-spec.selectors :as sel]
[fulcro-spec.suite :as suite]))
(suite/def-test-suite client-tests {:ns-regex #"atlas-crm\..*-spec"}
{:default #{::sel/none :focused}
:available #{:focused :should-fail}})
tests-to-run, atlas-crm.client-test-main is not reloadedclient-test-main depends on tests-to-run?tests-to-run is probably reloaded, but def-test-suite macro probably inspects some analyzer data and is not reloaded to do that againclient-test-main?(ns atlas-crm.CI-runner (:require atlas-crm.tests-to-run [doo.runner :refer-macros [doo-all-tests]])) ;; This file is for running JS tests via karma/node for CI server (doo-all-tests #".*-spec")
shadow-cljs test so you don’t have to write any of thattests-to-run, or rather ensure that the namespaces are compiled/loaded properlydoo is lein specific it seems 😞(ns atlas-crm.CI-runner (:require atlas-crm.tests-to-run [doo.runner :refer-macros [doo-all-tests]])) ;; This file is for running JS tests via karma/node for CI server (doo-all-tests #".*-spec")
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'resources/public/',
files: ['js/ci/ci.js', {pattern: 'js/ci/cljs-runtime/**', included: false}],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {args: ["doo.runner.run_BANG_"],
singleRun: true}
})
};
"karma": "^1.7.1",
"karma-chrome-launcher": "2.2.0",
"karma-cljs-test": "^0.1.0"
yarn exec karma start or if you are using npm npx karma start:ci {:target :browser
:asset-path "/base/js/ci"
:modules {:ci {:entries [atlas-crm.CI-runner]}}
:output-dir "resources/public/js/ci/"
:devtools {:preloads [devtools.preload]}}
(suite/def-test-suite client-tests {:ns-regex #"atlas-crm\..*-spec"}
{:default #{::sel/none :focused}
:available #{:focused :should-fail}}):test {:target :browser
:asset-path "/js/test"
:modules {:common {:entries []}
:devcards {:entries [atlas-crm.cards] :depends-on #{:common}}
:test {:entries [atlas-crm.client-test-main] :depends-on #{:common}}}
:output-dir "resources/public/js/test/"
:compiler-options {:devcards true}
:devtools {:http-port 8600
:http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
:http-handler dev.test-handler/handler
:after-load atlas-crm.client-test-main/client-tests
:preloads [shadow.cljs.devtools.client.hud devtools.preload]}}
:http-handler do? what kind of assets? css I presume?(ns dev.test-handler
(:require [ring.middleware.resource :as ring-resource]))
(defn not-found [req]
{:status 404
:headers {"content-type" "text/plain"}
:body "Not found."})
(defn wrap-dir-index [handler]
(fn [req]
(handler
(update-in req [:uri]
#(if (= "/" %) "/index.html" %)))))
(def handler (-> not-found
(ring-resource/wrap-resource "public")
(wrap-dir-index)))
cljs.test:http-root optional if :http-handler is set.{:target :browser
:asset-path "/js/test"
:modules {:common {:entries []}
:devcards {:entries [atlas-crm.cards] :depends-on #{:common}}
:test {:entries [atlas-crm.client-test-main] :depends-on #{:common}}}
:output-dir "resources/public/js/test/"
:compiler-options {:devcards true}
:devtools {:http-port 8600
:http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
:http-handler dev.test-handler/handler
:after-load atlas-crm.client-test-main/client-tests
:preloads [shadow.cljs.devtools.client.hud devtools.preload]}}shadow-cljs browser-test some-regexp can probably spin up a http server and open it:http-handlershadow-cljs browser-test --test-match some-regexp --port 1234 --handler some.ns/handler --runner atlas-crm.client-test-main etcINFO: filename violation for ns paper.components.tooltip, got: cljs/paper/components/tooltip.cljs expected: paper/components/tooltip.cljs (or .cljc)
:source-paths set to ["src/cljs"]shadow-cljs --cli-info?:lein in your config? when embedding inside boot or lein their classpath will be used and :source-paths has no effect.["src/cljs" "src/cljc"]"src" ends up in your classpath as welllein: true because I want to manage my clojure dependencies via project.clj (for cursive support)shadow-cljs pom to generate a pom.xml and use that for cursive:lein true and :builds ..., nothing elsedeps.edn I’ll add support for that which should remove some of the lein odditieskarma I don’t really understand what its doing22 11 2017 19:36:28.744:WARN [web-server]: 404: /js/cljs-runtime/goog.debug.error.js 22 11 2017 19:36:28.744:WARN [web-server]: 404: /js/cljs-runtime/goog.dom.nodetype.js 22 11 2017 19:36:28.745:WARN [web-server]: 404: /js/cljs-runtime/goog.string.string.js 22 11 2017 19:36:28.747:WARN [web-server]: 404: /js/cljs-runtime/goog.asserts.asserts.js
include: false from your configHeadlessChrome 0.0.0 (Mac OS X 10.12.6) LOG: '0 failures, 0 errors.' 22 11 2017 19:47:59.079:WARN [HeadlessChrome 0.0.0 (Mac OS X 10.12.6)]: Disconnected (1 times), because no message in 10000 ms. HeadlessChrome 0.0.0 (Mac OS X 10.12.6) ERROR Disconnected, because no message in 10000 ms.
:test-dummy
{:target :browser-test
:output-dir "out/demo-test-dummy/public/js"
:devtools
{:http-root "out/demo-test-dummy/public"
:http-port 8606}}cljs.test will be includedcljs.test itself to trigger thisbrowser-test target.. took me a while. I like that solution ^^:runner for a custom runner(ns shadow.test.browser
"generic browser test runner"
(:require [shadow.test :as st]
[shadow.dom :as dom]))
;; FIXME: implement custom reporter instead
(defonce log-node (dom/by-id "log"))
(when log-node
(set-print-fn!
(fn [s]
(dom/append log-node (str s "\n")))))
(defn start []
;; (js/console.log "test env" @st/tests-ref)
(st/run-all-tests))
(defn stop [done]
(set! (.-innerText log-node) "")
;; FIXME: determine if async tests are still running
;; and call done after instead
;; otherwise a live reload might interfere with running tests by
;; reloading code in the middle
(done))
;; not sure we need to do something once?
(defn ^:export init []
(start))shadow.test/tests-ref is an atom with all the testscljs.test as usual, the only thing I added is that deftest is registered at runtimeshadow-cljs release my-build would add it to the output, but I’m not seeing itshadow-cljs clj-repl and then (shadow/release-snapshot :build-id)target/shadow-cljs/release-snapshots/build-id/latestbundle-info.edn thats fine.413761 bytes -> 406811 bytes before gzip and 53808 -> 52762 gzip’d.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c3506746876687f7e"}, :content ("[email protected]")} and setting :compiler-options {:shadow-keywords true}fulcro project building with shadow-cljs? Getting an error about clojure.future not being on the classpath, which I'm pretty sure is from https://github.com/tonsky/clojure-future-spec.187304 -> 185424 for gzipped filefulcro. clojure-future-spec is ignored by default since its a backport of clojure.spec to 1.8 but shadow-cljs already uses clojure 1.9clojure.future works again.constants-inject)(= :foo a) to (identical? :foo a):none(ns permafrost.main) (def value-a 3) (defonce value-b 2) (defn reload! [] (println "Code updated.") (println "Trying values:" value-a value-b)) (defn main [ & argv ] (println "App loaded:" argv))
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[cider/cider-nrepl "0.16.0-SNAPSHOT"]
[refactor-nrepl "2.4.0-SNAPSHOT"]]
:nrepl
{:port 8202}
:builds
{:pf {:target :node-script
:output-to "out/permafrost.js"
:main permafrost.main/main
:devtools {:after-load permafrost.main/reload!}
:release {:output-to "permafrost.js"}}}}
:optimizations :simple due to larger number of externs required on node setups:compiler-options {:infer-externs :auto :optimizations :advanced}:simpleprintln or prn only console.log:build-options {:print-fn :none} it should go down moreshadow-cljs itselfrm -rf target/shadow-cljs/builds/build-id …:npm-module name is a bit misleading. you can use :node-library as well which is a bit smaller and better optimizable than :npm-module:npm-module:node-script is fine too, thats how I started.:print-fn :none(js/console.log "foo") in your code?(defn main [ & argv ] (println "App loaded:" argv))
&package.json. don’t use the one at the project root.--cache option?lumo is great but having it check if something needs to be compiled before running it is not useful for production builds:advanced optimization output..closh is a different story since it needs runtime evalpackages/shadow-cljs/cli/dist, install a bin runner.js that loads this file with some logic around how it’s finding the file. what’s the purpose of the runner here?shadow-cljs is installed globally it should still use the one installed in the project{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1f6c777e7b7068327c73756c5f2d312f312e2f2f"}, :content ("[email protected]")} also adds :target :karma which always produces one output file (missing source maps currently, will add later) :test-karma
{:target :karma
:output-to "out/demo-karma/test.js"}
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'out/demo-karma',
files: ['test.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
// FIXME: do we need this?
client: {args: ["shadow.test.karma.init"],
singleRun: true}
})
};
watch?(ns atlas-crm.CI-runner
(:require
[shadow.test :as shadow-test]
[doo.runner :as runner :refer-macros [doo-tests]]))
(doo.runner/set-entry-point!
(fn [tc]
(let [total-tests (reduce
(fn [acc {:keys [vars]}]
(+ acc (count (keys vars))))
0
(vals (shadow-test/get-tests)))]
(jx.reporter.karma/start tc total-tests))
(shadow-test/run-tests (cljs.test/empty-env :jx.reporter.karma/karma))))
shadow.test.env which has the get-tests fnget-test-count fn 😉shadow.test depends on cljs.test but shadow.test.env needs to be loaded before cljs.testmodule.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
basePath: 'resources/public/',
files: ['ci/js/test.js', {pattern: 'ci/js/cljs-runtime/**', included: false}],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {args: ["doo.runner.run_BANG_"],
singleRun: true}
})
};
:ci {:target :browser-test
:asset-path "/base/ci/js"
:ns-regexp "-spec$"
:runner-ns atlas-crm.CI-runner
:test-dir "resources/public/ci/"}
vN.j ? vN.j(ax, e5) : vN.call(null, ax, e5);
function f5() {
return "undefined" !== typeof $zopim ? $zopim.livechat.window.show() : null{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3f4c575e5b5048125c53554c7f0d110f110e0f0e"}, :content ("[email protected]")}. see https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9shadow-cljs.<build-id>.edn if that seems useful. I kinda like having my config in one place but it tends to get pretty large in bigger projects.:modules?modulesinstrument call? My first guess would be to call it after each reload?(:require ["consul" :as consul]) in cljs, and the consul.js looks like:function Consul(opts) {
if (!(this instanceof Consul)) {
return new Consul(opts);
}
.....
};
/**
* Module exports.
*/
exports.Consul = Consul;Usage
var consul = require('consul')();
consul.acl.bootstrap(function(err, result) {
if (err) throw err;
});Some packages just export a single function which you can call directly by using (:require ["thing" :as thing]) and then (thing).consul/Consul will workeval error <eval>:-6
shadow.js.shim.module$consul.Consul()
^
TypeError: Cannot read property 'Consul' of undefined
at <eval>
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at runInThisContext (vm.js:152:38)
at global.SHADOW_NODE_EVAL (/Users/sundbp/dev/bi/permafrost/out/permafrost.js:113:30)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/sundbp/dev/bi/permafrost/target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:28:1)consul/default?eval error <eval>:-6
shadow.js.shim.module$consul["default"]()
^
TypeError: Cannot read property 'default' of undefined[:pf] Compiling ... [:pf] Build failure: The required JS dependency "consul123" is not available, it was required by "permafrost/cli.cljs".
permafrost.cli> consul "nil"
consul/consul?consul.consul i mean[:pf] Compiling ... [:pf] Build failure: The required JS dependency "consul.consul" is not available, it was required by "permafrost/cli.cljs".
:node ?» less target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow.js.shim.module\$consul.js
goog.provide("shadow.js.shim.module$consul");
shadow.js.shim.module$consul = require("consul");Use of undeclared Var shadow.test.env/register-test
(prn (js-keys (consul))) and see the fns in the js docs(let [c (consul (clj->js {...})] ...), but then i need to access .kv.get in that c object.aget and call it I get a failure as it expects this to be set to c during the call..(-> consul (.-kv) (.get arg1 arg2 ...))cljs.test and do deftest somewhere in your buildshadow.test.env is included automatically for the new test builds but not for everything else. need to fix that(:require ["consul" :as consul]) should have just worked. no idea why it wouldn’t.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fb88939a9f948cd698979188bbc9d5cbd5cacbc9"}, :content ("[email protected]")}, sorry about that. <link rel="stylesheet" href="/css/foo.css"/>:devtools {:http-root ...} http server it should just work:devtools {:watch-dir ...} which should be the path to your http root folder:watch-dir "public" will reload public/css/foo.css when it finds the link in HTMLnode dev-output/foo.js at the time it’d have gotten picked up properly as shadow-cljs had done it’s thing. I was expecting the require in the shim to blow up or work as expected though, seemed to have silently errored instead.yarn does not require a restart. REPL might have some edge cases related to loading. builds should be fine.lein figwheel right away and all required dependencies are downloaded automatically.
On the other hand, when I add rum as a dependency to shadow-cljs, I have to separately include the official js react dependencies in the project's package.json as well (e.g. done here: https://github.com/thheller/shadow-cljs-template). If I don't, I receive an The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs" (`cljsjs/react` is a dependency for rum) error. Why is that?
I guess I'm not really understanding how leiningen and shadow-cljs solve the installation of dependencies internally, especially when it comes to cljsjs-libraries (which we don't really need in shadow-cljs anyways, right?).npm install react.:npm-deps and will still use cljsjsnpm install. it already has everything properly setup.lein templates just don’t run that command for youcljsjs.react which is the re-packaged npm package. so its not using npm but rather the 3rd party package. https://github.com/cljsjs/packages/tree/master/reactfailed to inspect cljs file: jar:file:/home/matthys/.m2/repository/metosin/spec-tools/0.5.1/spec-tools-0.5.1.jar!/spec_tools/core.cljc {:tag :shadow.build.classpath/inspect-cljs, :resource-name "spec_tools/core.cljc", :url #object[java.net.URL 0x7f2d31af "jar:file:/home/matthys/.m2/repository/metosin/spec-tools/0.5.1/spec-tools-0.5.1.jar!/spec_tools/core.cljc"]} Has anyone seen a similar error before?failed to parse ns form {:clojure.spec.alpha/problems ({:path [:clauses :refer-clojure :clause], :pred #{:refer-clojure}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "097a61686d667e246a65637a493b27392738393a"}, :content ("[email protected]")}. my ns parser was a bit too strict and didn’t allow (:import) which spec-tools.impl has for :cljsjs/document.body to get the document body? Because I am trying to use a preload for fulcro-devtools and here: https://github.com/fulcrologic/fulcro-inspect/blob/develop/src/fulcro/inspect/ui/events.cljs#L79 target is undefined:npm-deps for listing and managing js dependencies?:npm-deps in a deps.cljs file that will make shadow-cljs isntall them on startup:foreign-libs for :npm-deps:npm-deps? is it module name to semnatic versioning range?{:npm-deps {"thing" "range}} yesjs/requestAnimationFrame.
I check the output of (or batched-updates js/requestAnimationFrame), it's
return or__32840__auto__;
} else {
requestAnimationFrame;
}
if(cljs.core.truth_(or__30096__auto__)){
return or__30096__auto__;
} else {
return requestAnimationFrame;
}
var G__54995_54997 = "or";
var G__54996_54998 = (function (){var or__34403__auto__ = null;
if(cljs.core.truth_(or__34403__auto__)){
return or__34403__auto__;
} else {
document.body}
})();
console.log(G__54995_54997,G__54996_54998);return(or batched-updates (fn [] js/requestAnimationFrame)){:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "12617a73767d653f717e786152203c223c232226"}, :content ("[email protected]")}. sorry about that.shadow-cljs check foo:-> Closure - Checking ... ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String shadow.build.closure/closure-source-file (closure.clj:565) shadow.build.closure/closure-source-file (closure.clj:565) shadow.build.closure/source-map-sources/fn--21021 (closure.clj:930)
aero lib on nodejs, in advanced opt mode it gives:function jB(a,b,c){b=b.l?b.l():b.call(null);$f.c(c,Qd,a);return b}function kB(a,b,c){b=null!=b&&(b.o&64||p===)?pf(ni,b):b;var d=E.b(b,Sk),e=E.b(b,Ck),f=E.b(b,Nk);if(v(Zl.a(f)))return null;try{var g=jB(a,d,c)}catch(k){throw c=k,[x.a(["could not start [",x.a(a),"] due to"].join(""))," ",x.a(c)].join("");}hB(b,g);$f.D(fB,T,a,new u(null,1,[Ck,e],null));return iB(new X(null,2,5,Y,[a,Nk],null),new vi(null,new u(null,1,[Zl,null],null),null))}
^
could not start [#'permafrost.config/config] due to TypeError: Cannot read property 'b' of undefinedcheck recently when doing the externs inference workshadow-cljs release app --debugcheck isn’t totally reliable anymore due to all the new JS interop-> Closure - Optimizing ... ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String shadow.build.closure/closure-source-file (closure.clj:565) shadow.build.closure/closure-source-file (closure.clj:565) shadow.build.closure/source-map-sources/fn--21022 (closure.clj:930)
:target is that?:builds
{:pf {:target :node-library
:output-to "out/permafrost.js"
:exports {:main permafrost.cli/main}
:devtools {:before-load permafrost.cli/stop!
:after-load permafrost.cli/start!}
:release {:output-to "permafrost.js"
:compiler-options {:infer-externs :auto
:optimizations :advanced}}}}}
shadow-cljs release pf --debugaero library (i.e. if i exclude the aero/read-config call doesn’t trigger). but was hoping for a bit more info to figure out where it is.aero?ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dba8b3babfb4acf6b8b7b1a89be9f5ebf5eaebee"}, :content ("[email protected]")}aero has to do with it though. release source maps were just generally broken for :node-libraryaero(fs.readFileSync source "utf-8") probably this(os.hostname)/Users/sundbp/dev/bi/permafrost/permafrost.js:20075
throw $done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$ = $e38700$jscomp$inline_1327$$, [$cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$(["could not start [", $cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$($state$jscomp$22$$), "] due to"].join("")), " ", $cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$($done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$)].join("");
^
could not start [#'permafrost.config/config] due to TypeError: Cannot read property '$cljs$core$IFn$_invoke$arity$2$' of undefinednode --inspect the-thing.js so the source maps actually apply?--inspect-brk$cljs$core$IFn$_invoke$arity$2$throw $done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$ = $e38700$jscomp$inline_1327$$, that the heck is that? 😛» node --inspect-brk bin/runner.js ~15.0s 21:23:30 Debugger listening on For help see
pause on exceptions thing (pause icon)(.readFileSync fs source "utf-8") ?(.. fs (writeFileSync source "utf-8))(fs/writeFileSync ...) coupled with (:require ["fs" :as fs]) in the nsnodejs/require calls go away 😛lumo supports that<project>/externs/pf.txt and just put the problematic things into it. so hostname writeFileSync
check should also work againdeps.cljs has to have the same information that already resides in the package.json file. Is there an easier way to keep the two in sync?------ WARNING #3 -------------------------------------------------------------- File: /Users/zilence/code/shadow-cljs/src/dev/demo/lib.cljs:13 -------------------------------------------------------------------------------- 10 | 11 | 12 | (def fs (js/require "fs")) 13 | (fs.writeFileSync "x" "foo" "utf-8") -------------------------------------------------------------------------------- Property writeFileSync never defined on demo.lib.fs -------------------------------------------------------------------------------- 14 | --------------------------------------------------------------------------------
:npm-deps is only for libraries declaring dependencies on JS packagespackage.json (since that drives npm which isn’t aware of :npm-deps)package.json served as the canonical, and shadow-cljs could generate deps.cljs from it. It seems like it could be potentially dangerous for packages to get out of sync if writing a lib (also another thing to remember).deps.cljs would be part of it.:profiles and such. I really don’t want to do that..jar. same as lein/`boot`package.json handling which those don’t dodeps.cljs file:dev-dependencies or so:npm-deps though. pretty good odds they won’t work with anything but shadow-cljs:npm-deps pretty often does not work in CLJS corerelease currently but they don’t work in dev either which has the comments.--debug flag for release it would make senseshadow-cljs.edn would be logical:devtools {:repl-timeout a-number}?:node-library):node-scriptbin/runner.js<- Compile CLJS: om/next.cljc (15087 ms)
Cache write: om/next.cljc
aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
{:aborted [:shadow.build.classpath/resource "fulcro/client/util.cljc"], :pending #{om.next}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.compiler/par-compile-one (compiler.clj:647)
shadow.build.compiler/par-compile-one (compiler.clj:622)
shadow.build.compiler/par-compile-cljs-sources/fn--11576/iter--11577--11581/fn--11582/fn--11583/fn--11584 (compiler.clj:721)
clojure.core/apply (core.clj:657)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/apply (core.clj:661)
clojure.core/bound-fn*/fn--5471 (core.clj:1995)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
Is this fixable?om.next … not sure whats happening17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/logging.cljc"] waiting for #{om.next}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/i18n.cljc"] waiting for #{fulcro.client.logging}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/mutations.cljc"] waiting for #{fulcro.client.util fulcro.client.logging om.next fulcro.i18n}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/om_plumbing.cljc"] waiting for #{fulcro.client.mutations fulcro.client.logging om.next}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/data_fetch.cljc"] waiting for #{fulcro.client.util fulcro.client.mutations fulcro.client.logging om.next fulcro.client.impl.om-plumbing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/network.cljc"] waiting for #{fulcro.client.logging}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/application.cljc"] waiting for #{fulcro.client.util fulcro.client.impl.data-fetch fulcro.client.network fulcro.client.logging om.next fulcro.client.impl.om-plumbing fulcro.i18n}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/core.cljc"] waiting for #{fulcro.client.util fulcro.client.mutations fulcro.client.impl.application fulcro.client.network fulcro.client.logging om.next fulcro.client.impl.om-plumbing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "atlas_crm/api/mutations.cljs"] waiting for #{fulcro.client.mutations fulcro.client.logging om.next fulcro.client.routing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/routing.cljc"] waiting for #{fulcro.client.util fulcro.client.core fulcro.client.mutations fulcro.client.logging om.next}
17-11-29 12:48:06 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "atlas_crm/ui/app/routes.cljc"] waiting for #{fulcro.client.routing}
17-11-29 12:48:07 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro_css/core.cljc"] waiting for #{om.next}
<- Compile CLJS: om/next.cljc (15087 ms)
Cache write: om/next.cljc
aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
{:aborted [:shadow.build.classpath/resource "fulcro/client/util.cljc"], :pending #{om.next}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.compiler/par-compile-one (compiler.clj:647)
shadow.build.compiler/par-compile-one (compiler.clj:622)
shadow.build.compiler/par-compile-cljs-sources/fn--11576/iter--11577--11581/fn--11582/fn--11583/fn--11584 (compiler.clj:721)
clojure.core/apply (core.clj:657)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/apply (core.clj:661)
clojure.core/bound-fn*/fn--5471 (core.clj:1995)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
cljs.coreom.next is doing that its this slow{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0a79626b6e657d27696660794a38243a243b3a3c"}, :content ("[email protected]")}, bumped the timeout to 60secom.next always re-renders from the root?om.next a long while ago and it was pretty terrible performance wiseident if you know what that means. And then it will only re-render what is bound to that ident:karma target but it gives me:
[:ci] Compiling ...
{:type :shadow.build.targets.karma/test-namespaces, :test-namespaces [atlas-crm.ui.components.entity-selector-test atlas-crm.ui.impl.routing.path-test atlas-crm.ui.impl.routing.linear-search-router-test], :entries [shadow.test.env atlas-crm.ui.components.entity-selector-test atlas-crm.ui.impl.routing.path-test atlas-crm.ui.impl.routing.linear-search-router-test shadow.test.karma]}
no goog/base.js
{}
ExceptionInfo: no goog/base.js
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.output/closure-defines-and-base (output.clj:46)
shadow.build.output/closure-defines-and-base (output.clj:41)
shadow.build.targets.karma/flush-karma-test-file (karma.clj:72)
shadow.build.targets.karma/flush-karma-test-file (karma.clj:67)
shadow.build.targets.karma/flush (karma.clj:94)
shadow.build.targets.karma/flush (karma.clj:91)
shadow.build.targets.karma/process (karma.clj:109)
shadow.build.targets.karma/process (karma.clj:99)
clojure.lang.Var.invoke (Var.java:381)
shadow.build/process-stage (build.clj:110)
shadow.build/process-stage (build.clj:102)
shadow.build/flush (build.clj:316)
shadow.build/flush (build.clj:312)
shadow.cljs.devtools.api/compile* (api.clj:189)
shadow.cljs.devtools.api/compile* (api.clj:184)
shadow.cljs.devtools.cli/do-build-command (cli.clj:40)
shadow.cljs.devtools.cli/do-build-command (cli.clj:30)
shadow.cljs.devtools.cli/do-build-commands/fn--61387/fn--61388 (cli.clj:68)
clojure.core/binding-conveyor-fn/fn--5476 (core.clj:2022)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
bin/lein run -m shadow.cljs.devtools.cli compile cishadow-cljs compile ci 😉goog/base.js in the compile output:lein true it basically calls exactly the command you used:ci {:target :karma
:output-to "resources/public/ci/karma.js"}
Is this config maybe wrong?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e5968d84818a92c886898f96a5d7cbd5cbd4d5d2"}, :content ("[email protected]")}:browser-test working with karma?:karma target just always emits one file:ns-regexp:js-options {:js-provider :shadow}:karma or :browser-test or both?:karma is basically a very simplified version that doesn’t do live reloading or a REPL:karma does not work:browser-test target to automatically include all files that end on -cards:ns-regexp "-(test|cards)$" should do it?cljs.test related or do they?-card namespaces so I don't have to keep adding them to one file:target :devcards would be useful 😉:browser-test to work again, for some reason it does not seem to pick up my runner-ns:karma{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c0b3a8a1a4afb7eda3acaab380f2eef0eef1f0f8"}, :content ("[email protected]")}. same issue indeed.FROM circleci/clojure:lein-2.7.1 USER root RUN curl -sL | bash - RUN apt-get install -y nodejs # RUN wget -q -O - | apt-key add - RUN echo 'deb stable main' >> /etc/apt/sources.list RUN apt-get update && apt-get install --no-install-recommends -y google-chrome-stable
lein or shadow-cljs directly?shadow-cljs:source-paths ["src" "checkouts/the-thing/src"]:dependencies so its dependencies get picked up properlylein test via circleci succeeded. not very meaningful since there are no tests but still 😉.yml thats such a horrible format 😛:karma/`:browser-test` breaking are not coolshadow-cljs server in the background and then run a bunch of things against that server====>> Saving Cache Error: Skipping cache - error checking storage: not supported
["path" :as path] today, got huge error messages...arrary-of caused.. didn't check itshadow-cljs CLI script does this as well I’m quite confident it works. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L3:target :browser which won’t work because its a node only package:target :nodejs, I used fs module=>> node target/main.js
SHADOW import error /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/shadow.module.main.append.js
/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154
var self__ = this;
^
RangeError: Maximum call stack size exceeded
at Array.join (native)
at cljs.core.Keyword.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154:94)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:31863:12)
at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
at /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9861:30
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9594:39)
at Object.cljs$core$print_prefix_map [as print_prefix_map] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:32481:18)
at cljs$core$print_map (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9871:8)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9680:23)
at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
=>> cat src/server/main.cljs
(ns server.main
(:require ["walk-sync" :as walk-sync]
[clojure.string :as string]
["fs" :as fs]
["path" :as path])) ; <---
(defn main! []
(println path) ; <---
(let [base-dir js/process.env.base
paths (filter
(fn [filepath] (string/ends-with? filepath ".tsx"))
(walk-sync base-dir))
*colors (atom [])]
(doseq [filepath paths]
(let [content (fs/readFileSync (str base-dir filepath) "utf8")]
(doseq [line (string/split-lines content)]
(if (string/includes? line "#")
(let [color (re-find (re-pattern "#[0-9a-f]{3,6}") line)]
(if (some? color) (swap! *colors conj color) (println line)))))))
(println (string/join "\n" (sort (set @*colors))))))
(defn reload! [] (main!))
println that?(js/console.log path) should work since it detects circlespath and it broke the global path.. so I tried to printprint is for clojure objects not JS objectsjs/console.log when in doubt[
[Circular] things#js ...cljs.user=> (println (clj->js {:a 1}))
#js {:a 1}
nil
cljs.user=>
console.log is longer to write, I preferred println first[:worker-error {:resources [[:shadow.build.classpath/resource "atlas_crm/ui/components/dialog.cljc"]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update} java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286]
target/shadow-cljsprn since thats not useful at all.target/shadow-cljs:lein. hmm do you have any kind of logging configured?logging.properties so thats not good 😛leinlein it uses whatever logging setup you have configuredslf4j-nop on the classpath, which means no logging at all.17-11-30 12:21:13 UnknownHost WARN [shadow.cljs.devtools.server.util:286] - failed to handle server msg {:resources [[:shadow.build.classpath/resource atlas_crm/ui/components/dialog.cljc]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update}
java.lang.Thread.run Thread.java: 748
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/bound-fn*/fn core.clj: 1995
clojure.core/apply core.clj: 661
...
clojure.core/with-bindings* core.clj: 1965 (repeats 2 times)
clojure.core/apply core.clj: 657
...
shadow.build.compiler/par-compile-cljs-sources/fn/iter/fn/fn/fn compiler.clj: 726
shadow.build.compiler/par-compile-one compiler.clj: 667
shadow.build.compiler/generate-output-for-source compiler.clj: 621
shadow.build.compiler/maybe-compile-cljs compiler.clj: 572
shadow.build.compiler/maybe-compile-cljs/fn compiler.clj: 596
shadow.build.warnings/get-source-excerpt warnings.clj: 55
shadow.build.warnings/get-source-excerpts warnings.clj: 52
clojure.core/into core.clj: 6815
clojure.core/reduce core.clj: 6748
clojure.core.protocols/fn/G protocols.clj: 13
clojure.core.protocols/fn protocols.clj: 75
clojure.core.protocols/seq-reduce protocols.clj: 24
clojure.core/seq core.clj: 137
...
shadow.build.warnings/get-source-excerpts/iter/fn warnings.clj: 41
shadow.build.warnings/get-source-excerpts/iter/fn/fn warnings.clj: 41
java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286
NoClassDefFoundError though{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2d5e454c49425a004e41475e6d1f031d031c1c1d"}, :content ("[email protected]")}. only change is that it now catches Throwable since NoClassDefFoundError is not an exceptionException in thread "async-dispatch-2" java.lang.ExceptionInInitializerError at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:253) at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253) at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61) at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59) at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79) at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63) at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343$fn__49346.invoke(util.clj:119) at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343.invoke(util.clj:119) at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973) at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975) at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986) at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace at clojure.lang.Compiler.currentNS(Compiler.java:7397) at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1310) at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843) at clojure.lang.LispReader.read(LispReader.java:275) at clojure.lang.LispReader.read(LispReader.java:206) at clojure.lang.LispReader.read(LispReader.java:195) at clojure.lang.RT.readString(RT.java:1871) at clojure.lang.RT.readString(RT.java:1866) at shadow.cljs.devtools.errors$user_friendly_error$fn__49243.<clinit>(errors.clj:254)
read-stringlein clean?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c350674687668777777"}, :content ("[email protected]")} at least fixes the java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.NamespaceException in thread "async-dispatch-8" java.lang.ExceptionInInitializerError at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:254) at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253) at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61) at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59) at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79) at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63) at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347$fn__49350.invoke(util.clj:119) at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347.invoke(util.clj:119) at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973) at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975) at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986) at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: Can't resolve find-ns at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1315) at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843) at clojure.lang.LispReader.read(LispReader.java:275) at clojure.lang.LispReader.read(LispReader.java:206) at clojure.lang.LispReader.read(LispReader.java:195) at clojure.lang.RT.readString(RT.java:1871) at clojure.lang.RT.readString(RT.java:1866) at shadow.cljs.devtools.errors$user_friendly_error$fn__49246.<clinit>(errors.clj:254)
*ns* binding seems to be the cause since I changed that and the error changed{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7e0d161f1a1109531d12140d3e4c504e504f4f4c"}, :content ("[email protected]")}. I removed that binding completely, maybe nrepl just doesn’t like doing that.shadow-cljs cljs-repl :id outputs response as I’d expect, but within Emacs/cider, after connecting and running (shadow.cljs.devtools.api/nrepl-select :id-of-build), responses come back, but they are always a string.cljs.user> (+ 1 2) "3"
(:value response) is a stringread-string the result I get back from the CLJS repl(read-string) conditionallyif thereC-c C-p) rather than a vanilla eval behaves as expected, reading the stringread-string the value I get from the client if all else fails{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfccd7dedbd0c892dcd3d5ccff8d918f918e8e8c"}, :content ("[email protected]")} has the configuration :devtools {:repl-timeout 30000} (if you still need it)read-string the REPL result Cursive breaks with Error handling response - class java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence
targets purpose. For example, does it make sense to create a custom target to pre-process the CSS files?:target is meant to define the target platform, ie. the thing thats going to run the generated JSshadow-cljs watch compile-css app , where app is the build targeting the browser. Is it correct? or what is the recommended way to add some extra steps to the build (e.g. compile sass)?shadow-cljs clj-run your.css/build manually(shadow.cljs.devtools.api/get-build-config :app) if it needs the configshadow-cljs to call when startingshadow-cljs until you REALLY need tolein (and boot and tools.deps clojure)The state is a clojure map representing the full shadow-build compiler state. TBD: open an issue if you want to know more about this. can you point me to where to find more info about it?shadow.build.data has some utility functionswatch mode?could not find module-entry: babel-runtime/core-js/symbol Any idea what might cause this?target/shadow-cljs/logging.* in case it still doesn’t work.Request URL:
localhost to connect my dev serverjs/location.hostname?:devtools {:after-load app.main/reload!
:preloads [shadow.cljs.devtools.client.hud]
:http-root "target"
:http-port 8080}
:http {:host ...} ?shadow.cljs.devtools.client.env in the javascript consoleuse-document-host is true so it will use js/document.location.hostname{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "097a61686d667e246a65637a493b27392738383c"}, :content ("[email protected]")}user-error: ‘cider-eval-last-sexp’ needs a ClojureScript REPL. If you don’t know what that means, you probably need to jack-in (‘C-c M-J’).
(shadow.cljs.devtools.api/nrepl-select :plugin) and (cemerick.piggieback/cljs-repl :plugin). I have shadow-cljs watch plugin and shadow-cljs node-nrepl in the background=>> yarn watch yarn run v1.3.2 $ shadow-cljs watch browser shadow-cljs - config: /Users/chen/repo/mvc-works/mvc-works.org/shadow-cljs.edn version: 2.0.115 shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.pom from Retrieving thheller/shadow-client/1.3.0/shadow-client-1.3.0.pom from Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.jar from Retrieving thheller/shadow-client/1.3.0/shadow-client-1.3.0.jar from ^C =>> time yarn watch yarn run v1.3.2 $ shadow-cljs watch browser shadow-cljs - config: /Users/chen/repo/mvc-works/mvc-works.org/shadow-cljs.edn version: 2.0.115 shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.jar from ^C real 1m3.436s user 0m0.433s sys 0m0.083s
:local/root of deps.edn in shadow-cljs? https://clojure.org/reference/deps_and_cli#_dependenciesclj-run fails (eg. an error like failed to load namespace: foo.x), should it return a non-zero error code? (or is there a way to make that happen?):entries supports strings and they current expect full paths"/src/main.js" as the entry in the config. but it is not currently supported to specify devtools and such since that expects cljs namespaces"./src/main.js" support? that's the common syntax in Node since Node prefers relative paths that start with ./(println #"(\p{Lu}+[\p{Ll}\u0027\p{Ps}\p{Pe}]*)")
;; (while developing): #"(\p{Lu}+[\p{Ll}\u0027\p{Ps}\p{Pe}]*)"
;; (advanced compilation): #"(p{Lu}+[p{Ll}\u0027p{Ps}p{Pe}]*)"\p, never used that before?:compiler-options {:language-out :ecmascript6}\p before, but it is used in the funcool cuerdas string library, which currently does not work with advanced compilation due to this.target/shadow-cljs has some info?with-let macro results in some externs inference warnings:
https://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L48
Cannot infer target type in expression (. c__50784__auto__ -ratomGeneration) Cannot infer target type in expression (. with-let79468 -generation)
^js in front of v and c#^clj not js(let [^clj ~v (reagent.ratom/with-let-values ~k)] …v (with-meta {:tag 'clj} (gensym "with-let")) in the let above(with-meta (gensym "with-let") {:tag 'clj})v (with-meta (gensym "with-let") {:tag 'clj})
and an inline ^clj for the symbol that is bound within the quote
(when-some [^clj c# reagent.ratom/*ratom-context*] ...)^clj c# to workrm -rf target)
41 | (deftype GZIPPacker [packer] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. GZIPPacker -prototype) -taoensso$sente$interfaces$IPacker$) -------------------------------------------------------------------------------- 42 | taoensso.sente.interfaces/IPacker 43 | (pack [_ x] 44 | (try 45 | (->> x (pack packer) (gzip))
watch process, the warnings are gone (until i remove the caches)$thing$foo$(defprotocol IExplain (explain [this value])) (defrecord ExplainStruct [struct-schema] IExplain (explain [this value] (first (struct/validate value struct-schema))))results in
24 | (defrecord ExplainStruct [struct-schema] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. ExplainStruct -prototype) -my-app$lib$forms$IExplain$) -------------------------------------------------------------------------------- 25 | IExplain 26 | (explain [this value] (first (struct/validate value struct-schema))))
shadow-cljs clj-repl and then (require 'shadow.build.cljs-hacks :reload) and compile again?elide-require stuff but besides that nothing that should interfere with the compileclj-repl command above, and 4) edited a file to trigger the watch. Now the warnings are gone.shadow-cljs itself. just never saw it when using it as a lib.(in-ns 'cljs.analyzer) always felt like it could break any time{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f6859e97929981db959a9c85b6c4d8c6d8c7c7cf"}, :content ("[email protected]")}. cljs.core was force-loaded after the hacks so it was overwriting them again.shadow-cljs emits an undeclared var warning for letfn forms if the bindings are not in the right orderletfn should be available to all definitionsshadow-cljs issue{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c6b5aea7a2a9b1eba5aaacb586f4e8f6e8f7f4f6"}, :content ("[email protected]")}.clj now?Exception in thread "main" clojure.lang.ExceptionInfo: missing instance {}
at clojure.core$ex_info.invokeStatic(core.clj:4739)
at clojure.core$ex_info.invoke(core.clj:4739)
at shadow.cljs.devtools.server.runtime$get_instance_BANG_.invokeStatic(runtime.clj:11)
at shadow.cljs.devtools.server.runtime$get_instance_BANG_.invoke(runtime.clj:8)
at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:104)
at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:99)
at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:125)
at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:115)
at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
at build.watch$_main.invokeStatic(watch.clj:12)
at build.watch$_main.invoke(watch.clj:8)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
(api/with-runtime (api/watch ...)) if you want a short lived runtime. (shadow.cljs.devtools.server/start!) if you want to start and leave it running in the background.2 | (ns app.updater (:require [respo.cursor :refer [mutate]])) 3 | 4 | (defn updater [store op op-data] 5 | (case op ---------^---------------------------------------------------------------------- Cannot infer target type in expression (. G__35616 -fqn) -------------------------------------------------------------------------------- 6 | :states (update store :states (mutate op-data)) 7 | :content (assoc store :content op-data) 8 | store))
=>> clj -m build.compile Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http) at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106) at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106) at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30) at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:23) at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:108) at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:99) at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:125) at shadow.cljs.devtools.api$watch.invoke(api.clj:111) at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:115) at shadow.cljs.devtools.api$watch.invoke(api.clj:111) at build.compile$_main$body_fn__29460__auto____31659.invoke(compile.clj:9) at build.compile$_main.invokeStatic(compile.clj:8) at build.compile$_main.invoke(compile.clj:7) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.lang.Var.applyTo(Var.java:702) at clojure.core$apply.invokeStatic(core.clj:657) at clojure.main$main_opt.invokeStatic(main.clj:317) at clojure.main$main_opt.invoke(main.clj:313) at clojure.main$main.invokeStatic(main.clj:424) at clojure.main$main.doInvoke(main.clj:387) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:702) at clojure.main.main(main.java:37)
(ns build.compile
(:require [shadow.cljs.devtools.api :as api]
[shadow.cljs.devtools.server :as server]
[clojure.java.shell :refer [sh]]))
(defn -main []
(api/with-runtime
(api/watch :browser)))
clj(server/start!)watch you can’t use with-runtime. only for compile.start! should workapi/with-runtime (api/compile ...)clj. it is just strictly worse than using shadow-cljs directly(server/stop!)clj won’t solve that for you.clj file, not touching it from REPL actuallyclj will always launch a new JVM so I’m not sure what you are hoping to gainshadow-cljs twice from npm script(ns build.compile) (defn do-something [] ...)clj to run that.shadow-cljs clj-run build.compile/do-something(api/watch ...)clj?cljclj-run sub-command beforeclj doesdeps.edn if I call shadow-cljs clj-run Cannot infer target type in expression (. G__35616 -fqn)clj-run?clj has a few issues with dependencies, it sometimes loads old versionslein or boot. don’t know why … it is alpha so be careful.clj-run, no warning now{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "186b70797c776f357b74726b582a362836292a2a"}, :content ("[email protected]")} which should start a bit faster. if you already have ssl configured it now supports http2 as well.:npm-deps is supported when libs use it. in your project you directly npm install (or yarn) yourself:npm-deps should also work for your own project, no? that’s what i have been doing.. then my libs/apps are consistentshadow-cljs - config: /Users/chen/repo/mvc-works/coworkflow/shadow-cljs.edn version: 2.0.122 shadow-cljs - starting ... Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http) at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106) at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106) at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30) at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:23) at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:95) at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:86) at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:112) at shadow.cljs.devtools.api$watch.invoke(api.clj:98) at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:102) at shadow.cljs.devtools.api$watch.invoke(api.clj:98) at build.watch$_main.invokeStatic(watch.clj:9) at build.watch$_main.invoke(watch.clj:7)
(ns build.watch
(:require [shadow.cljs.devtools.api :as api]
[shadow.cljs.devtools.server :as server]
[clojure.java.shell :refer [sh]]))
(defn -main []
(server/start!)
(api/watch :browser))
clj-run you don’t need server/start!api/watchserver/start!yarn shadow-cljs clj-run build.watch/-main(api/watch :browser)clj-run only does a with-runtime which is a lightweight runtime that doesn’t start the embedded serverwatch needs the embedded serverwatch via clj-runindex.html to match the MD5 output names in manifest.edn. I’d like to make sure these paths get re-written to their base forms during dev. I’m trying to think of the most logical way to do this… what came to mind is using clj-run to run my-app.build/watch, and in that function, call the write-static-resource-paths! function once, after the initial compile of api/watch.watch is that it starts a background threadshadow-cljs watch the-build doesn’t do?"del": "rm -rf dist/*",
"release": "shadow-cljs release browser",
"compile-ssr": "shadow-cljs compile ssr",
"html": "node target/ssr.js && cp entry/manifest.json dist/",
"build": "yarn del && yarn release && yarn compile-ssr && yarn html"
shadow-cljs command line, if launching it from Clojure is not better.(ns build.release
(:require [shadow.cljs.devtools.api :as api]
[shadow.cljs.devtools.server :as server]
[clojure.java.shell :refer [sh]]))
(defn -main []
(println (sh "rm" "-rf" "dist/*"))
(api/with-runtime (api/release :browser))
(api/with-runtime (api/compile :ssr))
(println (sh "node" "target/ssr.js"))
(println (sh "cp" "entry/manifest.json" "dist/")))
ns for everything(ns app.build) (defn release [] ...) (defn watch [] ...)clj-run, makes things much easier to organize imhobuild.release works with clj-run right?clj calls a specific function from CLIclj can’t call functions directly, only -main yeahclj-run you also don’t need api/with-runtime(defn release [] (println (sh "rm" "-rf" "dist/*")) (api/release :browser) (api/compile :ssr) (println (sh "node" "target/ssr.js")) (println (sh "cp" "entry/manifest.json" "dist/")))
api/watch starts a background thread. its basically an async function. it returns as soon as the first compile completes(defn watch [] (api/watch :browser) (api/repl :browser))
api/repl would “block” until you exit the replException in thread "main" java.lang.AssertionError: Assert failed: (map? http) at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106) at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106) at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30)
watch to do that shadow-cljs watch does not do?api/watch that doesn’t make much senseAssert failed: (map? http) goes awaylein deps :tree with shadowshadow-cljs pom ; mvn dependency:treemvn stuff but that seems to worklein deps :tree to a new “FAQ” page, as I wasn’t sure where else to put it: https://github.com/thheller/shadow-cljs/wiki/FAQcli release with a decent documentation, I would like to take a spin and see if that works in my case: replacing my npm scripts.clj command takes about 2s to run in my machine, that's acceptable. And it's much better than Boot visually.shadow-cljs takes long time to start too. It's reasonable to start a compiler with so much time, but not fast enough for scripts.clj to see if there's any good ideas.lumo when I writing simple script XDtime yarn your-scripts b) run yarn shadow-cljs server, in another terminal time yarn your scripts. The difference should be substantial when the server is running since you only pay for startup once.shadow-cljs start|stop|restart at some point which starts a background server so you could modify your scripts to first call start, then do all the rest, then call stop.shadow-cljs clj-run start as fast as clj, it is slow since it wants to provide easy access to shadow-cljs itself. as soon as you are going to use anything you are going to pay for that startup time again. UNLESS you are using the server instance …:compiler-options for :release? I’d like to set :devcards true but only for dev{:dev {:compiler-options {:devcards true}}}shadow-cljs release app from com.cognitect/transit-cljs:source-paths and :dependencies? I want to have a separate build for devcards.`` $ shadow-cljs watch app shadow-cljs - config: /Users/chen/repo/cumulo/cumulo-workflow/server/shadow-cljs.edn version: 2.0.123 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - starting ... RuntimeException: java.net.BindException: Address already in use io.undertow.Undertow.start (Undertow.java:214) shadow.undertow/start (undertow.clj:147) shadow.undertow/start (undertow.clj:115) shadow.cljs.devtools.server/start-http/fn--21391 (server.clj:109) shadow.cljs.devtools.server/start-http (server.clj:108) shadow.cljs.devtools.server/start-http (server.clj:104) shadow.cljs.devtools.server/start-system (server.clj:137) shadow.cljs.devtools.server/start-system (server.clj:118) shadow.cljs.devtools.server/start! (server.clj:215) shadow.cljs.devtools.server/start! (server.clj:205) shadow.cljs.devtools.server/start! (server.clj:208) shadow.cljs.devtools.server/start! (server.clj:205) shadow.cljs.devtools.server/from-cli (server.clj:312) shadow.cljs.devtools.server/from-cli (server.clj:288) shadow.cljs.devtools.cli/blocking-action (cli.clj:114) shadow.cljs.devtools.cli/blocking-action (cli.clj:101) shadow.cljs.devtools.cli/main (cli.clj:162) shadow.cljs.devtools.cli/main (cli.clj:117) clojure.core/apply (core.clj:661) clojure.core/apply (core.clj:652) shadow.cljs.devtools.cli/-main (cli.clj:204) shadow.cljs.devtools.cli/-main (cli.clj:202) clojure.lang.Var.applyTo (Var.java:702) clojure.core/apply (core.clj:657) clojure.main/main-opt (main.clj:317) clojure.main/main-opt (main.clj:313) clojure.main/main (main.clj:424) clojure.main/main (main.clj:387) clojure.lang.Var.applyTo (Var.java:702) clojure.main.main (main.java:37) Caused by: BindException: Address already in use sun.nio.ch.Net.bind0 (Net.java:-2) sun.nio.ch.Net.bind (Net.java:433) sun.nio.ch.Net.bind (Net.java:425) sun.nio.ch.ServerSocketChannelImpl.bind (ServerSocketChannelImpl.java:223) sun.nio.ch.ServerSocketAdaptor.bind (ServerSocketAdaptor.java:74) org.xnio.nio.NioXnioWorker.createTcpConnectionServer (NioXnioWorker.java:190) org.xnio.XnioWorker.createStreamConnectionServer (XnioWorker.java:243) io.undertow.Undertow.start (Undertow.java:173) shadow.undertow/start (undertow.clj:147) shadow.undertow/start (undertow.clj:115) shadow.cljs.devtools.server/start-http/fn--21391 (server.clj:109) shadow.cljs.devtools.server/start-http (server.clj:108) shadow.cljs.devtools.server/start-http (server.clj:104) shadow.cljs.devtools.server/start-system (server.clj:137) shadow.cljs.devtools.server/start-system (server.clj:118) shadow.cljs.devtools.server/start! (server.clj:215)
:http {:port ...} to override the default portresources/public as the public folder instead of public?:output-dir?public, which doens't exist:http-root is what I was looking for 🙂["pixi.js" :as [Pixi]]:as should be a plain symbol, rather than a vector of symbols - eg.
["pixi.js" :as Pixi]:as Pixi.Uncaught TypeError: Cannot redefine property: default$
at Function.defineProperty (<anonymous>)
at index.js:23
at Array.forEach (<anonymous>)
at Object.shadow$provide.module$node_modules$pixi_js$lib$core$index (index.js:21)
at shadow.js.require (VM2328 shadow.js.js:51)
at Object.shadow$provide.module$node_modules$pixi_js$lib$index (index.js:19)
at Object.shadow.js.require (VM2328 shadow.js.js:51)
at phlox.main.js:10
(anonymous) @ index.js:23
shadow$provide.module$node_modules$pixi_js$lib$core$index @ index.js:21
shadow.js.require @ VM2328 shadow.js.js:51
shadow$provide.module$node_modules$pixi_js$lib$index @ index.js:19
shadow.js.require @ VM2328 shadow.js.js:51
(anonymous) @ phlox.main.js:10
default$ for cljs compat since cljs munges default to default$forEach copying the properties from _math with was required above_constdefault$ that blows updefault property but it doesn't know about default$export * from './math';then in the published
node_modules, that has been compiled to
var _math = require('./math');
Object.keys(_math).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _math[key];
}
});
});
:http {:host "0.0.0.0"} in the top level, same as :builds0.0.0.0, seems way more reasonableshadow/start-worker is not in devtools.api. I tried watch but ran into an issue where runtime/instance-ref was not set, so I figure I'm doing something wrong.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9be8f3fafff4ecb6f8f7f1e8dba9b5abb5aaa9af"}, :content ("[email protected]")} which changes the default host back to 0.0.0.0(shadow.cljs.devtools.server/start!) to start and stop!start-worker is just dev the wiki is a bit oldwatch to match the CLIstart! fn will launch the “runtime” which runs in a background thread(s)watch in particular needs thatwith-runtime for watch since it needs to keep running in the backgroundwith-runtime is not suitable for watchstart! isstart!, I'm not interested in using the shadow http server in this case.watch needs that to reload files thoughstart! not by with-runtimewith-runtime will use the server created by start! though so it won’t launch a new runtimeDec 28, 2017 10:36:35 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.6.Final IllegalArgumentException XNIO001001: No XNIO provider found org.xnio.Xnio.doGetInstance (Xnio.java:255)Is this a known, common, mistake?
mvn installed you can clj -Spom and mvn dependency:tree❯ boot -d thheller/shadow-cljs -B with-cp --write --file /tmp/bootcpfile Retrieving maven-metadata.xml from (6k) Retrieving shadow-cljs-2.0.124.pom from (7k) Retrieving xnio-nio-3.3.6.Final.pom from (6k) Retrieving shadow-cljs-2.0.124.jar from (376k) Retrieving xnio-nio-3.3.6.Final.jar from (113k)That's interesting.
tools.deps definitely has some unresolved issues. there was another issue where it picked an ancient version of clojurescript over a more current one(shadow.server/start! {})
(shadow/watch
{:build-id :hoop/app
:target :browser
:output-dir "public/hoop/js"
:asset-path "/public/hoop/js"
:modules {:main {:entries [pro.juxt.hoop.app]}}})
Which is starting a server on 9360, but I can't see the build anywhere, or see any way to access the js, any hints?"public/hoop/js"?find to check.user=> (def stop (pro.juxt.krei.core/watch)) shadow-cljs - server running at [:hoop/app] Configuring build. #'user/stopThis is the only output I see, am I doing something wrong maybe?
stop! immediately watch watch?krei.core/watch returns a function, which calls (shadow.server/stop!). So, no.compile* with your config?*out* or anything else the output would go elsewhere*out*start!watchuser=> (shadow.cljs.devtools.server/start! {})
shadow-cljs - server running at
:shadow.cljs.devtools.server/started
(shadow.cljs.devtools.api/compile* {:build-id :hoop/app
:target :browser
:output-dir "public/hoop/js"
:asset-path "/public/hoop/js"
:modules {:main {:entries '[pro.juxt.hoop.app]}}} {})
[:hoop/app] Compiling ...
AssertionError Assert failed: (cljs-util/is-file-instance? cache-root) shadow.cljs.devtools.config/make-cache-dir (config.clj:115)
I guess the exception is lost into the background when it happens during a watch.DEVTOOLS: connected! browser.cljs:25:10 DEVTOOLS: disconnected! browser.cljs:25:10Immediately after one another.
:devtools {:autoload true} in my build config fwiwuser=> [XNIO-1 I/O-3] WARN - stale websocket client, no worker for build :app there we are. Something to work with!The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs". Is there a config or something I need to use?npm install react react-dom create-react-class/cljs directory in your monorepo with /cljs/package.json for npm and /cljs/shadow-cljs.edn:output-dir to ../shop-clientA/public/js or whateverlein repl for everything CLJ and one shadow-cljs instance for everything CLJSboot launch and everything we need is started. It's a nice experience.
We've not had any issues with mixing cljs & clj dependencies in a project in the past. Although, one time I did manage to get cljs running in it's own boot pod, with it's own dependencies, it was a nice hack. The thingis, it didn't solve any problems, so we never used it.cljsA -> npm-deps [jslib 1.0] cljsB -> npm-deps [jslib 2.0]with normal clojurescript? Does cljsA get jslib1.0 and cljsB get jslib 2.0? That would make sense to me in a "node.js world", so I will be surprised if nobody has at least considered this before.
om.dom in om is broken with shadow-cljs. but if render with other library(sablono), that works.om.dom should work just fine.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ff8c979e9b9088d29c93958cbfcdd1cfd1cecdc8"}, :content ("[email protected]")} fixes the pixi.js issue from a couple days ago{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9eedf6fffaf1e9b3fdf2f4eddeacb0aeb0afaca7"}, :content ("[email protected]")} which doesn’t do the AOT on install:after-load some.ns/reload:autoload true:external-config {:devtools/config {:features-to-install [:formatters :hints]}} to configure binaryage/devtools:compiler-options, so :compiler-options {:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}:external-config, not sure if that is a figwheel thing:manifest-name "manifest.json". the output format is chosen by file ext, just defaults to manifest.edn:module-hash-names and need to get the actual filenames (since they are hashed){:build-options {:manifest-name "foo.json"}}:target abstraction is to capture as much as possible about the “final” product so it requires almost no post processing. In your case there should be a :target :chrome-extension where the config itself contains everything required to generate all the support files the chrome extensions want.:browser sort of fits but not exactly since you’ll never serve things from a webserver and such:target :chrome-extension thoughmanifest.json itself and figure out what if needs to do from thereshadow-cljs/src/main/shadow/build/targets/chrome_extension.clj a try. I will ask here if I bump into problems.:target some.ns/process is supported:escape-unicode false here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L308 was useing icelandic chars for manifest metadata and they all got \u00xxx:module-hash-names from the state passed into this function. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L277
(I'm not useing this namespace or file directly, but creating code deriving from it).:module-hash-names works by modifying :output-name for the module, so others don’t need to be concerned with it:output-name defaults to :module-id+`.js`, :module-hash-names turns it into <module-id>.<hash>.jscljs-runtime/*.jscljs-runtime files are written in that fn callflush-sources call, see https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L178-L209:source-ids is what I'm looking for:build-sources:modules the :sources of each module:build-sources is all sources from a buildstate is too large to print so there is no easy way to inspect it[[:shadow.build.classpath/resource "goog/base.js"] [:shadow.build.classpath/resource "goog/debug/error.js"] [:shadow.build.classpath/resource "goog/dom/nodetype.js"] [:shadow.build.classpath/resource "goog/string/string.js"] [:shadow.build.classpath/resource "goog/asserts/asserts.js"] ...elidedslashes to dots = real filename.
(data/get-source-by-id state source-id):resource-name is the relative filename on the classpath:url contains the source location:file may also be present but only for actual file, not files from libs in .jarsdata/get-output! fn returns the generated code for that resourceshadow-cljs server which avoids spinning up a new JVM for everythingshadow-cljs start runs the server in the background:npm-module may already solve thatcreate-react-app https://www.youtube.com/watch?v=BLDX5Twt2zkshadow-cljs at all so that is probably my fault 😉figwheel is pretty deeply embedded in pretty much every template/tutorial these dayscider, some people here use ittools.deps, similar to the current lein supportdeps.edntools.deps today but lose all the optimizations the shadow-cljs script doesclj -m shadow.cljs.devtools.cli compile foo is equal to shadow-cljs compile footools.deps for CLJS yetnpm and suchcljs-deps.edn than trying to integrate into deps.edntools.deps assumes a classpath which is a JVM thingnpm doesn’t have a classpathtools.deps had existed when I started I would have used that insteadlein and boot use 😉shadow-cljs node-repl if you need a quick REPL aware of your classpath, might not need lumo 😉lumo is better if you want “scripts”:target :node-script to build the “scripts” and run them directly. lumo just lets you skip the build step which is nice.:node-script to npm (with a package.json to declare deps):npm-deps? not sure I remember the issue:npm-deps declared in a deps.cljs?:npm-deps inside a deps.cljs file inside of the dependent project:npm-deps? I don't know of anynpm stuff, ie. node_modules/*:advanced DCEmain.js, adding :output and :output-to in build options didnt made a difference.:main is called main.js:output-name:target clj.chrome-extension/process (clj is just whatever source directory is on cp)
https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998runtime-bundled? (or (nil? optimizations) (= :none optimizations) (= :simple optimizations)):shadow.build/mode in the state is either :dev or :releasebrowser targetns clj.chrome-extension
(:refer-clojure :exclude (flush require))
(:require [shadow.build :as build]
[shadow.build.api :as build-api]
[ :as io]
[clojure.set :as set]
[clojure.data.json :as json]
[shadow.build.data :as data]
[shadow.build.output :as output]
[shadow.build.targets.shared :as shared]
[shadow.build.classpath :as cp]
[shadow.build.modules :as modules]
[shadow.cljs.repl :as repl]
[shadow.build.targets.browser :as browser]))
(defn flush-crx-manifest [{:keys [build-options chrome-extension stage mode] :as state}
{:keys [chrome-extension optimizations] :as config}]
(let [runtime-bundled? (or (nil? optimizations) (= :none optimizations) (= :simple optimizations))
chrome-extension (:chrome-extension config)
cljs-runtime-path (:cljs-runtime-path build-options)
js-main (-> state ::modules/modules :main :output-name)
js-filelist (mapv #(->> (data/get-source-by-id state %)
:output-name
(io/file cljs-runtime-path)
.getPath)
(:build-sources state))
data (merge {:manifest_version (or (:manifest_version chrome-extension) 2)
:name (or (:name chrome-extension) "unnamed-shadow-cljs-extension")
:version (or (:version chrome-extension) "1.0.0")
:background {:scripts (if runtime-bundled?
(into [js-main] js-filelist)
[js-main])}}
chrome-extension)
manifest-name "manifest.json"
manifest-file (data/output-file state manifest-name)
manifest (with-out-str
(json/pprint data :escape-slash false :escape-unicode false))]
(spit manifest-file manifest))
state)
(defn process
[{::build/keys [stage mode config] :as state}]
(-> state
(browser/process state)
(cond->
(= stage :flush)
(flush-crx-manifest config))))d3 as a deps in a shadow-cljs project. I've found that in shadow-cljs demo/browser.cljs, it uses (:require ["d3" :as d3]) to include d3 but the "d3" in shadow-cljs.edn was commented out. I am wondering how the d3 in demo/browser.cljs can work. Should I add d3 in the package.json and (:require ["d3" :as d3]) to make d3 work in my project?d3 to package.json and (:require ["d3" :as d3]), it works!:preprocess a.qualified/symbol syntax. so far I have gotten away without any configuration for this and babel in theory could automatically be applied if there was a .babelrc presentd3-* packages instead of the d3 meta package. eg. (:require ["d3-color" :as d3-color]) instead of accessing the d3.color property. avoids always importing everything."d3-color" here means I should add a d3-color to my package.json in the same directory of shadow-cljs.edn?d3 they will all be there alreadypackage.json:shadow.build/mode showed to me :dev despite useing whitespace optimization. As for background scripts, it takes an array so I see it as one way to serve the depending js files, maybe there's another way to do it, but for example adblockplus uses 7 js files in background scripts. If it's only for development then it's probably ok, the user needs to http regex match if they want it to run on all or only specific addresses.:optimizations only apply for shadow-cljs release. they are ignored otherwise.cljs-runtime dir get bundled too.importScripts or something to load other files:module-hash-names in the example? that doesn’t seem useful for chrome exts? the hash names are meant to that you can http cache the files forever since new versions will have different namesoutput ns at some point:compact mode at some point which did basically that:module-hash-names should be, don't think you copied all the code above 🙂 ?inject-loader-setup-release useful?flush is the last stepflush only takes the compiled resources and writes it to disk in whatever formatflush also always happens by default for safetyflush may still happenrender again:before-load to unmount and then mount :after-loadinit once, then repeated start -> stop -> start -> ... for each hot reload(js/document.getElementById "app")(defonce app-container (js/document.getElementById "app")) and then (r/render [..] app-container) is probably the safer thing to do(js/document.getElementById "app")?<div id="app"> in your html?(route/app-routes)?:output-dir "target/js" :output-to "js/main.js"Tried adding the autoreload
:devtools {:autoload true}
and starting the repl
shadow-cljs cljs-repl :my-id
opening the extension background page I get
main.js:90082 WebSocket connection to '' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED DEVTOOLS: disconnected!must be my config, read that websockets are fine in crx's.
js/document.location.hostname to connect to which is incorrect here:devtools {:use-document-host false}cljs-devtools but it does have its own little console utilities which do basic formatting:devtools {:preloads [devtools.preload]} … way too much devtools in that line but it works 😉cljs-devtools on the classpath{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e2918a83868d95cf818e8891a2d0ccd2ccd3d1d2"}, :content ("[email protected]")} should automatically include it if its on the classpathcompile?:optimizations only applies for releasetrf is broken on extraction…compiler is moving the literal string to a varcljs.env/*compiler* atomlein clean in yearsns is parsed nothing else[:cljs.analyzer/namespaces the-ns] is written to a file so anything thats in there just works:use-document-host false then what I got was one of the stranger error logs I've seen 🙂
https://pastebin.com/MwwCmCsH
short research led me to inline scripts in html causing this, it's maybe a longshot here
https://developer.chrome.com/extensions/tut_migration_to_manifest_v2#inline_scripts
(I'm also perfectly fine not haveing hot-reload, so no stress about this)main.js:89433 DEVTOOLS: load JS goog/debug/error.js
main.js:89487 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-M37Ss2WONZF7RdLxeAaEIHlfH/yox80jtDrUm4wIlr8='), or a nonce ('nonce-...') is required to enable inline execution.goog/debug/error.js since it doesn't know that its already loadedDEVTOOLS: connected! main.js:89433 DEVTOOLS: disconnected!
[2018-01-11 01:47:54 - WARNING] stale websocket client, please reload client :vast
shadow-cljs cljs-repl :vast ?js/eval insteadshadow-cljs watch vastcljs-repl vast only if you want the actual replwatch is running)script-eval thingeval worksscript-eval just use (js/goog.global.eval code) instead of creating a script elementjs/eval direct instead of going through goog.global try and see what works 😉:http-handler)shadow.cljs.devtools.client.browser is being injected since I'm not useing the same name. Only quirk was that I had to add this into my manifest "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"js/eval would worksrc/shadow/cljs/devtools/client/browser.cljs if you :source-paths is ["src"]load anything before REPL init successfulgoog.dependencies_ stuff is not properly set(defn flush-crx-to-file
[{:keys [polyfill-js unoptimizable build-options build-sources] :as state}
{:keys [output-to] :as config}]
(let [prepend
(str unoptimizable
(output/closure-defines-and-base state)
"var shadow$provide = {};\n"
"goog.global[\"$CLJS\"] = goog.global;\n")
out
(->> build-sources
(map #(data/get-source-by-id state %))
(remove #(= "goog/base.js" (:resource-name %)))
(map #(data/get-output! state %))
(map :js)
(str/join "\n"))]
(spit output-to (str prepend out)))
state)
map step that adds the two lines per file:devtools {:async-require true} and just use the default :browser outputasync-require will load things via fetch instead of the usual closure debug loaderfetch should just worklein (or boot)tools.deps):source-paths and :dependencies from shadow-cljs.edn, https://stackoverflow.com/a/7741790/3421050BUJAKA! main.js:89714 DEVTOOLS: connected! main.js:89714 DEVTOOLS: REPL init successful main.js:89714 DEVTOOLS: load JS vast/core.cljs core.cljs:31 BUJAKA! main.js:89714 DEVTOOLS: load JS vast/core.cljs core.cljs:31 BUJAKA!
clj -m boot.deploy 😉:boot.deploy/config {...} in deps.ednclj instead of boot? 😉shadow-cljs clj-run boot.deploy with [boot/deploy ...] in my depslein run -m boot.deploy … everything that is able to launch a JVM should worklein boot and just invoke namespacesboot binaryjava -cp (clj -Spath) boot.App repl running boot without boot 😄:devtools :http-root and the css is embedded in the page with an absolute path the css will be reloadedshadow.dom. the prefix kinda stuck."dlt/events.cljs" is the circledlt.fx look like?dtl.graphql.core?src/main and src/test both having a dlt.core or so?target/shadow-cljs/builds directory:exlusions are incorrect, just one vector with symbols, no nested vectorsflatten in there 😛cljsjs is all ignored anyways so it doesn’t matter much which version you have on the classpath.clj files next to .cljs filessrc/main where all sources live clj,cljs,cljcsrc/test for tests etc.js include you have might get you in trouble at some point.cljs if possible.jar and publish that, the relative path will be invalid since it wouldn’t be in the jarCircular dependency detected: circular.foo -> circular.util.lib -> circular.foo)--reload option for clj-run?clj-repl and invoking the function via the REPL while developing it(require 'the.ns :reload) thenLoad file in REPL directly as well which also works--reloadnpm run release) and this is what our ci / build systems call--reload permanently then though and just let it always reload?npm run release not using the latest version of that codeshadow-cljs watch browser and do some front-end coding, with live reload. Then I close the watch process and want to run a releasenpm run release, but since the dev-server is in the background i end up restarting it whenever i do releases. possibly because i just haven’t developed the habit of using a repl for that bitshadow-cljs watch browser vs. shadow-cljs clj-run my-build-ns.core/watch, wherein I do some cleanup and then run (shadow.cljs.devtools.api/watch <build-id>) ?watch stops the build when connected to the server an you CTRL+Cclj-run probably doesn't:watch-start :release etc eventsclj-runshadow-cljs clj-run my.build.ns/before-watch; shadow-cljs watch browser;shadow-cljs start; shadow-cljs clj-run my.build.ns/before-watch; shadow-cljs watch browser;start starts a background server if none is running:npm-deps?:npm-deps doesn't handleSHADOW import error /projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js
/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539
throw new TypeError('Line must be greater than or equal to 1, got '
^
TypeError: Line must be greater than or equal to 1, got null
I'm not sure if I'm doing anything wrong, because I have very limited experience with nodejs.$ /projects/funnels-cljs$ node out/funnels-cljs/server.js
SHADOW import error /projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js
/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539
throw new TypeError('Line must be greater than or equal to 1, got '
^
TypeError: Line must be greater than or equal to 1, got null
at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539:13)
at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:604:22)
at mapSourcePosition (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:199:42)
at wrapCallSite (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:343:20)
at /projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:378:26
at Array.map (<anonymous>)
at Function.prepareStackTrace (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:377:24)
at process.emit (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:431:52)
at process._fatalException (bootstrap_node.js:386:26)
lineCount property from source maps, looks like I forgot to do that somewhere/projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js.map probably has "lineCount":null which it shouldn’tError: Cannot find module 'simple-encryptor'Cannot find module 'multiparty'Cannot find module 'cookies':compiler-options {:source-map false} in the build configsource-map-support package for node is just one piece of horrible ugly code{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cbb8a3aaafa4bce6a8a7a1b88bf9e5fbe5faf8f8"}, :content ("[email protected]")} again, was using incorrect offsets so source maps got confused.target/ and node_modules/ then reinstalling...stale websocket client, please reload client :browser means that the client has JS that was not generated by the current workerwatch:repositories
{"" {:url ""
:username "xxx"
:password "yyy"}}
lein to manage the classpath. you just specify :lein true in shadow-cljs.edn and setup your :dependencies and :source-paths via lein. everything will be executed via lein so :repositories should work. https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integrationshadow-cljs should also support :repositories but I never tested it so I can’t verify it actually works. try to just specify it at the top level in shadow-cljs.edn. you can use :username #shadow/env "DATOMIC_USERNAME" if you prefer to keep the username/password out of shadow-cljs.edn and use env variables instead.lein or boot so it may just work. https://github.com/cemerick/pomegranatedatomic has cljs support? Otherwise should not be required if you just want to build cljs?watch from the REPL? (shadow.cljs.devtools.api/watch :build) does not block the REPL.SHADOW import error /home/asp/projects/logview/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.cookies.js Error: Cannot find module 'cookies'
target, but put the final entry point in resources? in prod, we only use a single js in resources. in dev, we do what i just said, and serve target/js at /js in dev time. i’ve got shadow working, but because it puts stuff in resources, it now complains that it’s finding sources twice.:output-to "resources/app/js/app.js"
:output-dir "target/js/out"
:asset-path "/js/out"
(shadow/start!) call showing shadow-cljs - server running at in my repl.
but, when i shadow-cljs watch, i get: ClassNotFoundException shadow.cljs.devtools.cli. what have i forgotten?shadow-cljs - connected to server message:lein {:profile "+dev"}, :http-handler can’t find my dev profile http handler namespace.package.json. libaries can publish a deps.cljs with :npm-deps {"thing" "version"} which shadow-cljs will transfer over to package.json. unfortunately most libaries do not yet do this.shadow.cljs.devtools.cli where you require shadow.cljs.devtools.server.Error: Cannot find module 'cookies' means you need npm install cookies(shadow.cljs.devtools.server/start!) somewhere to start the embedded server instance:watch-dir which should point to the document root of your webserver.(shadow.cljs.devtools.api/compile :build) is the same as calling shadow-cljs compile buildimmutant.web.async, given that you use undertow for the webserver?(defn start-cljs-repl [] (shadow-server/start!) (shadow/watch :app) (shadow/watch :test) (shadow/watch :devcards) (shadow/nrepl-select :app))
draft-js was among the packages I tested when writing the npm integration. I might be able to help if you have questions.app build:repl/quit exits back to the normal CLJ nrepl<output-dir>/cljs-runtime directorycljs-runtime dir so you can ignore that for any release:npm-deps via deps.cljs yes, you have to do npm install{:draft-js "0.10.4"
:draft-js-export-html "1.2.0"
:immutable "3.7.4"
:react "15.6.2"
:react-dom "15.6.2"}
shadow-server is the shadow.cljs.devtools.server ns. shadow is shadow.cljs.devtools.api(require '[shadow.cljs.devtools.server :as shadow]
'[shadow.cljs.devtools.api :as shadow-api])
(shadow/start!)
(shadow-api/watch :app)
watch is only in shadow.cljs.devtools.api not the server nsshadow.cljs.devtools.server.nrepl/cljs-select needs to be in your nrepl middlewarecider-connect to. It does all the complicated setup so you don’t have to.shadow-cljsjs project that provide replacements for cljsjs. but the react version is likely use the dev version?watch and compile will use the dev version, release will use the release versionrelease will use the correct thing{:resolve {"react" {:target :npm :require "react/cjs/react.production.min.js"}}} (for react v16):repl-options {:init-ns user
:nrepl-middleware [;; provided by fake-piggieback, only because tools expect piggieback
cemerick.piggieback/wrap-cljs-repl
;; cljs support
shadow.cljs.devtools.server.nrepl/cljs-load-file
shadow.cljs.devtools.server.nrepl/cljs-eval
shadow.cljs.devtools.server.nrepl/cljs-select]}}}
:resource-paths).js files in .jar. instead serve them directly from a directory if possible. otherwise you’ll need to restart the JVM process every time you want to update the .js.$ lein with-profile +cljs run -m shadow.cljs.devtools.cli => exception in thread "main" java.lang.UnsupportedClassVersionError: shadow/build/closure/ErrorCollector has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0, compiling:(shadow/build/classpath.clj:1:1)ideas?
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b1c2d9d0d5dec69cd2dddbc2f1839f819f808287"}, :content ("[email protected]")} which has class file version 52 again. (actually fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "71021910151e065c121d1b0231435f415f404246"}, :content ("[email protected]")}, sorry about that)ns with (:require ["a-string" ...]) as clojure code instead of cljs?shadow-cljs watch the-build or via the REPL itself (shadow.cljs.devtools.api/watch :the-build)(shadow.cljs.devtools.api/nrepl-select :the-build)shadow-cljs has a server mode which will start the nrepl servershadow-cljs watch the-buildshadow-cljs server or shadow-cljs start(shadow.cljs.devtools.api/nrepl-select :the-build) would be enough then(js/alert "foo")shadow-cljs node-repl and (nrepl-select :node-repl):websocket-url to <wss://example.com/figwheel>, and the proxy sends that URL to figwheel. This way I don't need to make random ports public and can control access in one spot. I'd like to do the same with shadow-cljs:websocket-url "" and forward /shadow-cljs/* to host:9630 that should be fine{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfccd7dedbd0c892dcd3d5ccff8d918f918e8c87"}, :content ("[email protected]")} lets you configure :devtools-url "". must be http or https, it will use ws where approriate./* is forwarded to the actual shadow-cljs instance that should work:builds {:build {:devtools {:devtools-url ...}}}} that isCompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((:require [rum.core :as rum] ["d3" :as d3])) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses), Extra input
#:clojure.spec.alpha{:problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [rum.core :as rum] ["d3" :as d3])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x1f563fb3 ""d3"DEVTOOLS: REPL init successful 🙂:npm-module target (https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module), is it possible to somehow embed a REPL server into that outputted JS file? I'm trying to embed it into a create-react-app application, and then connect to it from CIDER 🤔shadow.cljs.devtools.client.node ns somehow:npm-module doesn’t have clearly defined entriesrequire("shadow-cljs/shadow.cljs.devtools.client.node") should do it if you are using the default :output-dirindex.jsimport which can’t be conditionalrequire in the usual process.env.NODE_ENV check:output-dir to node_modules/shadow-cljsrequireindex.js to requirerequire("shadow-cljs/shadow.cljs.devtools.client.node") to App.js?node thing. require("shadow-cljs/shadow.cljs.devtools.client.browser");:runtime to :browserMay 21, 2017 … lots has changed since thenshadow.cljs.devtools.client.browser loaded, how would I start a REPL client? Something like: shadow-cljs cljs-repl?[3:1]~cljs.user=> (js/alert "test") There is no connected JS runtime.
shadow-cljs cljs-repl dev (my build id is "dev")shadow.cljs.devtools.client.browser in index.js, is there any function I need to call to actually "start" it? Or is the act of requiring it enough?:npm-module works ok but the REPL is never going to be reliable anyways given the amount of stuff webpack does to the code:npm-module was supposed to achieve, which it sorta does until you launch a REPL 😉(js/alert "foo") 😉(.field js/thing) can be broken so easily. How do other tools do it? So my interest in (1) the practical, which so far has been: use cljs-oops for all external accesses and (2) learn about different approaches people are taking. It seems like you are doing something different in shadow to make interop safer (?). At any rate I just have a general technical curiosity here. No specific burning need.cljs-oops at all. shadow-cljs has greatly improved externs inference support which has elimitated the need for almost every extern I used before:infer-externs :auto these days(.field js/thing) are fully inferredWe only need externs for the code we actually call from CLJS, not everything the JS code uses. That suggests that over-specifying externs keeps code in that might otherwise be elided. Does GCC do DCE on npm modules? I thought the whole idea is that the compiler won’t do advanced optimizations on npm modules and the externs are a directive to the compiler not to name mangle those symbols in optimized code.:simple for everything on node_modules.:advancedns and suchcreateThing defined somewhere in the externscreateThing will never be shortened or removed, even if it could be otherwise:simple optimizations i was think that createThing couldn’t ever be renamed or removed anywaynode_modules:advanced optimized so it could be removed there (in case it exists):advanced at some point(ns demo.app) (defn foo [])demo.app.foo = function() {} basicallydemo$app$foo so it can remove the nested objectsxA (or removes it entirely):simple:advanced:js-provider :closure and see if you code still works. that does :advanced for everything. if it doesn’t go back to :shadow.node_modules so I’m doing that:infer-externs :auto and let the compiler tell you if it doesn’t unterstand something^js typehint or cljs-oops as the fix is up to you:infer-externs :auto with occasional ^js typehints works really well. I use a lot of JS libs, and it’s become extremely rare to hit a problem. JS interop with :advanced compilation used to be my #1 complaint with writing real-world clojurescript — frequent, painful, manual hunting of obscure bugs, interrupted by multiple-minute recompile times — and that whole experience is just gone now. I see an immediate warning whenever something should be hinted, I add a ^js somewhere, and just keep coding.:builds {:app {:js-options {:resolve {"libcsound" {:target :file
:file "resources/libcsound.js"}}}
(:require ["libcsound"]))
The required JS dependency "libcsound" is not available, it was required by "csound_wasm/core.cljs"Something I'm not doing right, tried :target :npm and :require instead of :file. Same error.
:target?:resolve currently only works when using :shadow as js provider (eg. for :browser):node-library just directly delegates to node require so we can't influence what that does directly(:require ["./libcsound" :as x]) with the file just next to the .cljs filejs/require works fine 🙂js/require might be the safest optionnpm install cookiescuerdas library needed, but other than that I’ve been able to run it just fine. just working on hot loading:after-load, it complained that a server was still running on the port(defstate ^{:on-reload :noop} ....) should do what you want:before-load and :after-load callbacks just set :autoload trueroutes.cljs when I set :autoload true(def routes
["/" {:get home}]server.core keeps a reference to the router. :handler (wrap-defaults router) this won’t be reloaded.(mount/in-cljc-mode)^:figwheel-always seems to be used to force reload the .app ns always:autoload true in the build config. that still needs to be in :devtools {:autoload true}:js-options {:js-provider :closure} and see if your build still works:shadow 😉npx shadow-cljs start shouldn’t need the background option. it will exit when the server has finished starting. at least in theory.background will just run the process itself in the backgroundnode process that starts the process itself will exit anywaysbackground with npx shadow-cljs server that works? (instead of start)shadow-cljs clj-run maria.build/release.. i don’t see any real reason why i should have to run these commands separatelytarget/shadow-cljs has some clues?npx shadow-cljs release live trusted bootstrap wow, very nice site! I have handful of people I could recommend this to 🙂 @mhuebertpwd; ls; cd editor; npm install; npm run release; command[:bootstrap] Compiling ... -> Converting 31 JS sources <- Converting 31 JS sources (3215 ms) -> JS Cache write: 31 JS files <- JS Cache write: 31 JS files (70 ms) -> Compile CLJS: cljs/core.cljs <- Compile CLJS: cljs/core.cljs (15735 ms)
npx shadow-cljs start into a command (without background: true), then ran subsequent builds - https://circleci.com/gh/mhuebert/maria/325
the build after shadow-cljs start:
#!/bin/bash -eo pipefail cd editor; npm run release; > @ release /root/project/editor > rm -rf public/js/bootstrap; shadow-cljs clj-run maria.build/release; shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139 shadow-cljs - connected to server shadow-cljs - socket connect failed, server process dead?
background try server instead of start so circleci can take back of backgrounding the processnpx shadow-cljs release bootstrap and the other 2 builds after each other without the server?cat target/shadow-cljs/shadow-cljs.log.0 just in caseThe background attribute allows for executing commands in the background. In this case, job execution will immediately proceed to the next step rather than waiting for the command to return.v1-dependencies-{{ checksum "editor/package.json" }}--{{ checksum "editor/shadow-cljs.edn"}} would be sufficientstart is supposed to solve that.cljc files, and it works with both server- and client-rendered libs. In one particular form field, :phone_number, the input’s name attribute is set to phone_number in development mode (watch), but after doing a shadow-cljs release, that field becomes phone-number. Other underscored field names seem to be unaffected.start again and got the same,
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139 shadow-cljs - connected to server shadow-cljs - socket connect failed, server process dead? deleted pid file, please retry command to start new server Exited with code 1
shadow-cljs release keywords are optimizednew cljs.core.Keyword(null, "phone_number", hash, meta) calls with cljs$cst$kw$phone_number variables:phone-number be different than :phone_number?:phone_number AND :phone-number in your code the normalized JS variable name replace each other- is just replaced by _ blindlynpm install shadow-cljs there{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f7849f96939880da949b9d84b7c5d9c7d9c6c3c7"}, :content ("[email protected]")}#!/bin/bash -eo pipefail cat target/shadow-cljs/shadow-cljs.log.0 cat: target/shadow-cljs/shadow-cljs.log.0: No such file or directory Exited with code 1
- run:
command: cat target/shadow-cljs/shadow-cljs.log.0 2> /dev/null
working_directory: ~/project/editor
when: on_fail
:source-paths and keep it in :dependencies. or you use the lein integrationlein does not always put checkouts paths on the classpath. I think the version of your :dependencies of the lib has to match the actual version of the lib. check if lein classpath lists the path correctly. should be before the actual .jar.shadow.markup.react?tools.deps integration today{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6f1c070e0b0018420c03051c2f5d415f415e5b5c"}, :content ("[email protected]")} has experimental support for deps.edn. requires a very recent version and still has a couple problems but sort of works.:deps {:aliases [:test :foo]} to shadow-cljs.edn if you want to try[2018-01-24 13:55:44 - WARNING] TCP Port 9630 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9631 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9632 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9633 in use.
[2018-01-24 13:55:53 - WARNING] :shadow.cljs.devtools.server.dev-http/start-error resources/public 8700 #error {
:cause Address already in use
:via
[{:type java.lang.RuntimeException
:message java.net.BindException: Address already in use
:at [io.undertow.Undertow start Undertow.java 214]}
{:type java.net.BindException
:message Address already in use
:at [ bind0 Net.java -2]}]
main processes seemed to work> shadow-cljs start; shadow-cljs clj-run web3.build.build/reset-asset-paths;shadow-cljs watch browser; shadow-cljs - config: /Users/MattPro/Documents/sites2017/web3/shadow-cljs.edn version: 2.0.142 shadow-cljs - server starting ..................................................................................... ready! shadow-cljs - config: /Users/MattPro/Documents/sites2017/web3/shadow-cljs.edn version: 2.0.142 shadow-cljs - connected to server shadow-cljs - socket connect failed, server process dead? deleted pid file, please retry command to start new server
shadow-cljs start; shadow-cljs clj-run _SOMETHING_; shadow-cljs watch browser seems to be problematic; messes with the backgrounding of the process somehow$ shadow-cljs start; shadow-cljs clj-run test.foo/bar; shadow-cljs watch npm shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143 shadow-cljs - server starting ........................................... ready! shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143 shadow-cljs - connected to server :bar shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143 shadow-cljs - connected to server shadow-cljs - watching build :npm [:npm] Configuring build. [:npm] Compiling ...
curl fixes it and why that says App not ready. start should only return once the cli-repl.port exists which is written AFTER all the servers were started.sleep 1 after start. I give up figuring out why this is required.shadow-cljs watch build in IntelliJ Terminal (or from REPL) in that place instead you’d get warnings there.target/shadow-cljs directory so you keep starting new instances since the old port info is gone. do you run lein clean or similar things by any chance?npx shadow-cljs start; npx shadow-cljs stop; => always adds a new process, doesn’t kill the last oneserver.pid is always reflecting the last process id createdctrl-c, but the process.id file and process itself remain&&’s, and (2) added a sleep 2 after shadow-cljs start (one second didn’t seem to be enough)java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
$ npx shadow-cljs start; npx shadow-cljs stop; shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143 shadow-cljs - server starting ........................................... ready! shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
npx shadow-cljs server standalone and if killing it with CTRL+C leaves the orphan java process?mattpro:editor MattPro$ npx shadow-cljs server shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144 shadow-cljs - starting ... WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean? WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean? [2018-01-28 11:32:41 - WARNING] TCP Port 9630 in use. BindException: Address already in use java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:382) java.net.ServerSocket.bind (ServerSocket.java:375) java.net.ServerSocket.bind (ServerSocket.java:329) clojure.tools.nrepl.server/start-server (server.clj:149) clojure.tools.nrepl.server/start-server (server.clj:121) shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278) shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)
main processes so maybe i’m just not seeing themjava processes when i run the command from mariamain when i run from my other projectjavamain would be?main (or the first process ends and another one called main starts, however that works)ps ax for that process look like?PID TT STAT TIME COMMAND 77080 ?? Ss 1:20.61 /usr/bin/java -Djava.util.logging.config.file=target
main?npx shadow-cljs server that is called main as well?java, around the time it’s finished loading the name changes to mainmattpro:editor MattPro$ npx shadow-cljs start; npx shadow-cljs clj-run '(+ 1 1);' shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144 shadow-cljs - server starting ..................................................... ready! shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144 shadow-cljs - connected to server shadow-cljs - socket connect failed, server process dead?
rm -rf target/shadow-cljs before running thatls -ahl target/shadow-cljs after?npx shadow-cljs start; npx shadow-cljs clj-eval '(+ 1 1)' shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144 shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.pom from Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.jar from shadow-cljs - dependencies updated shadow-cljs - server starting ........................................ ready! shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144 shadow-cljs - connected to server 2
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0e7c61617a4e6c3a6c3d3d683837383b393c"}, :content ("[email protected]")}target/shadow-cljs contents?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fc8e939388bc9ec89ecfcf9acac5cac9cbce"}, :content ("[email protected]")}server.stderr.log or server.stdout.log?curl ?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "35475a5a4175570157060653030c03000207"}, :content ("[email protected]")}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e5978a8a91a587d187d6d683d3dcd3d0d2d7"}, :content ("[email protected]")}npx shadow-cljs clj-eval '(+ 1 2)' probably works now{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "13617c7c6753712771202075252a25262421"}, :content ("[email protected]")}shadow-cljs - socket connect failed, server process dead? deleted pid file, please retry command to start new server
start and then wait-for-server.sh which could probably just be sleep 1rm -rf target
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "03716c6c7743613761303065353a35363431"}, :content ("[email protected]")}.log files say?[2018-01-28 11:01:13 - WARNING] TCP Port 9630 in use. BindException: Address already in use (Bind failed) java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) java.net.ServerSocket.bind (ServerSocket.java:375) java.net.ServerSocket.bind (ServerSocket.java:329) clojure.tools.nrepl.server/start-server (server.clj:149) clojure.tools.nrepl.server/start-server (server.clj:121) shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278) shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)but instead of throwing that error it keeps trying to start
shadow-cljs - server starting ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
sleep command in between start & the command would be a fix for all of this, but my colleague (on mac os) still got that same error even with shadow-cljs start && sleep 2 && shadow-cljs clj-run ...&& don't work can you try multiple commands like in my circle config?server or start entirelytarget/shadow-cljs entirely, kill all java processesnpx shadow-cljs start alonenpx shadow-cljs clj-eval :foonpx shadow-cljs stop?target/shadow-cljs, kill all javanpx shadow-cljs start && npx shadow-cljs clj-eval :foomattpro:editor MattPro$ npx shadow-cljs start && npx shadow-cljs clj-eval :foo shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - server starting ................................................... ready! shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144 shadow-cljs - connected to server shadow-cljs - socket connect failed, server process dead?
npx shadow-cljs clj-eval :foo alone works?npx shadow-cljs stop.sleep 1 works for me now, but that is the same command that didn’t work for my colleagueshadow-cljs start and clj-eval as two separate commands (no sleep) and getting an error{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d7a4bfb6b3b8a0fab4bbbda497e5f9e7f9e6e3e2"}, :content ("[email protected]")} should hopefully fix thisThe required namespace "cljsjs.semantic-ui-react" is not available, it was required by "soda_ash/core.cljs".cider-connect and cider-connect-clojurescript. Specifically I'm trying to connect to node-repl.(shadow.cljs.devtools.api/nrepl-select :node-repl) node-repl is a node repl and the id of the build 🙂.js files that you are including via js/require.js file to npm:npm-deps for the libpackage.json to declare :source-paths for a libshadow.dom is in <root>/shadow/dom.cljsnode_modules/some-package/src as that pathpackage.json "clojurescript":{"source-paths": ["src"]} or something and that would work easilyreact-virtualized/dist/commonjs/AutoSizerreact-virtualized/AutoSizer at some point#ccc or #ddd0.0.0.0, so when the JS runtime tries to connect to the shadow-cljs server, it blocks the connections127.0.0.1 or localhost?:http {:host "localhost"} in shadow-cljs.edn:card/keys in favor of just :keys compilesclj
Clojure 1.9.0
user=> (fn [{:card/keys [:slug :title :can-edit? :can-complete?]}])
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/fn did not conform to spec:(fn [{:card/keys [slug title can-edit? can-complete?]}]) this worksyarn install then shadow-cljs watch appclj-run some.ns/fn which outputs to stdout I wanted to be able to capture that without any log outputyarn.lock files from the examples since they locked in older version of shadow-cljs. so everything should be using the most recent version now without me having to update it.child_process.spawnSync and don't handle any signalsspawn and do everything async with manual signal handlingspawnSync to do the correct thingmanager.cljs 😉spawnSync.exec is the same as spawn I think(.exec cp command (clj->js {:cwd cwd})) you can do (cp/exec command #js {:cwd cwd})cp = require 'child_process' ret = cp.spawnSync 'sleep', ['100'] console.log ret
#js {:cwd cwd} since my code is not written in Clojure directly...Error: kill ESRCH
at Object._errnoException (util.js:1003:13)
at process.kill (internal/process.js:173:18)
(comment .kill proc)
(.kill js/process (- 0 pid) "SIGKILL")
use of undeclared Var warnings------ WARNING #17 ------------------------------------------------------------- File: /Users/jorge/lunar/src/lunar/ui/catalog/views.cljs:119:69 Use of undeclared Var lunar.ui.catalog.views/c --------------------------------------------------------------------------------
c would be the var from the for-indexed snippet abovei and c are set within the argument vector of the mapping function for map-indexeduser=> (for-indexed [i c [{:card/id 1} {:card/id 2}]] [:li {:class "card" :key i} (:card/id c)])
([:li {:class "card", :key 0} 1] [:li {:class "card", :key 1} 2]:require-macros in the ns formshadow/nrepl-select and a remote repl instead?:repl/quit to exit the annoying popups btwlein replshadow-cljs watch app in the terminal (intellij terminal works great)clojure.main doesn't have all the features but everything I need 😉:lein true will checkouts just work?:lein true the usual lein checkouts work yes. you can also just add the :source-paths to the other repo(shadow.cljs.devtools.api/release-snapshot :app {}).
the file bundle-info.edn is created but unfortunately it is ill-formed. for example, it contains the string ... to abbreviate the contents of the vector under :build-sources. it looks like this edn file is created by some pretty printer that is meant for the repl.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c7b4afa6a3a8b0eaa4abadb487f5e9f7e9f6f2f7"}, :content ("[email protected]")} which doesnt pprint anymore2.0.150 the edn file is no longer pretty printed but still elidedshadow-cljs clj-eval "(shadow.cljs.devtools.api/release-snapshot :app {})" should work but no offical API for that yet*print-length* https://clojuredocs.org/clojure.core/*print-length*release or any other call would also be elided(binding [*print-length* false] (shadow.cljs.devtools.api/release-snapshot :app {}))shadow-cljs, but I'm getting this error:[:gql-contacts] Configuring build. [:gql-contacts] Compiling ... [:gql-contacts] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/wilkerlucio/.m2/repository/thheller/shadow-cljs/2.0.150/shadow-cljs-2.0.150.jar!/shadow/cljs/devtools/client/hud.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.cljs.devtools.client.hud -------^------------------------------------------------------------------------ Invalid :refer, var cljs.core.async/go does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [shadow.dom :as dom] 4 | [shadow.xhr :as xhr] 5 | [shadow.animate :as anim] --------------------------------------------------------------------------------
core-asyncreact-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.jscljsjs/react version. either exclude it or bump to a newer versionshadow-cljsjs has nothing to do with thatcljsjs/react package itselfdeps.cljs files so "errors" in those files go unnoticed easily[reagent "0.7.0" :exclusions [cljsjs/react cljsjs/react-dom]] since we are not going to use them anywaysfailed to start service
{:id :classpath}
ExceptionInfo: failed to start service
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.runtime.services/start-many/fn--15833 (services.clj:135)
shadow.runtime.services/start-many (services.clj:126)
shadow.runtime.services/start-many (services.clj:105)
shadow.runtime.services/start-all (services.clj:144)
shadow.runtime.services/start-all (services.clj:139)
shadow.cljs.devtools.server/start-system (server.clj:191)
Caused by:
/home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.js
{:tag :shadow.build.classpath/deps-cljs, :source-path #object[java.io.File 0x64c82a3b "/home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar"], :name "cljsjs/react/development/react.inc.js"}
ExceptionInfo: /home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.js
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.classpath/process-deps-cljs/get-index-rc--17183 (classpath.clj:252)
shadow.build.classpath/process-deps-cljs/fn--17187 (classpath.clj:265)
clojure.core/map-indexed/mapi--8189/fn--8190 (core.clj:7228)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.RT.seq (RT.java:528)
[cljsjs/react "15.6.2-4"] do your dependencies so you don't have to exclude it for everything2.1.1. thanks for the report. "shadow-cljs": "^0.18.0" hehe cute 😛[day8.re-frame/trace "0.1.18-react16"] to my project, shadow-cljs watch app complains
Build failure: The required namespace "cljsjs.react-flip-move" is not available, it was required by "day8/re_frame/trace/utils/animated.cljs".then I added
[cljsjs/react-flip-move "2.9.17-0"] to shadow-cljs.edn, still same complains.react-flip-move uses cljsjs?[cljsjs/react-flip-move "2.9.17-0"] from shadow-cljs.edn and add react-flip-move to package.json and create react_flip_move.cljs in cljsjs/ and it works.(ns cljsjs.react-flip-move
(:require cljsjs.react
cljsjs.react.dom
["react-flip-move" :as flip-move]))
(js/goog.exportSymbol "FlipMove" flip-move)npm install react-flip-move should do itnpm integration is completely custom and none of the official code for that is used (since its too broken). so the npm/js integration is the biggest difference. a few minor tweaks to the compiler here or there.shadow-build about a year before it landed in CLJS itself:modules support in CLJSshadow.loader existed about a year before cljs.loader ...cljs.loader unfortunately has some unsolvable issues which is why I don't recommend using itserver {
server_name ;
location / {
deny all;
}
rewrite ^/(.*)$ permanent;
}
, he/she will be redirected to UserGuide.(:require ["material-ui/Card" :default Card :refer (CardHeader)]) and such"material-ui" and picking apart that object(:require ["material-ui/es/Card" ...]) should also work(:require ["material-ui" ...]). should save a ton of bytes unless you are actually using everything:npm-deps functionality in CLJS (since it doesn't work)lein setup already you can do it via https://shadow-cljs.github.io/docs/UsersGuide.html#embeddedlein :aliases {"build-uberjar" ["do" ["run" "-m" "shadow.cljs.devtools.cli" "release" "your-build"] "uberjar"]}bash or make or anything really shadow-cljs release your-build && lein uberjarshadow-cljs watch the-build then in vim :Connect and :Piggieback :the-build?cider-nrepl on the classpath? not sure if the vim stuff uses thatreact-with-addons for testing and plain react for prod.:preloads:node-test target. See https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test["material-ui/Button/Button" :default Button] ["material-ui/IconButton" :default IconButton] ["material-ui/Progress/LinearProgress" :default LinearProgress] ["material-ui/Radio/Radio" :default Radio] ["material-ui/Radio" :refer [RadioGroup]] ["material-ui/Form" :refer [FormLabel FormControl FormControlLabel FormHelperText]] ["material-ui/Switch" :default Switch] ["material-ui/Dialog" :default Dialog] ["material-ui/AppBar/AppBar" :default AppBar] ["material-ui/Toolbar" :default Toolbar] ["material-ui-icons/Menu" :default MenuIcon] ["material-ui-icons/Close" :default CloseIcon] ["material-ui-icons/MoreVert" :default MoreVertIcon] ["material-ui-icons/ExpandMore" :default ExpandMoreIcon] ["material-ui-icons/ExpandLess" :default ExpandLessIcon] ["material-ui/Menu" :default Menu :refer [MenuItem]] ["material-ui/Typography" :default Typography] ["material-ui/Card/Card" :default Card] ["material-ui/Avatar" :default Avatar] ["material-ui/Card" :refer [CardHeader CardMedia CardContent CardActions]] ["material-ui/Paper" :default Paper] ["material-ui/transitions/Collapse" :default Collapse] ["material-ui/TextField" :default TextField] ["material-ui/Drawer/Drawer" :default Drawer] ["material-ui/List/List" :default List] ["material-ui/List" :refer [ListItem ListItemIcon ListItemText]] ["material-ui/Divider" :default Divider] ["material-ui/ExpansionPanel/ExpansionPanel" :default ExpansionPanel] ["material-ui/ExpansionPanel" :refer [ExpansionPanelDetails ExpansionPanelSummary]]Using the components is then simple, just use the special
:> operator reagent provides, for example [:> Card {} ]:> seems very interesting, I have been using reagent for a long time and I have never heard of it. Can you point me to some docs?:simple mode (which is used for npm deps) is also pretty good though, so thats part of it too.The required namespace "beicon.impl.rxjs" is not available, it was required by "beicon/core.cljc". I skimmed last couple of days and found some similar stuff but somehow I can't get my head around it. The problem I guess is that beicon is using https://github.com/funcool/beicon/blob/master/assets/deps.cljs and it is not compatible with shadow-cljs.npm install rxjs(ns beicon.impl.rxjs (:require ["rxjs/Rx" :as rx])) (js/goog.exportSymbol "Rx" rx)
ReferenceError: [BABEL] shadow$empty.js: Unknown option: /home/mitchel/Development/atlas-crm-next/node_modules/react/react.js.Children. Check out for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
------ WARNING #1 --------------------------------------------------------------
File: /Users/wilkerlucio/Development/pathom/src/com/wsscode/pathom/core.cljc:70:1
--------------------------------------------------------------------------------
67 | (gen/call-gen g rdn size))
68 | (gen/call-gen (gen/return []) rdn size)))))))
69 |
70 | (s/def ::mutation-expr
-------^------------------------------------------------------------------------
No such namespace: operation.on, could not locate operation/on.cljs, operation/on.cljc, or JavaScript source providing "operation.on"
--------------------------------------------------------------------------------
71 | (s/with-gen
72 | (s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
73 | #(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
74 | val (s/gen ::params)]
--------------------------------------------------------------------------------operation.on? my doesn't mention that at all:require-macros thing again .. this is really beginning to bother me.test.check or do you have any macros involved in this?test.check and spec, these are my requires:(ns com.wsscode.pathom.core
(:refer-clojure :exclude [ident?])
(:require
[clojure.spec.alpha :as s]
[clojure.set :as set]
[clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.walk :as walk]
[fulcro.client.primitives :as fp]
#?(:cljs [goog.object :as gobj]))
#?(:clj
(:import (clojure.lang IAtom IDeref)))):include-macros on all of then, but no effect:require-macros for itself in .cljc files with macrosgen/let macro is not handled properly internally I assume (s/gen '#{do-something create/this-thing operation.on/space}) is in your code?[clojure.test.check.generators :as gen :include-macros true] this seems to work?(s/def ::mutation-expr
(s/with-gen
(s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
#(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
val (s/gen ::params)]
(list key val))))(do ;; s/def ::mutation-expr
(s/with-gen
(s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
#(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
val (s/gen ::params)]
(list key val))))(def sample-mutations '#{do-something create/this-thing operation.on/space})
(s/def ::mutation-expr
(s/with-gen
(s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
#(gen/let [key (s/gen sample-mutations)
val (s/gen ::params)]
(list key val))))clj build.clj WARNING: No such namespace: operation.on, could not locate operation/on.cljs, operation/on.cljc, or JavaScript source providing "operation.on" at line 9 src/test/foo.cljs WARNING: No such namespace: create, could not locate create.cljs, create.cljc, or JavaScript source providing "create" at line 9 src/test/foo.cljs
(def ^:extern some-thing)^:export: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/git checkout -b shadow so i’ll let you know in a few hours how it goes 😛npm install react-dnd and (:require ["react-dnd" :as dnd]) let me know 😉:npm-module does what you asked. processes CLJS with closure but lets you do the final packaging with webpack or others. I still consider the Closure Compiler to be the most advanced JavaScript tool out there so there are no other options for me.shadow-cljs clj-run your.tool/build-deps-cljs ... to execute it. similary lein run -m your.tool/build-deps-cljs ... but I get a shawdow-cljs generated webpage that has a link to Release Snapshots instead of my index.html:http-handler {:http-handler shadow.http.push-state/handle}) gave me this error ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named. now my program is broken in some other way but it does appear to be loading.main! a convention for the entry point? i just followed your medium article and changed my code to use that symbol. in the lein template i had been using, it needed an init! symbol:http-handler shadow.http.push-state/handle not nested in itself 😛init/start/stop setup in my template.init from HTML, which calls start. live reload calls stop :before-load, then start :after-load:http-handler gets a reasonable error. keep the feedback coming if you run into anything. it helps a lot.:js-options {:resolve {"react" {:target :npm
:require "react/dist/react.js"}}}}}}}
but it doesn’t seem to change anytningshadow-cljs release it will use their correct production js and not minify the dev version. so the warning is the only problem.shadow-cljs watch client server to watch both builds in one process. no need to use separate processes.(:require ["qiniu" :as qiniu]) to import a node library to clojurescript in shadow-cljs. But I got stuck when trying to write javascript
var mac = new qiniu.auth.digest.Mac(key1, key2)in clojurescript. I tried
(def mac (-> (qiniu.auth.digest/Mac access-key secret-key)))but failed. How should I do this?
qiniu/auth.digest.Mac should work:as must always be used as-is. qiniu.auth.digest is not a valid alias(def mac (qiniu/auth.digest.Mac. access-key secret-key)). at the end. that is sugar for new.------ ERROR ------------------------------------------------------------------- File: /Users/chen/repo/memkits/manuscript/src/app/util.cljs:6:11 -------------------------------------------------------------------------------- 3 | 4 | (defn focus-text! [] 5 | (js/requestAnimationFrame 6 | (fn [] (let [element (.querySelector js/document ".text"), .focus element] )))) -----------------^-------------------------------------------------------------- Invalid local name: .focus at line 6 app/util.cljs --------------------------------------------------------------------------------
:as vs :default issue is a bit annoying due to the inconsistencies in JS:npm-module at all?require from JS just worksjs global accessors?create-react-app(:require ["react-dnd"]) stays just like thatrequire("react-dnd") and lets webpack provide itshadow-cljs compile npm (default config included, no extra build config required)require("shadow-cljs/your.ns") and let webpack find it(:require ["react-dnd"]) looks at node_modules/react-dnd/package.json for mainrequire calls or import:foreign-libs mess and NOTHING from that applies to shadow-cljs(:require ["thing" :as x]) and then (js/console.log "x" x).default property you are better off using :default:as is always the safer choice.default$ property but that is just :default again:foreign-libs otherwise would create back to the original npm package:js-options :require.cljsjs.react and use js/React:js-options
{:resolve
{"react-flip-move" {:target :npm :require "react-flip-move/dist/react-flip-move.es"}}}:require "react-flip-move/dist/react-flip-move.es.js"shadow-cljs - failed to load module$node_modules$react_dnd$lib$DragDropContextProvider shadow.js.jsRequire @ shadow.js.js:53 shadow$provide.module$node_modules$react_dnd$lib$index @ index.js:17 shadow.js.jsRequire @ shadow.js.js:51 shadow.js.require @ shadow.js.js:77 (anonymous) @ seekeasy.sidebar.js:10
module$node_modules$react_dnd$lib$DragDropContextProvider is the internal namespace that is generated for the filegoog-define since it works with DCE(dostuff
(if (goog.node-js)
(js/require "some-canvas-alt")
(js/getElementById "canvas")))
I can do a goog.define 🙂goog-define(goog-define target "browser"):compiler-options {:closure-defines {your.ns/target "node"}node_modules/react-dnd/lib/DragDropContextProvider.js in this case(:require ["react-dnd"]) and it works just fine. what exactly do you require?:closure-defines is static at compile time. if you prefer to detect at runtime instead you could use js/process.browserreact-dnd seems painfully hard to use even from the JS side. I would probably never be able to use this without looking at the docs every time.reagent does sometimes just smells like pain:dependencies [[org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.9.946"] [reagent "0.8.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/creat-react-class cljsjs/react-dom-server]] [hiccup "1.0.5"] [secretary "1.2.3"] [cljs-http "0.1.44"] [com.rpl/specter "1.1.0"] [venantius/accountant "0.2.3" :exclusions [org.clojure/tools.reader]] [binaryage/oops "0.5.8"] [org.clojure/test.check "0.9.0"]]and now i’m getting
The required JS dependency "react-flip-move" is not available, it was required by "cljsjs/react_flip_move.cljs"Where is that cljsjs coming from?
cljsjs.react-flip-moveshadow-cljs clj-repl(shadow.cljs.devtools.api/find-resources-using-ns 'cljsjs.react-flip-move)shadow.js.js:53 shadow-cljs - failed to load module$node_modules$create_react_class$index
shadow.js.jsRequire @ shadow.js.js:53
shadow.js.require @ shadow.js.js:77
(anonymous) @ reagent.impl.component.js:3
shadow.js.js:54 Uncaught TypeError: m.Component is not a constructor
at Object.shadow$provide.module$node_modules$create_react_class$index (index.js:23)
at Object.shadow.js.jsRequire (shadow.js.js:51)
at Object.shadow.js.require (shadow.js.js:77)
at reagent.impl.component.js:3reagent is trying to new something thats supposed to be used a functionDragSource setup stuff correctly?(defn thing [] [:div "goodbye world"])
(defn mount-root []
(reagent/render [thing]
(.getElementById js/document "app")))
node_modules directly while the compile is runningcljsjs/react shim. shadow-cljs provides thistarget/shadow-cljs?create-react-class you mean?create-react-app nonpm can install nested versions. so it maybe installed node_modules/thing/node_modules/reactnode_modules/react never the nested versions?yarn thought a thing was installed because it was nestedconsole.clear = function () { throw "who be calling me"; }node_modules folder sometimesdefonce:http-handler shadow.http.push-state/handle:after-load:after-load should just re-mount the root reagent componenttarget/shadow-cljs folder there is a socket-repl.port filecli-repl.port filecli-port is used by the shadow-cljs script itself to communicate with the server:socket-repl {:port 123} can be configuredstdoutwatch for that and a connected clientshadow-cljs cljs-repl your-build and print all stdout somewhereshadow-cljs script does is connect to the cli-repl port(shadow.cljs.devtools.cli/from-remote "some-uuid" "another-uuid" ["cljs-repl" "your-build"])cljs-repl command will read and process itunrepl is newer but not many tools use it (yet). prepl will be something official but nobody knows when this will get adoption. socket-repl still isn't used by anything and thats has been there since 1.7.["cljs-repl" "your-build"]print you don't expect["cljs-repl" "browser"] does nothing but connect me to the REPL in browser..*target* is set to default instead of nodejs (what I would expect) when the build is configured with :target :node-script. Can anyone give me a hind here where I am running into?*target*?cljs.core/*target* I presume. Didn't even know that existed:compiler-options {:closure-defines {cljs.core/*target* "nodejs"}} in your buildnodejs for :node-script and :node-library builds :dependencies [[cider/cider-nrepl "0.16.0"]] to my shadow-cljs.edn file I get SERVER INSTANCE OUT OF DATE! Please restart.
cider-connect to a the repl - but get a message from cider indicating the cider-nrepl version is nil and doesn’t match cider version.(shadow/nrepl-select :cards) - but attempt tos C-c C-e from cljs file - get There is no connected JS runtime.shadow-cljs stop to stop the "out of date" (ie. dependencies were changed) servertarget/shadow-cljs/logging.properties? the warning you see on startup is NOT normal. Also please dont use the from-remote call, it is not part of any public API and may change at any time. Just call (shadow.cljs.devtools.api/repl :build-id) instead.coworkflow has been renamed to calcit-workflow for some weeks.:jvm-opts ["-Xmx521M"] helps a little?(shadow.cljs.devtools.api/repl :build-id) doing the same thing like from-remote?from-remote does stuff you don't need..clj file, from package.json https://github.com/mvc-works/calcit-workflow/blob/master/cli/build/main.cljyarn build as an alias for shadow-cljs run-cljs build.main/build.. the later is quite long.#!shadow-cljs for a while.clj tool, I would try to switch.clj cli/build.clj is shorter.yarn build yarn html is really smooth.cli/build.clj as "script"clj -m build.release is short to type in.alias x="shadow-cljs run-clj"x build.release=>> yarn shadow-cljs clj-repl
yarn run v1.3.2
$ /Users/chen/repo/mvc-works/calcit-workflow/node_modules/.bin/shadow-cljs clj-repl
shadow-cljs - config: /Users/chen/repo/mvc-works/calcit-workflow/shadow-cljs.edn version: 2.1.6
shadow-cljs - starting ...
shadow-cljs - HTTP server for ":browser" available at
shadow-cljs - server running at
shadow-cljs - socket repl running at localhost:5900
shadow-cljs - REPL - see (help), :repl/quit to exit
[1:0]~shadow.user=> (require '[build.main :as b])
nil
[1:0]~shadow.user=> (b/build)
{:exit 0, :out , :err }
[:browser] Compiling ...
shadow-cljs node-repl
shadow-cljs - config: /home/joscha/src/realtime-playground/backend/shadow-cljs.edn version: 2.1.6
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm node-repl
Feb 12, 2018 6:17:05 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Feb 12, 2018 6:17:05 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server running at
shadow-cljs - starting node-repl
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 1 compiled, 0 warnings, 1.96s)
[0:0]~cljs.user=> fs.js:642
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/home/joscha/src/realtime-playground/backend/shadow-cljs/builds/node-repl/dev/out/cljs-runtime/goog.debug.error.js'
at Error (native)
at Object.fs.openSync (fs.js:642:18)
at Object.fs.readFileSync (fs.js:510:33)
at global.SHADOW_IMPORT ([stdin]:44:15)
at [stdin]:3003:1
at [stdin]:3042:3
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at Object.runInThisContext (vm.js:97:38)
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:570:32)
When trying to run the node-repl in my setup I get this error.
My build config is the following:
{:aws-lambda {:id :aws-lambda
:target :node-script
:output-to "target/backend/backend.js"
:main backend.core/main
:optimizations :none
:language-in :ecmascript5}}
What I noticed is that the backend/shadow-cljs/builds/node-repl/dev/out/cljs-runtime/goog.debug.error.js seems to be missing the target dir.
Any hints for me?cat target/shadow-node-repl.js | node and that filename gets lost in the processnode will resolve relative to the process root which is incorrectnode target/shadow-node-repl.js2.1.7. I also upgraded the Closure Compiler version which may break stuff. Please let me know if you run into any issues. I did some testing and all appears to be working correctly but its really hard writing automated tests for this stuff so I may have missed some stuff.2.1.7 also fixes the node-replpdfjs-dist npm module under build/pdf.worker.js. what’s the right way to tell shadow-cljs about that file and that it need to be served during development and copied & minified during production?npm install pdfjs there is no such file?(ns your.app.worker (:require ["pdfjs-dist/lib/core/worker"])) and then let shadow-cljs build it for you(:require ["pdfjs-dist/build/pdf.worker"]) as wellconst PDFJS = window.PDFJS; PDFJS.workerSrc = '/pdf.worker.js';and then I make sure that the
pdf.worker.js bundle is available to be served. so if I just straight require it, won’t that just include the worker source rather than allowing it to be run in a new worker? or is there more shadow-cljs magic here?:web-worker true generates is a standalone worker file, ie. you call it with the webworker constructorClosure compilation failed with 1 errors --- node_modules/dialog-polyfill/dialog-polyfill.js:692 this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
pdfjs.worker.js is that it basically doubles the code your user has to downloadECMASCRIPT_NEXT language mode--- null:-1 Missing externs definition for Symbol. Did you forget to include the ES6 externs?
2.1.8 which seems to fix itns and I don’t think it is extensible in thatway:default is standard clojurescript so it should support that(js/console.clear) to my :before-load hook. I kinda like it.:before-load:referd inmaterial-component-web. Same with 2.1.9js/module$node_modules$$material$ripple$index resolves to the right objectshadow-cljs - updating dependencies shadow-cljs - dependency update failed - Could not find artifact thheller:shadow-cljs:jar:2.1.10 in central () error Command failed with exit code 1.
ripple.MDCRipple.attachTo this is incorrect thoughripple/MDCRipple.attachTo["three" :as THREE]resources/public/js/test/index.html and I want it to be visible for the :browser-test target, is there a way I can tell it to look for index.html in another :resource-paths? Right now it only looks at :http-root. If not, is there a way I can move files, like sift in boot?shadow-target/ output dir, but I’d prefer not to keep any of those file in the git repo, just have it as a temporary target that can be wiped. Is that possible?vega-lite:
(:require ["vega-lite" :refer (compile)])
compile is undefined even though this is synonymous to https://github.com/nesterone/vue-vega/blob/9d7f1b3341471e33b402dc1383266d8570f16cfd/test/unit/specs/components/delegate/vegaLiteDelegate.spec.js
when I type veg into the browser console, this variable autocompletes module$node_modules$vega_lite$build$src$index and module$node_modules$vega_lite$build$src$index.compile exists. Any ideas what might be going on here?index.html or do you want to access that file independently?:http-root is shadow-target/... and my file is resources/.../index.html:test-dir?:test-dir to resources/public/js/testboot setup where resources/* where in git and all the compiled output stuff was in shadow-target/*:test-dir will be a combination of stuff I’ve got in git and stuff generated by shadow.gitignore for now; but this kind of API improvement would be nice 🙂compile does exist yes?["aphrodite" :refer (StyleSheet)], StyleSheet is undefinedObject.defineProperty(exports, '__esModule', {
value: true
});aphrodite which doesn't even make sense when you look at it 😛:advanced stuff Closure does and from what I can tell the JS world is working towards getting something comparable(:require ["npm-module-name" :as something]) is a really nice feature, but I wonder does it make sense to provide an option (maybe in :js-options?) to use a synthetic namespace. i ask because right now the string messes up my linter and deviates from cljs. it’s nice to be able to require the right module name right from the source without a compiler option but in the final estimation not critical. just a thought.(:require [npm-module-name :as something]) actually works as welljava.io.FileNotFoundException: Could not locate seekeasy/handler__init.class or seekeasy/handler.clj on classpath., compiling:(seekeasy/repl.clj:1:1)which i assume must be part of the repl protocol as i don’t have a handler.clj or a repl.clj
[react-flip-move :default FlipMove] then when you actually use FlipMove it will (weirdly) throw an error saying react_flip_move is not definedfailed to parse websocket message {:type :build-failure, :build-config {:target :browser-test, :test-dir "resources/public/js/test", :ns-regexp "-test$", :runner-ns gondola.client.client-test-main, :devtools {:http-port 8022, :http-resource-root "public", :http-root "resources/public/js/test"}, :id :test, :build-id :test}, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs:13:1\n--------------------------------------------------------------------------------\n 10 | ([id] [::address-result id])\n 11 | ([id field] [::address-result id field]))\n 12 | \n 13 | (defsc AddressResult [this {:keys [id]}]\n-------^------------------------------------------------------------------------\nSyntax Error at gondola.client.smartystreets:13\n{:cause clojure.lang.ExceptionInfo: Invalid arity for query {:expected 0, :got 1}}\nExceptionInfo: Syntax Error at gondola.client.smartystreets:13\n\tclojure.core/ex-info (core.clj:4739)\n\tclojure.core/ex-info (core.clj:4739)\n\tfulcro.client.primitives/defsc (primitives.cljc:3203)\n\tfulcro.client.primitives/defsc (primitives.cljc:3142)\n\tclojure.core/apply (core.clj:661)\n\tclojure.core/apply (core.clj:652)\n\tcljs.analyzer/macroexpand-1*/fn--3565 (analyzer.cljc:3286)\n\tcljs.analyzer/macroexpand-1* (analyzer.cljc:3285)\n\n--------------------------------------------------------------------------------\n 14 | {:ident (fn [] (address-result-path id))\n 15 | :query '[*]})\n 16 | \n 17 | (defmutation get-street-address [{:keys [id] :as params}]\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "gondola/client/smartystreets.cljs"] {:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "gondola/client/smartystreets.cljs"], :url #object[java.net.URL 0x71843d1d "file:/Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs"], :file #object[java.io.File 0x1367c8aa "/Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs"], :line 13, :column 1, :source-excerpt {:start-idx 9, :before [" ([id] [::address-result id])" " ([id field] [::address-result id field]))" ""], :line "(defsc AddressResult [this {:keys [id]}]", :after [" {:ident (fn [] (address-result-path id))" " :query '[*]})" "" "(defmutation get-street-address [{:keys [id] :as params}]"]}}}
Error handling response - class java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.CharSequence for expressions like (+ 1 1)clojure.main pointing to a tiny script that starts figwheel, this boots up the compilation and with a REPL ready to use, with shadow I have to do it in 2 steps (open the process in a terminal and connect via nREPL on Cursive)(use 'figwheel-sidecar.repl-api) (start-figwheel! "devcards" "test") (cljs-repl)
(require '[shadow.cljs.devtools.server :as server]) (require '[shadow.cljs.devtools.api :as shadow]) (require '[shadow.cljs.devtools.cli]) (server/start!) (shadow/watch :devcards) (shadow/watch :test)
figwheel.clj instead. change nothing else. done.(cljs-repl) does(shadow/repl :devcards) would drop you into the REPL for devcards(first) on a map), but you can type :cljs/quit, it takes you to a place where you can select which REPL to connectobjc[32799]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java (0x10ce484c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10ced44e0). One of the two will be used. Which one is undefined. Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: es5>= in this context, compiling:(shadow/build/cljs_hacks.cljc:439:22)
(require 'repl) (repl/go)deps.edn does shadow supports deps.edn?clj isn't available on windows{:deps {:aliaes [:foo :bar]}} in shadow-cljs.ednshadow-cljs will then run the jvm via cljFeb 16, 2018 11:48:15 AM clojure.tools.logging$eval27442$fn__27445 invoke INFO: duplicate resource goog/locale/scriptToLanguages.js on classpath, using jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/locale/scriptToLanguages.js over jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170519-fa0499ef/google-closure-library-0.0-20170519-fa0499ef.jar!/goog/locale/scriptToLanguages.js Feb 16, 2018 11:48:15 AM clojure.tools.logging$eval27442$fn__27445 invoke INFO: duplicate resource goog/positioning/anchoredviewportposition.js on classpath, using jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/positioning/anchoredviewportposition.js over jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170519-fa0499ef/google-closure-library-0.0-20170519-fa0499ef.jar!/goog/positioning/anchoredviewportposition.js
[0:0]~cljs.user=> 3
3
[0:0]~cljs.user=> 4
4
[0:0]~cljs.user=> (in-ns 'com.wsscode.pathom.book.graphql.fulcro-network.demos)
Feb 16, 2018 11:51:36 AM clojure.tools.logging$eval27442$fn__27445 invoke
WARNING: client sent unknown msg {:type :repl/set-ns-complete, :id 7, :ns com.wsscode.pathom.book.graphql.fulcro-network.demos}
Timeout while waiting for REPL result.
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> (css/upsert-css "token-demo" RequireTokenApp)
#object[HTMLStyleElement [object HTMLStyleElement]]
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> {:map "with content"}
{:map "with content"}
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> [:book] Compiling ...
[:book] Build completed. (317 files, 2 compiled, 0 warnings, 0.78s)WARNING: client sent unknown msg {:type :repl/set-ns-complete will be gone in next version.Feb 16, 2018 11:58:03 AM clojure.tools.logging$eval27442$fn__27445 invoke
WARNING: client sent unknown msg {:type :repl/require-complete, :id 10}Timeout while waiting for REPL result.[2018-02-16 22:42:59 - WARNING] TCP Port 9630 in use. BindException: Address already in use (Bind failed) java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) java.net.ServerSocket.bind (ServerSocket.java:375) java.net.ServerSocket.<init> (ServerSocket.java:237) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:161) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:153) shadow.cljs.devtools.server/start-system (server.clj:157) shadow.cljs.devtools.server/start-system (server.clj:132) error Command failed with exit code 1. info Visit for documentation about this
shadow.cljs.devtools.server.socket-repl/startshadow-cljs cljs-repl foo instead of connecting to any socket at alltarget/shadow-cljs/socket-repl.port?:socket-repl {:port 0}, it would be fine also.cli-repl.port and connects to that.nrepl-port yes. but that belongs to lein and I don't want to conflict with that.pid files I guessshadow-cljs clj-repl. connect to that from Cursive.(shadow/watch :the-build)?shadow variable is not in REPL by default?shadow-cljs clj-repl process running in a terminalshadow-cljs watch admin it starts the http server for :public as well as :admin. Is it possible to prevent this?compile and releaseshadow-cljs cljs-repl app, I get a timeout trying to switch to a library (and I confirmed that I’m connected to the browser by logging there first) [3:1]~com.rpl.specter=> (js/console.log "***") nil [3:1]~com.rpl.specter=> (in-ns 'com.rpl.specter) Timeout while waiting for REPL result.
(require 'com.rpl.specter) first?shadow-cljs - config: /Users/wilkerlucio/Development/pathom-book/shadow-cljs.edn version: 2.1.13 shadow-cljs - socket connect failed, server process dead?
target/shadow-cljs/cli-repl.port file(defn g [a] (js/console.log :HI a)), I see the error Failed to parse client result: No dispatch macro for: '#'the-ns/g(def h (f/debounce g 1000)) Failed to parse client result: No dispatch macro for: ' => "#'the-ns/h"
shadow-cljs stop fixed the start issue, after that it ran fine:printed-value true:printed-value on the message and just pass the string along2.1.14 on the way? 🙂:printed-value 1 in piggieback .. no trueencoding of result failed TypeError: Cannot convert a Symbol value to a string
at Array.join (native)
at Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 ()
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] ()
at cljs$core$pr_writer ()
at
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] ()
at Object.cljs$core$print_prefix_map [as print_prefix_map] ()
at cljs$core$print_map ()
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] ()
at Object.cljs$core$pr_writer [as pr_writer] () {$$typeof: Symbol(react.element), type: "div", key: null, ref: null, props: {…}, …}
Restarting nREPL fixes it (do not have to restart shadow):code is whatever I sent2.1.15 prints errors and should fix the Boolean issueTo quit, type: :cljs/quitTo quit, type: :repl/quit:cljs/quit and it did the trick?2.1.16 seems to work properly with Cursive nowThe required namespace "goog.i18n.DateTimeSymbols_en" is not available, it was required by "cli/web/services/app/translations.cljs".The ns looks like :
(ns cli.web.services.app.translations (:require [bf.algo.generic :as a]) ;; an internal lib (:import [goog.i18n DateTimeSymbols DateTimeSymbols_en]))
:compiler-options {:closure-defines {goog.LOCALE "en"}} and that will pull in the correct symbolsgoog.i18n.DateTimeSymbolsDateTimeSymbols-en works although its DateTimeSymbols_endeps.edn, but I'm getting this:Wilker-Nu:pathom-book wilkerlucio$ shadow-cljs watch book shadow-cljs - config: /Users/wilkerlucio/Development/pathom-book/shadow-cljs.edn version: 2.1.16 shadow-cljs - starting via "clojure" Invalid option: -Sdeps
-Spath instead?TypeError: Cannot call a class as a function
at b.a (quill.js:1952)
at new b (quill.js:5471)
at b.value (quill.js:5367)
at b.value (quill.js:6617)
at new a (quill.js:1111)
at a.createEditor (mixin.js:13)
at a.componentDidMount (component.js:202)
at a.componentDidMount (factory.js:666)
at commitLifeCycles (react-dom.production.min.js:150)
at c (react-dom.production.min.js:159)
this does not have to be because of shadow-cljs.. going to investiage-Sdeps should be available. maybe you have an older version where its not?shadow-cljs release build --debug to get a more usefull error maybe:default?:default is in a weird situation in some packages because even though they might provide examples as ES6 with default imports:deps {:aliases [:alias ...]}--clj-options -A:more-alias:other:default isn't in CLJS yet so I could definitely change it. problem is that the node/webpack world handles default exports differently than closure-A support["react-quill" :as Quill][:> Quill ...] should be working?module.exports = require('./component'); is what you get with :as QuillQuill property[com.google.javascript/closure-compiler-unshaded "v20180101"] to your deps[com.google.javascript/closure-compiler-unshaded "v20170910"]. so maybe thats the safe option.v20180101 worksv20170910[:> Quill/Quill] you get the same error as before.Quill is the react-quill componentQuill/Quill is basically (:require ["quill" :as Quill])git bisect["react-quill" :as Quill] becomes, differes between the compiler versions.[:> Quill/Quill] and [:> Quill] in newer compiler is exacly the same, but I can look better..Quill/Quill is never the component["react-quill" :as Quill] is also not the component-A:foo now supported in 2.1.172.1.17, trying to compile is generating a lot of those:------ WARNING #1 -------------------------------------------------------------- File: /Users/wilkerlucio/Development/third-part/fulcro/src/main/fulcro/client/primitives.cljc:608:21 -------------------------------------------------------------------------------- 605 | (if-not (nil? x) 606 | #?(:clj (or (instance? fulcro.client.impl.protocols.IReactComponent x) 607 | (satisfies? p/IReactComponent x)) 608 | :cljs (true? (. x -fulcro$isComponent))) ---------------------------^---------------------------------------------------- Cannot infer target type in expression (. x -fulcro$isComponent) -------------------------------------------------------------------------------- 609 | false)) 610 | 611 | #?(:clj 612 | (defn react-type
:compiler-options {:infer-externs true} was the previous defaulttrue was the previous default? what is the default now?:autotrue you have to (set! *infer-externs* true) to get the warningstrue ... 140 warnings is way too much2.1.1833 | (.on socket "message" on-message!) ----------------^--------------------------------------------------------------- Cannot infer target type in expression (. socket on "message" on-message!)
^js also worked.index.js:19 Uncaught TypeError: Cannot read property 'ease' of undefined
at Object.left (index.js:19)
at b.d.scrollSelectedIntoView (Tabs.js:257)
at b.value (Tabs.js:308)
at commitLifeCycles (react-dom.production.min.js:150)
at b (react-dom.production.min.js:159)
at ka (react-dom.production.min.js:170)
at t (react-dom.production.min.js:169)
at p (react-dom.production.min.js:168)
at m (react-dom.production.min.js:166)
at Object.enqueueForceUpdate (react-dom.production.min.js:110)
and crashes the root component and leaves the site with only background, typical react crash, investiageing...shadow-cljs release app --debug to get more clues about where you are at in the codeshadow-cljs check app, maybe that has some cluespause on exception in chrome and stepping through the code might help as wellUncaught TypeError: Cannot read property 'ease' of undefined since its named ease I don't think its an externs issuenil is passed where it shouldn't✗ shadow-cljs release public --debug shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn version: 2.1.16 ... [:public] Build completed. (1509 files, 1389 compiled, 0 warnings, 48.10s)oh damn, tmux is not allowing me to select text and copy,
1509 files geez 😛scroll does this dynamic things closure is not very fond of_scroll2.default.left(_this.tabs, invert * nextScrollLeft);
module.exports = {
left: make('scrollLeft'),
top: make('scrollTop')
}
function make (prop) {
return function scroll (el, to, opts, cb) {
if (typeof opts == 'function') cb = opts, opts = {}
var ease = opts.ease || inOutSine
but the object opts gets set to a default value {}, would guess that just adding var in front of that could fix is. In any case I open an issue.v20180204 didnt fix this, Im surprised how this worked for so long in the first place, only god knows (ergo nobody). But the idea of overriding I'll do anywayTypeError: Cannot read property 'log' of null
at b (main.js:1638):js-options {:resolve {"scroll" {:target :file
:require "./overrides/scroll_index.js"}}}
:file "overrides/scroll_index.js"shadow-cljs release app --debug should make it easier to find whats nulltarget and try to run shadow commands, I get this:shadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'target/shadow-cljs back so it workstarget folderrm -rf targetwatch:deps I guess?:deps is been used:compiler-options {:closure-defines {goog.LOCALE "en"}}, I remembered reading this earlier heregoog.LOCALE "en" is one of the defaults?"node_modules/scroll/index.js" after
:js-options {:resolve {"scroll" {:file "overrides/scroll_index.js"}}}:target :file:npm is configured via :require and :require-min:file is :file:target is necessary to select which key to look at next:file is a in a weird space right now since the classpath changes I made:global 😉module$overrides$scroll_index.js module$node_modules$scroll$index.jsand the code requireing scroll/index.js finds neither. Maybe harmless, just wondering if this is affecting the correct true state of the target to compilation.
modules$node_modules$material_ui$tabs$tabs.js or whatever that was called:filevar _scroll = require('scroll');
var _scroll2 = _interopRequireDefault(_scroll);
function called from _scroll2 that existed, is now not foundgoog.LOCALE "en" is one of the defaults, defaults of what?en shouldn't really make a difference?opts = opts || {}; cured it haha, wowrequire. can't influence what that does.:browser I control entirely how and what gets resolvedwebpack has something similar, thats where I got the idea:resolve {"scroll" {:target :npm :require "@hlolli/scroll"}} would have been the alternativerequire("material-ui") and whatever that does we have no control overscrollshadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'did some backtracking, and looks like this happens for every version 2.0.143 to present
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cfbca7aeaba0b8e2aca3a5bc8ffde1fee1fef6"}, :content ("[email protected]")} I hopenpx shadow-cljs server shadow-cljs - error $CLJS.Pg.resolve is not a function
mattpro:re-style MattPro$ npx shadow-cljs server shadow-cljs - config: /Users/MattPro/Documents/sites2017/re-view/re-style/shadow-cljs.edn version: 2.1.20 shadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'
mkdir -p target/shadow-cljs[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
cannot find package.json for package react at /Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json
{:tag :shadow.build.npm/missing-package-json, :package-name "react", :package-json-file #object[java.io.File 0x55bcd296 "/Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json"]}
ExceptionInfo: cannot find package.json for package react at /Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.npm/find-package* (npm.clj:126)
shadow.build.npm/find-package* (npm.clj:108)
shadow.build.npm/find-package (npm.clj:137)
shadow.build.npm/find-package (npm.clj:133)
shadow.build.resolve/eval20329/fn--20332 (resolve.clj:210)
clojure.lang.MultiFn.invoke (MultiFn.java:238)/Users/wilkerlucio/Development/personal/multi-timer/node_modules/react does it exist?rm -rf node_modules && npm installnpm installyarn these days which seems a bit more reliablerm -rf target/shadow-cljs and start the server again. does the target/shadow-cljs folder exist at least?npx shadow-cljs stop said that there was no server running, but then afterwards it workednpx shadow-cljs stop:lein or :deps?npx shadow-cljs server does not create the directory:depsmkdirp not mkdirp/sync ...:deps{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "40332821242f376d232c2a3300726e716e7271"}, :content ("[email protected]")} ...:source-paths and :dependencies are configured via lein. All build configs will still be in shadow-cljs.edn. So you only need to set :lein true in your shadow-cljs.edn. As far as builds they are identical whether or not you use lein.:lein true and move :dependencies and :source-paths to project.clj.[thheller/shadow-cljs "2.1.21"] though:cljsbuild keys in my project.clj?[[org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.9.946"] [thheller/shadow-cljs "2.1.21"]]
core.async is one common offender if you use an older versionnpm install react react-dom create-react-class for reagentnpm install it:none builds in Nashorn?node_modules/shadow-cljs directory? when I try compiling on anything else (still inside node_modules) it fails and dont runnpm-modules (for react native).babelrc for shadow-cljs which tells babel to not do any processingyarn remove on a package. All I had to do was to restart shadow-cljs.The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs".
npm install react react-dom create-react-class. Shadow doesn't use the included js from cljsjs.npm install xregexpshadow-cljsjs lib maps the foreign-libs back to their original npm packages and uses those directly646 | #?(:cljs NaN :clj Double/NaN)))) ----------------------^--------------------------------------------------------- Use of undeclared Var cuerdas.core/NaN
js/NaN?:cljsbuild
{:builds
{:app
{:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
:figwheel {:on-jsload "fema-gmm.core/mount-components"}
:compiler
{:main "fema-gmm.app"
:asset-path "/js/out"
:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:source-map true
:optimizations :none
:pretty-print true
;:install-deps true
;:npm-deps {:aws-amplify "0.2.6"
; :left-pad "1.1.3"}
:preloads [re-frisk.preload]}}}}
and what I have so far in my config file
;; shadow-cljs configuration
{:lein true
;:source-paths
;["src"]
;
;:dependencies
;[]
:builds
{:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js/out"
:modules {:main {:entries [fema-gmm.app]}}}}}
{:lein true
:builds
{:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:main {:entries [fema-gmm.app]}}
:devtools {:after-load fema-gmm.core/mount-components
:preloads [re-frisk.preload]}}}}npm install aws-amplifylein new luminus foo?lein new luminus foo +reagent or +re-frame ,etc[thheller/shadow-cljs "2.1.21"] dependencyproject.clj I have seen. scary that the template generates this mess.:after-load fema-gmm.core/mount-components setting up figwheel?lein for the server stuffshadow-cljs for cljs.core is the entry point for the applein run I'd recommend lein repl (user/start)semantic-ui-react adds 726 files to the compilation. that takes a while. shouldn't be a problem on the second compile once caching kicks in.shadow-cljs compile app --verbose to get a bit more timing related output-> Shadow JS converting 729 JS sources <- Shadow JS converting 729 JS sources (3688 ms) -> Shadow JS Cache write: 729 JS files <- Shadow JS Cache write: 729 JS files (5814 ms)
:verbose true in the config also works-> Flushing 1023 sources <- Flushing 1023 sources (108 ms) -> Flushing unoptimized modules <- Flushing unoptimized modules (95 ms)
"2.1.10"Flushing ... is just writing the final JS to disk, not the actual compilation parts[:browser] Build completed. (822 files, 728 compiled, 0 warnings, 18.15s)[:browser] Build completed. (822 files, 0 compiled, 0 warnings, 1.06s)<- Flushing 822 sources (6966 ms)ns into the namespace i’m working in at the REPL, none of the vars exist unless I manually evaluate the defs at the REPLmy.foo.bar/bazmy-project.pages.sign-in that has some logic, makes some requests, etc.(def foo "bar") inside of my-project.pages.sign-in, I’d like to evaluate foo at the REPL and see “bar” printed outmy-project.pages.sign-in/foo, even if I do (ns my-project.pages.sign-in) in the REPL firstdef(shadow.cljs.devtools.api/nrepl-select :script) To quit, type: :cljs/quit => [:selected :script] (in-ns 'demo.script) => demo.script (def foo "bar") => #'demo.script/foo foo => "bar"
(in-ns 'cljs.user) => cljs.user (ns demo.script) => demo.script foo => "bar"
ns into a namespace that is not yet loaded(require 'that.ns) first to load itns into the namespace are things that are (:require)’d in the ns declarationin-ns not ns(ns that.foo) it will be empty, no defs no requires nothingin-nsrequire firstin-ns also only switches and does not load-main function is in and I often evaluate the whole file(ns cambia.web.experience.dashboard.pages.sign-in
(:require [cambia.web.ui.components.page-header :as page-header]
[cambia.web.experience.dashboard.components.page-setup :as page-setup]
[cambia.web.experience.dashboard.components.login :refer [login]]))
;; ...
(defn foobar [] "baz")
page-header is an alias, you can't use that directlypage-header/foo or whatever is in that ns:as is only direclty usable for JS namespaces. not allowed for CLJ(S).(defn my-func [] ...) and then send forms that invoke it (my-func). I seem to need to run the definition manually before being able to use it. But @lilactown pointed out that it is actually loaded already but you have to use the fully qualified namespace(require 'my-project.core) (in-ns 'my-project.core) (my-func)
[2018-02-21 12:29:33 - WARNING] client sent unknown msg {:type :repl/set-ns-complete, :id 0, :ns seekeasy.util}{op: "eval", code: wrappedCode, ns: ns, session: session}. I need to figure out a way to dump the actual serialized bytes being sent over the socket to tell more, but the code should be sending the namespace of the current file from which you send the formshadow-cljs using its own internal way to resolve the classpath? If so I have a feature request if possible 😄lumo 🙂shadow-cljs itself depends on shadow-cljs-jar{:dependencies [[foo/bar "1.2.3"]]} map from stdin:cache-root/classpath.edn:cache-root/classpath.edn I guesslumo depstools.deps which I would recommend at this point to be honestproject.clj in place and I can just use lein...or use tools.depsclojure -Spath which is what I assume you are asking for?deps.edn to become standard pretty soon I'd suggest sticking with thatnpm install but yeah...you are probably right...shadow-cljs.edn config:node-library, you could even add JSDoc 😄 😄 😄shadow-cljs has improved a lot since the last time I checked!shadow-cljs tool classpath by any chance? my deps are not deployed on Maven as we prefer npm in my company at the moment...deps.edn, I will try thatdeps.edn file that contains {:paths ["src" "../spec-cljs/src"]}dist a folder called cljs-runtime:output-dir:release {:output-to "some-other/path.js"} to only change the path for release:output-to you will only get that file. :output-dir during development uses an absolute path in the target/shadow-cljs directory so the cljs-runtime folder doesn't show up in the dist dir 😛(println "hello") will print hello in the screen I executed shadow-cljs node-repl, Is it possible to print the message in cider? (https://github.com/thheller/shadow-cljs/issues/207#issuecomment-367699962)IllegalStateException: Can't change/establish root binding of: *cljs-warnings* with set when using the [binaryage/oops] library (https://github.com/binaryage/cljs-oops) within a shadow-clj repl. Any ideas?goog.object/set did not seem to be working to set properties of a javascript object. I believe something else is going on. My javascript interop chops are weak.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fd8e959c99928ad09e91978ebdcfd3ccd3cfc9"}, :content ("[email protected]")}import "shadow-cljs/shadow.cljs.devtools.client.browser":output-dir is:target :react-native but I haven't done any serious RN developmentshadow compile test followed by a node invocation on what was generatedcljs.test?sherman.server-test?lein auto tach lumo process running, and I have a (cljs.test/run-tests) line at the end of each of my test files(prn :foo) or so to confirm that they are getting loadedshadow compile test --verbose should also show them getting compiledlein auto tach lumo task in a separate window, but I'm not sure if there's a way of doing something similar in shadow yetchokidar-clichokidar out/node-test.js -c 'node out/node-test.js'npm install -g chokidar-cli https://github.com/kimmobrunfeldt/chokidar-cliI/ReactNativeJS: '%cDEVTOOLS: disconnected!', 'color: blue;To quit, type: :cljs/quit => [:selected :app] 3 There is no connected JS runtime.
lein with-profiles +cljs repl then (require 'repl) (repl/go)(shadow.cljs.devtools.api/watch :browser) is the test build I commonly use<script> tags to load things, that wont work on RN, I'm wondering if its easier to start from the node version, I tried that directly but seems like RN doesn't have teh crypto package, but in terms of load seems the node version is closer:npm-module it won't use <script>cider-nrepl.lein watch or whatever the command was and then (do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))cider-nrepl already has access to all the data I believe(shadow.cljs.devtools.api/release-snapshot :the-build {})module$node_modules$material_ui_icons$Gamepad
But it's still acceptable size with gzip and click through the release snapshot sutff831.76 KB node_modules/material-ui-icons 203.19 KB node_modules/material-uiok I'm defenitely going to just download each svg that I use, damn!
var _ref = _react2.default.createElement('path', { d: 'M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z' });
lein clean when using with lein. maybe it's better to always clean before start?lein clean should not be required at all. if something doesn't work but works after lein clean I want details.["material-ui-icons/Hotel" :as Hotel] this means I have required ["material-ui-icons"] somewhere?lein clean, everything works fine.shadow-cljs - config: /Users/shitianshu/sideline/loadstone/shadow-cljs.edn version: 2.1.24 shadow-cljs - socket connect failed, server process dead?also I got this when type shadow-cljs in terminal. @thheller I think this is not a urgent issue, you can just ignore. when i have time, i can create a repo that reproduce the problem.
socket connect failed, server process dead?shadow-cljs stop insteadnpm install does not trigger a recompile. if you have a watch running that failed because of a missing npm dependency that build will stay stuckshadow-cljs server then shadow-cljs release :app and then navigate to http://localhost:9630/ I get “no release snapshots found”shadow-cljs clj-repl and then (shadow.cljs.devtools.api/release-snapshot :the-build {})shadow-cljs clj-repl (shadow/stop-worker :build) (shadow/watch :build)ExceptionInfo: module without entry or suffix: react what's this error stands for?node_modules/react/package.json?npm or cnpm?cnpm did some weird symlinks that causes issues a while agoshadow-cljs clj-repl (shadow.cljs.devtools.server/reload!) if anything weird is happeningreact, react-dom and shadow-cljs in node_modules become empty...node_modules/react/node_modules(shadow.cljs.devtools.api/find-resources-using-ns 'foo.bar)["pdfjs-dist/lib/pdf.js" :as pdfjs]
["pdfjs-dist/web/pdf_viewer.js"]))fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
require.ensure([], function () {
var worker;
worker = require('./pdf.worker.js');
callback(worker.WorkerMessageHandler);
});
} : dynamicLoaderSupported ? function (callback) {
requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
callback(worker.WorkerMessageHandler);
});{
var isNodeJS = require('./shared/is_node.js');
if (isNodeJS()) {
var PDFNodeStream = require('./display/node_stream.js').PDFNodeStream;
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
return new PDFNodeStream(params);
});
} else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
var PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
return new PDFFetchStream(params);
});
} else {
var PDFNetworkStream = require('./display/network.js').PDFNetworkStream;
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
return new PDFNetworkStream(params);
});
}
}~/test/pdf.js/examples/webpack$ npm run build >
require.ensure and ignore themmain.js, which does a var pdfjsLib = require('pdfjs-dist'); and one for the workerrequire.ensure([], function () {
var worker;
worker = require('../pdf.worker.js');
callback(worker.WorkerMessageHandler);
});require.ensure to create a split pointgulp.task('build-bundle', function() {
return browserify('main.js', {output: TMP_FILE_PREFIX + 'main.tmp'})
.ignore(require.resolve('pdfjs-dist/build/pdf.worker')) // Reducing size
.bundle()
.pipe(source(TMP_FILE_PREFIX + 'main.tmp'))
.pipe(streamify(uglify()))
.pipe(rename('main.bundle.js'))
.pipe(gulp.dest(OUTPUT_PATH));
});
require.ensure2.1.25 should not include the worker anymoreseekeasy.page.worker.js:1 Uncaught SyntaxError: Unexpected token <
pdf.js:3853 Uncaught TypeError: Cannot read property 'WorkerMessageHandler' of undefined
at pdf.js:3853
at HTMLScriptElement.c.onload (pdf.js:771)cider-quit command.shadow-cljs - updating dependencies which work will be done at this moment. hang at here.shadow-cljs use maven for retrieving dependencies?updating dependencies will try to resolve maven depsmaven will be used? it has an embed mvn?mirrorsmvn command will use the config in ~/.m2/settings.xml, but shadow-cljs not.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e415e4246"}, :content ("[email protected]")} which should support :mirrors in your shadow-cljs.edn configshadow-cljs?:mirrors {"" {:name "some string" :url ""}}:mirrors should be write in project config, also for cider dependencies.:mirrors and :dependencies in my use case.shadow-cljs in react-native, each time I save a file, client will have a full reloadshadow-cljs recompile, it overwrite all files, this cause a full reload.shadow-cljs with react-native script, not expo.:target you use?:browser:after-load and :preloads [shadow.cljs.devtools.client.hud] in :devtools.{:source-paths ["src"]
:dependencies []
:builds {:browser {:target :browser
:output-dir "target/browser"
:modules {:main {:entries [app.main]}}
:devtools {:after-load app.main/reload!
:preloads [shadow.cljs.devtools.client.hud]
:http-root "public"
:http-port 8080}}}}
I use this as minimal setup and it works:after-reload, but whatever, it works.:autoload true.:npm-module ?react-native, how can I investigate what's going wrong?:npm-module there is no cleary defined entry namespacereact-native init Hello
then cd Hello, run shadow-cljs init.
edit shadow-cljs.edn to
...
:builds
{:app {:target :npm-module
:output-dir "js/"}}
And require js/hello.core.js in App.js.import "js/shadow.cljs.devtools.client.node" in App.jsimport "js/shadow.cljs.devtools.client.browser":runtime :browser in your build config:devtools-url see https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support192.168.1.151, what is the :devtools-url?Can't find variable: document. But after I dismiss this error, it works.script-eval it works and no error:react-native an :target 🙃:target :react-nativejs/document.
shadow.cljs.devtools.client.browser is meant for the browser. react-native is not a browser.shadow.cljs.devtools.client.react-native version. that uses every capability react-native has.:devtools-url :target :react-native could do thathello/core.cljs in source map, is that a relative path? in chrome, the src is not include in souces, there're node_modules and js(output dir). do you have any thought on this?src, but in chrome Sources section, there're only two folder: node_modules and js.cljs file in my casehello/core.cljs, i think it shoud be ../src/hello/core.cljs../src/.. would definitely be incorrect11:41:42 CLJS | ------ WARNING #1 -------------------------------------------------------------- 11:41:42 CLJS | File: day8/re_frame_10x/view/parts.cljs:26:28 11:41:42 CLJS | -------------------------------------------------------------------------------- 11:41:42 CLJS | 23 | :children [[:h1 "Events"] 11:41:42 CLJS | 24 | (render-registered re-frame.events/kind) 11:41:42 CLJS | 25 | [:h1 "Subscriptions"] 11:41:42 CLJS | 26 | (render-subs re-frame.subs/kind) 11:41:42 CLJS | ----------------------------------^--------------------------------------------- 11:41:42 CLJS | Use of undeclared Var re-frame.subs/kindHas anyone else ran into this? It doesn't make sense given re-frame is in my
:dependencies.re-frame.subs so it complains:devcards to true in my :dev :compiler-options.:repositories in my shadow-cljs.edn?:react-native target.2.1.28 which might just fix your problem. if not you can set :build-options {:par-timeout some-high-number-in-ms}lein but not sure if I'm maybe not setting something I would need to set. lein or deps.edn also work though.:shadow.build.classpath/resource "datascript/pull_api.cljc"] #error {
:cause "aborted par-compile, [:shadow.build.classpath/resource \"datascript/pull_api.cljc\"] still waiting for #{datascript.pull-parser}"
:data {:aborted [:shadow.build.classpath/resource "datascript/pull_api.cljc"], :pending #{datascript.pull-parser}}
:via
[{:type clojure.lang.ExceptionInfo
:message "aborted par-compile, [:shadow.build.classpath/resource \"datascript/pull_api.cljc\"] still waiting for #{datascript.pull-parser}"
:data {:aborted [:shadow.build.classpath/resource "datascript/pull_api.cljc"], :pending #{datascript.pull-parser}}
:at [clojure.core$ex_info invokeStatic "core.clj" 4739]}]
Is there a way to get more information printed out? I'd bet something else is going on here.-v flag and I get more information. I don't understand why some namespaces are taking a long time to compile. For example
Cache write: datascript/impl/entity.cljc <- Compile CLJS: datascript/parser.cljc (78929 ms)
No binary for ChromeHeadless browser on your platform. error not but that's something else I'm guessing). Confusing debugging process though. Not sure why it was telling me DataScript was taking a long time to compile.No binary for ChromeHeadless browser on your platform. is no error from shadow-cljs. probably karma?karma-chrome-launcher doesn't install chrome so you need to install chrome manuallylein-2.8.1-node-browsers should work-> indicates that an ns started compiling<- means it completed-> I guessFeb 27, 2018 3:03:01 AM shadow.build.compiler invoke
WARNING: [:shadow.build.classpath/resource "cljs/test.cljs"] waiting for #{cljs.pprint}
with the namespaces in the log messages varying.cider-jack-in and it uses lein to start a headless REPL and connect to itprn output appear in the REPL windowprn yes, console.log notarget/shadow-cljs/nrepl.port file which contains the port number.nrepl-port from leinshadow-cljs.edn though since :cache-root can be configuredshadow-cljs node-repldefun shadow-node-repl () is defined twice?(shadow.cljs.devtools.api/node-repl) does since simply by reading until eof on stdinshadow-cljs node-repl uses and just kills the node process aftrer{:op "do-a-thing" :some "thing"} and gets messages {:out "this is printed"} or {:value "foo"}:out would the the first output from the operation.:out is always stdout{:op "eval" :code "(+ 1 2)" :id 1} would get {:value "3" :id 1}shadow-cljs.edn that was working before, still getting the same behavior.lein clean fixed the version without lein.socket connect failed, server process dead? means that the server was most likely killed forcefully so the server didn't clean up after itself. can you verify that the server is actually dead? ie. no running java process left?lein clean will delete the target folder which includes target/shadow-cljs/*.portlein clean since that kills the information the server needs:cache-root ".shadow-cljs" in your config so lein clean doesn't mess with the server state(defn start-cljs-repl [] (shadow-server/start!) (shadow/watch :app) (shadow/watch :test) (shadow/watch :devcards) (shadow/nrepl-select :app))and then we can just do cider-jack-in-clojurescript We also have a
.dir-locals.el which contains:
((nil . ((projectile-project-type . lein-test)
(eval . (progn
(require 'cider)
(setq projectile-create-missing-test-files t)
(setq cider-cljs-lein-repl "(start-cljs-repl)"))))))
So we can set the correct command to start he cljs-replnode-repl2.2.0. bumped to 2.2 because I changed the default cache directory. it is now .shadow-cljs instead of target/shadow-cljs. too many conflicts with lein cleaning the target directory. you can configure the old directory by setting :cache-root "target/shadow-cljs" in your config.(shadow.cljs.devtools.api/node-repl) also works inside nrepl nowshadow-cljs browser-repl (or (shadow.cljs.devtools.api/browser-repl) for a simple browser REPL without a build configcp/spawnSync failed before the process got started, i.e. if an error would be displayed. It seems like this is always failing for me, independent of lein, since it also failed to run an npm command it said it was executing.lein clean and downgrade back to 2.1.26, the issue disappears.[com.google.javascript/closure-compiler-unshaded "v20180101"] to your dependencieslein with-profile dev run -m shadow.cljs.devtools.cli --npm watch app directly also fails without any error?shadow-cljs - socket connect failed, server process dead?, I wonder if it's sending some kill signal that isn't handled by shadow-cljs?(process-send-string (get-process "shadow-cljs") ":repl/quit\n")
and
(kill-process "shadow-cljs")
it kills the process for sure, it may be sending some SIGTERM or SIGINIT, I wonder which or something else...{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a0d3c8c1c4cfd78dc3cccad3e0928e928e91"}, :content ("[email protected]")}shadow-cljs-jack-in
I can start on my computer browser-repl node-repl and start watch and have cider connect to it without doing anything (like pressing enter twice). Only problem being the possibility of creating these ghost java processes. Deleteing .shadow-cljs directory most often fixes it. Assumes shadow-cljs v2.2.20+, the emacs package edn (melpa/elpa) and cider/cider-nrepl as declared dependency within shadow-cljs.edn.{:dependencies
[[cider/cider-nrepl "0.17.0-SNAPSHOT"]
:nrepl {:port 9000
:middleware []}
...}
This I have on top level.SomeGlobalObj in a.js and use SomeGlobalObj in b.js , I generated a a-externs.js file for *a.js* and add to shadow-cljs.edn :compiler-options, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js. How to fix this?:target :node-library to get a UMD api that works in both node and the browservar Foo = require("foo") in node, or just window.Foo in the browser if you’re just including the JS file in a script tag without a build systemwindow.returnExports instead of window.<my-lib-name> because this is hard-coded into the UMD template that shadow uses here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/umd_exports.txt#L7:umd-root-name "Foo"?cider-quit command, this is not normal quit behavior for shadow-cljs.cider-quit so I can look at what it actually does and see if I can do something about it?delete-process, which send signal SIGHUP.spawnSync doesn't return until the process it spawned dies so I need to switch to spawn firstlein dependence in most tools such as cider I would probably recommend just running through leinre-natal is this: https://github.com/drapanjanas/re-natal/pull/102/files
no need to patch in shadow-cljsmonaco-editor-core loading in cljs// OS detection
if (typeof process === 'object') {
_isWindows = (process.platform === 'win32');
_isMacintosh = (process.platform === 'darwin');
_isLinux = (process.platform === 'linux');
_isRootUser = !_isWindows && (process.getuid() === 0);
let rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
if (rawNlsConfig) {
try {
let nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
let resolved = nlsConfig.availableLanguages['*'];
_locale = nlsConfig.locale;
// VSCode's default language is 'en'
_language = resolved ? resolved : LANGUAGE_DEFAULT;
} catch (e) {
}
}
_isNative = true;
} else if (typeof navigator === 'object') {
let userAgent = navigator.userAgent;
_isWindows = userAgent.indexOf('Windows') >= 0;
_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
_isLinux = userAgent.indexOf('Linux') >= 0;
_isWeb = true;
_locale = navigator.language;
_language = _locale;
}
(js-delete js/self "process") before I instantiate itprocess object at runtimejs/process won’t screw up anything elseprocess.browser or process.env.NODE_ENVNODE_ENV will be inlined and optimized awayprocess.env accesses that won't be(defn require [paths cb]
(let [process (.-process js/self)]
(js-delete js/self "process")
(js/require (clj->js paths)
(fn [result]
(set! (.-process js/self) process)
(cb result)))
nil))
if it so happens that no other code attempts to read js/process during the span of time before require calls its callback<script src="/js/monaco/vs/loader.js"></script>process as a globalprocess at runtimeSomeGlobalObj in a.js , use SomeGlobalObj in b.js , generate a a-externs.js file for *a.js* and add to shadow-cljs.edn :compiler-options, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js. How to fix this?var SomeGlobalObj = {
"invoke": function () {},
"on": function () {}
}
invoke and on are not changed anymore.:compiler-options {:externs ["path/to/externs.js"]}? :compiler-options {:externs ["./weixin-externs.js"]}on and invoke, then I add the externs and the error not come out again.a.js is not, b.js is imported into cljsSomeGlobalObj.function handleFontSize() {
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
WeixinJSBridge.on('menu:setfont', function() {
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
});
}
here WeixinJSBridge is SomeGlobalObj.shadow-cljs release appshadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn version: 2.1.4 shadow-cljs - connected to server [:doumi] Compiling ... ------ WARNING #1 -------------------------------------------------------------- File: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: com/cognitect/transit/types.js:384:70 variable Buffer is undeclared -------------------------------------------------------------------------------- ------ WARNING #4 -------------------------------------------------------------- File: doumi/autorem.js:13:4 variable WeixinJSBridge is undeclared -------------------------------------------------------------------------------- nil [:doumi] Build completed. (713 files, 3 compiled, 0 warnings, 28.53s)
var autorem = function (...) {...}
module.exports = autorem;
export default autorem;(:require ["./autorem" :default autorem]):modules:include-macros true is in the core?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "54273c35303b237937383e2714667a667a67"}, :content ("[email protected]")} doesn't leak the process global anymorenpm install:resolve {"mylib" {:target :file
:file "jar:file:/lib/some.jar!/mylib.js}}
bit sorry I didn't try to do this immediately, was stuck with other project and the @logbot hasn't published logs for this channel since last year.(:require ["/path/to/mylib.js" :as x]) abs path being on the classpath(:require ["/mylib.js" :as x]) in your case. but be careful with files like that. everything on the classpath should be properly namespaced../ is relative to the current file/ is from any classpath root"libcsound" resolves to "/csound_wasm/libcsound""/csound_wasm/libcsound"?shadow-cljs release node compilation.:js-options at all"/csound_wasm/libcsound" not libcsoundClosure compilation failed with 7 errors --- csound_wasm/libcsound.js:81 Invalid module path "goog:shadow.js.shim.module$fs" for resolution mode "BROWSER" --- csound_wasm/libcsound.js:82 Invalid module path "goog:shadow.js.shim.module$path" for resolution mode "BROWSER" --- csound_wasm/libcsound.js:4253 Invalid module path "goog:shadow.js.shim.module$crypto" for resolution mode "BROWSER" --- csound_wasm/libcsound.js:5166 Invalid module path "goog:shadow.js.shim.module$ws" for resolution mode "BROWSER" --- csound_wasm/libcsound.js:5416 Invalid module path "goog:shadow.js.shim.module$ws" for resolution mode "BROWSER" --- remaining errors ommitted ...
make: Entering directory '/mnt/c/Users/thheller/code/shadow-cljs/tmp/csound-wasm/node_modules/speaker/build' CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o ../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory #include <alsa/asoundlib.h>
Windows: win32 Audio output for Windows (winmm). whatever winmm is, need to look into that. Webaudio in node.js is a strange world.module.exports = Module at the end of the file. the minifier would otherwise not find the object.node_modules sources but isn't at the momentlibcsound_browser.js libcsound_node.jsnodelibcsound.js to npm independently?Invalid module path "goog:shadow.js.shim.module$fs" for resolution mode "BROWSER" this I can fix easilyrequirerequire("fs")node_modulescljs.env/*compiler* return nil in the node-repl? required or notcljs.env/*compiler* is NEVER initialized:devtools {:enabled false} if you want to play around but REPL won't workreact-native which I haven't yet implemented:npm-module will work but not the REPL or built-in live reloadshadow-cljs clj-repl (require 'that.ns :reload):devtools for not and remove the import of shadow.cljs.devtools.*shadow-cljs do server-side-rendering for NodeJS-Express.js apps?shadow-cljs - server starting ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^Cupgraded shadow-cljs to
2.2.3 and server takes forever to start. Any idea what I might be doing wrong?cat .shadow-cljs/*.log or try shadow-cljs server?12:12:10.950 [main] WARN shadow.cljs.devtools.server - TCP Port 9630 in use.server errored because the port is in use.12:16:49.736 [main] WARN shadow.cljs.devtools.server - TCP Port 9630 in use. 12:16:49.736 [main] DEBUG io.undertow - starting undertow server
start.shadow-cljs stop... version: 2.2.3 shadow-cljs - server not running
jps lists all java processesjvisualvm might helplein nrepl :connect the-port(System/exit 1)lein repl not nreplshadow-cljs *start as the node process exitsjvisualvm is the best option(defprotocol Fun-Time (drinky-drinky [_]))i get
IllegalStateException: Can't change/establish root binding of: *unchecked-if* with setreported here https://groups.google.com/forum/#!msg/clojurescript/__Qf6L40cwU/MP7pTpTFDAAJ I explicitly added the most recent clojurescript as dependency, but this may be clojurescript bug.
shadow-cljs.edn?:fs-watch {:watch :polling})~/.shadow-cljs/config.edn. that config will be merged with the one in the project{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "493a21282d263e642a25233a097b677b677d"}, :content ("[email protected]")}:module-move warnings (dozens of them now appear). The source says ;; only warn when a file is moved to a module it wouldn't be in naturally:shared module in order to collect common dependencies? then there would be no deps in :shared at all ‘naturally’2.1.4 to 2.2.4, I am getting a Cannot call a class as a function error at runtime:
shadow$provide.module$node_modules$graphql$language$source = function(g, v, m, r, l) {
Object.defineProperty(l, "__esModule", {
value: !0
});
l.Source = void 0;
m("module$node_modules$graphql$jsutils$invariant");
l.Source = function(a, f, c) {
throw new TypeError("Cannot call a class as a function");
}
}
;
[com.google.javascript/closure-compiler-unshaded "v20180101"] to your deps:module-move is a bit tricky if you expected things to be moved:entries for :shared:module-move but thats what we have for now2.2.4, I’m seeing #shadow-hud-loading-container but not seeing #shadow-hud-container if I force a syntax error (just an error in the terminal). Was the HUD changed in some recent version? (I upgraded from a 2.0.x version)(shadow.cljs.devtools.api/reload!) to "restart" the server without restarting the JVMREPL command timed out. is the error?Error evaluating - class java.lang.InterruptedException: Error evaluating - class java.util.concurrent.RejectedExecutionException: Task
shutdown-agents?shutdown-agents:cljs/quit and then (shadow.cljs.devtools.api/reload!)(+ 1 2)<script src="some/relative/path.js"> maybe?<script src="js/main.js"></script>/js/main.js. otherwise it will attempt to load something/js/main.js when you are in /something/path.js files are requestedopen in new tab for the requestnpm start, and BAM, you have a working hot reloading project. you can start editing right then and there. shadow is great, but you still have to go read the section on :devtools, pick a directory, make sure you’re setting it right, figure out how the :after-load handler works and install it somewhere, etc. etc. each of these things = friction.:browser target and introduce some convention around it:browser-simple:app-ns my.app or somy.app/start and my.app/stop as the :after-load and optional :before-loadpublic/js/main.js:modules:target :reagent:browser is just generic browser stuff, could totally do framework specific stuffcreate-react-app did which is quite clever is that they separated out create-react-app, which is a generic tool, from react-scriptsshadow-cljs might be able to act as create-react-app and then you could write the react-scripts equivalent for, say, reagent.create-react-app part is just a template really.react-scripts rather than the template itself{:source-paths
["src"]
:dependencies
[[reagent/shadow-cljs "1.0.0"]]
:builds
{:app {:target :reagent
:app-ns my.app}}}package.jsonnpm install and prints the usual help stuffsrc files:reagent target in the guide. are you saying one can create custom targets?:browser target for everything in this case:browser config from that :target :reagent baseline and call the browser/process fn:reagent means is that shadow-cljs will try to load shadow.build.targets.reagent/process:browser with one adjustment to only output a single file in development:electron, :react-native, etcshadow-cljs itself{:source-paths
["src"]
:dependencies
[[reagent/shadow-cljs "1.0.0"]]
:builds
{:app {:target :reagent
:app-ns my.app}}}[reagent/shadow-cljs "1.0.0"]:targetshadow-cljs clj-run reagent.quick-start:target could definitely set way more aggressive defaults than :browser can. and since its just clojure data you could just generate the more complex :browser config from the "easy" one.2.2.5 which makes push-state the default and does the Accept header check to no longer serve images as htmlchokidar thing works well enough and just just an yarn add chokidar-cli --dev awayshadow-cljs clj-run some.ns/fn2.2.6 you can do
{:target :node-test
:autorun true
:output-to "out/demo-test-node/script.js"}node out/demo-test-node/script.js when the build completes:ns-regexp "some.ns-test" to only run the test ns you care about (instead of all -test)autorun thing before but removed it because it didn't make sense in many other testing scenarios (eg. browser-test, karma). but now that they are different targets it really makes sense for :node-test:autorun should be an ok temp solutionwatchshadow-cljs watch script be enough?2.2.6 releaseshadow-cljs watch script would not be enough. shadow-cljs watch script test would. or second shadow-cljs watch test processwatch test(shadow.cljs.devtools.api/compile :test):optimizations only applies to release builds. so :none is actually invalid. :none is enforced for watch and compile always so you do not need to set it to :none ever.shadow-cljs - error ENOENT: no such file or directory, open '.shadow-cljs/logging.properties'shadow-cljs watch script test.shadow-cljs/logging.properties?:output-to and :output-dir options?(defn compile* [build-config opts]
(util/print-build-start build-config)
(-> (util/new-build build-config :dev opts)
(build/configure :dev build-config)
(build/compile)
(build/flush)
(build-finish build-config)))
:output-to and :output-dir are getting set?:build-options :output-dir to a java.io.File instanceopts special or can I pass in something like:
(shadow/compile :app
{:build-options {:output-to "mypath/public/js"
:output-dir "mypath/public/js"}})
?(defn compile* [build-config opts]
...
(build/deep-merge opts)
(build/flush)
...
)))
flush should write output so you could set it like this(defn compile* [build-config opts]
(util/print-build-start build-config)
(-> (util/new-build build-config :dev opts)
(build/configure :dev build-config)
(build/compile)
(assoc-in [:build-options :output-dir] (io/file "somewhere"))
(build/flush)
(build-finish build-config)))lein.shadow-cljs watch app should that pick up changes to the dependencies in shadow-cljs.edn?:dependencies currently require a restart. I have some plans to fix that but its not finished yet.:after-load to the :devtools config. Even if the it points to a function that does nothing.:autoload true. autoload is not enabled by default.:after-loadyarn or npm for installing packages it finds in deps.cljs files in dependencies?"a", and it only comes from some library Lib my app depends on.
step 1, first compile: shadow-cljs installs version 1 of "a" because that is what is listed in a deps.cljs file in Lib. This is added to the local package.json.
step 2: Lib updates their deps file to version 1.1 of "a".
step 3: after upgrading to new version of Lib, we compile again. The local, auto-installed version of "a" will not be upgraded, but a warning is printed.
I think the only thing one can do here is manually update the local package.json file whenever a warning like this appears?yarn remove a then run shadow again["react-dnd-html5-backend" :default HTML5Backend] into [react-dnd-html5-backend :as react-dnd-html5-backend :refer (default) :rename {default HTML5Backend}]? When I do that, I get a perplexing runtime error: Uncaught ReferenceError: react_dnd_html5_backend is not defined on this line of code (react-dnd/DragDropContext HTML5Backend). I’m confused that it complains about react_dnd_html5_backend instead of complaining about default or HTML5Backend maybe.react_dnd_html5_backend/default works, so nevermind------ WARNING #1 -------------------------------------------------------------- File: bide/impl/helpers.js:29:41 variable toString is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared ---------------------------------------
toString is not declared. the transit warnings are also correct but its in conditional node code so it doesn't matter much.'[object Array]' == toString.call(val):npm-deps is icky. yarn will be used if a yarn.lock exists. there is this obscure and totally not official :node-modules {:managed-by :yarn} setting you can set in the shadow-cljs.edn top level as well.shadow.cljs.devtools.client.hud turned on by default now?:browser yesrequire. The other side is the client side with also some extra APIs. I think it could be treated as just two separate targets…:before-load and :after-load in devtools options?on-reload! functions which only exist to trigger cleanup/reset behaviour from namespaces which have no other relationship to each otherrequire?require the electron APIs from both sides, but the browser side gets access to the “remote” part of that.require function, no?:before-load maybe?on-reload! fns directly from your one on-reload! doesn't work?(defonce on-reload* (atom {}))
(defn on-reload
"Register a callback to fire when page reloads (during development)"
[key f]
(swap! on-reload* assoc key f))
(defn reload!
"Fire registered reload callbacks"
[]
(doseq [f (vals @on-reload*)]
(f)))
:after-load fns is that it can't control async(ns my.awesome.stuff {:shadow/after-load some-fn-in-this-ns} ...)re-view it would be nice to say “and add re-view.render-loop/render to your :after-load option”(defn ^:shadow/after-load on-reload! [] ...)(defn ^:shadow/after-load , ^:figwheel/after-load ...) (*I can’t remember what metadata figwheel all uses, i remember something like ^:figwheel-always):before-load just to avoid things interfering with reloadlein style and tools.deps style: paths vs source-paths, deps vs dependencies, repos vs repositories. will it be a good idea to support both or insisting on the lein style or just like user use tools.deps with shadow-cljs?.cljc namespace which used defmacro, but did not include a (:require-macros [...self...]) in the ns form.
this was in a utility library I used in Maria. Whenever I would compile the ‘browser’ build and the ‘bootstrap’ build together, this still worked as expected, so I had no idea I had even made a mistake. But if I would compile the ‘browser’ build independently from the ‘bootstrap’ build, I wouldn’t get a warning, but cljs would treat the defmacro as a function and return the unevaluated form.defmacro thing. one build should not affect the other since they are completely isolated[:bootstrap] Compiling ...[:live] Compiling ...[:trusted] Compiling ...
/usr/local/bin/clojure: line 342: 316 Killed "$JAVA_CMD" "${jvm_cache_opts[@]}" "${jvm_opts[@]}" -classpath "$cp" clojure.main "${main_cache_opts[@]}" "defmacro is properly requireddefmacro in .cljc files without being hidden in a conditional is scarily commonutil, a cljc file, and I was requiring it from another cljc file(util/the-thing ...) it just calls it as a function:cljs(defmacro deftime
"This block will only be evaluated at the correct time for macro definition, at other times its content
are removed.
For Clojure it always behaves like a `do` block.
For Clojurescript/JVM the block is only visible to Clojure.
For self-hosted Clojurescript the block is only visible when defining macros in the pseudo-namespace."
[& body]
(when #?(:clj (not (:ns &env)) :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))
`(do keyword-identical? for cljs and identical? for clj(util/the-thing ...)defmacro creates it------ WARNING #1 -------------------------------------------------------------- File: C:\Users\thheller\code\shadow-cljs\src\dev\demo\browser.cljs:24:2 -------------------------------------------------------------------------------- 21 | (defmacro dummy-macro [& body] 22 | (prn :foo)) 23 | 24 | (dummy-macro 1 2 3) --------^----------------------------------------------------------------------- Use of undeclared Var demo.browser/dummy-macro --------------------------------------------------------------------------------
defmacro is right there 😛defmacro is also to blame though.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "37445f565358401a545b5d4477051905190e"}, :content ("[email protected]")}. it probably breaks all the self-host stuff. please test.------ WARNING #1 -------------------------------------------------------------- File: cljs/spec/test/alpha$macros.cljc:113:35 -------------------------------------------------------------------------------- 110 | ([xs] 111 | `(instrument ~xs nil)) 112 | ([sym-or-syms opts] 113 | (let [syms (sym-or-syms->syms (eval sym-or-syms)) -----------------------------------------^-------------------------------------- Use of undeclared Var cljs.spec.test.alpha$macros/eval -------------------------------------------------------------------------------- 114 | opts-sym (gensym "opts")] 115 | `(let [~opts-sym ~opts] 116 | (reduce 117 | (fn [ret# [_# f#]] ---------------------------------------
declare that?eval is set!cider-jack-in starts a new lein process, so it won't find the one started by shadow-cljs watchlein repl basically, starts an nrepl session(require '[shadow.cljs.devtools.server :as server]) (server/start!) (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :foo) (shadow/nrepl-select :foo)
(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/watch :dev)
(shadow.cljs.devtools.api/nrepl-select :dev):dev is a built-in concept of shadow-cljs. every build has a dev and release mode:dev?shadow-cljs release the-build or shadow-cljs watch the-buildshadow-cljs - HTTP server for :app available at shadow-cljs - server running at [:app] Configuring build. [:app] Compiling ... [:app] Build failure: The required namespace "cljs-0x-connect.dev" is not available. To quit, type: :cljs/quit [:selected :app] mar 14, 2018 12:02:49 PM clojure.tools.logging$eval8628$fn__8631 invoke WARNING: stale websocket client, no worker for build :dev
:lein true in your shadow-cljs.edn?:lein true.shadow-cljs watch?clean the .shadow-cljs dir. :clean-targets ^{:protect false} ["target" "public/js" "node_modules" ".shadow-cljs"]:source-paths ["src" "dev"]:source-paths ["src"] there too:lein :dependencies and :source-paths are managed by lein and no longer mean anything in shadow-cljs.ednuser> (start-dev!) mar 14, 2018 12:17:48 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final mar 14, 2018 12:17:48 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :app available at shadow-cljs - server running at [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (226 files, 124 compiled, 0 warnings, 29,07s) To quit, type: :cljs/quit [:selected :app] user> JS runtime connected.
cider experience. I don't really know anything about ciderlein repl and then starting the server, watcher and repl using the API.cider-create-sibling-cljs-repl. That could work, I'll try.Connecting to remote nREPL server... Clojure 1.9.0 (js/console.log "HELLO") CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(null:1:1) (+ 1 1) CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(null:1:1)
Connecting to remote nREPL server... Clojure 1.9.0 (+ 1 2) => 3
module.js:478
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at [eval]:3:13
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at Object.runInThisContext (vm.js:97:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:577:32)
at evalScript (bootstrap_node.js:351:27)
Does anyone have any idea on what may be causing it?
My package.json:
{
"devDependencies": {
"shadow-cljs": "^2.2.9"
},
"dependencies": {
"create-react-class": "^15.6.2",
"react": "^15.6.2",
"react-dom": "^15.6.2"
}
}
:lein true.shadow-cljs and shadow-cljs-jar dirs.hlolli is typing?:lein true?re-frame-template and modified the generated project to use shadow-cljs.
The shadow-cljs.edn files do not differ between two projects. But the build for my main project starts with
Compiling ClojureScript...
Compiling ["frontend/static/js/main.js"] from ["frontend/cljs"]...
Options passed to ClojureScript compiler: {... A large map of options...}
[... the aforementioned error ...]
whereas the build for the generated project starts with
shadow-cljs - server running at shadow-cljs - watching build :dev [:dev] Configuring build. [:dev] Compiling ...
;; to clean JS files generated during the build :hooks [leiningen.cljsbuild]Removing the last one also removes the error, which of course surfaces a whole bunch of other errors. But they should be fixable.
lein if you don't need clojure. the @cljs-oss/module-deps is not from shadow-cljs and must be coming from something in lein-cljsbuild:jvm-opts being passed down is a shadow issue or a deps issue?deps.edn:aliases keyshadow-cljs.edn, or does shadow run itself ‘under’ clojure:deps it will run via clojure:ci profile for that option:jvm-opts along from shadow-cljs.edn though:aliases {:jvm-opts ["-Xmx2G"]}npx shadow-cljs clj-run maria.build/release; shadow-cljs - config: /home/circleci/project/editor/shadow-cljs.edn version: 2.2.9 shadow-cljs - starting via "clojure"
:aliases {:ci {:jvm-opts ["-Xmx2G"]}} and shadow-cljs -A:ci{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cab9a2abaea5bde7a9a6a0b98af8e4f8e4fbfa"}, :content ("[email protected]")}package.json when the project updates its dependencies?deps.cljs :npm-deps. I believe it started doing that in the latest alphas.Use of undeclared Var re-frame.cofx/kind. The mentioned vars vary, but they all exist when I check. What could cause these warnings?
We don't need to (:require [some.thing]) in order to write some.thing/foo, do we?:require ensures that things get compiled in the correct order. without the require a namespace might be compiled before its dependency leading to those kinds of warnings:parallel-build true? Or is it something different?:external-config and :closure-defines are still probably needed.:external-config is dangerous with caching. handle with care. :closure-defines not needed if all you set is goog.DEBUG but otherwise yes:devtools/config and :dirac.runtime/config in :external-config. Should be fine, right?:dev {:external-config ...} so it doesn't apply to release builds:dev {:compiler-options {:external-config ...}}.dirac work. In project.clj I have :repl-options {:init (do (require 'dirac.agent) (dirac.agent/boot!))}. Is it possible to have something like that with shadow-cljs?
I found this in the documentation: "When enabled the watch will also hot-reload your code and provide a REPL." However, the link on "enabled" just goes to "Development Options" section that doesn't say anything about REPL.pom.xml each time shadow-cljs.edn is changed)
3. I won't be able to use Leiningen plugins (e.g. lein-environ) and tools (e.g. lein ancient)dirac prints out something interesting:
[3:0]~shadow.user=> (dirac.agent/boot!)
#object[clojure.core$future_call$reify__8097 0x79c9b171 {:status :pending, :val nil}]
[3:0]~shadow.user=> -----------------------------------------------------------------------------------------------------------
[3:0]~shadow.user=> WARNING!
We detected unexpected middleware setup in your nREPL server at !
The difference (clojure.data/diff expected-ops reported-ops) is:
[nil
[nil nil nil nil nil nil nil nil nil nil :cljs/select]
[:clone
:close
:describe
:dirac-devtools-request
:eval
:identify-dirac-nrepl-middleware
:interrupt
:load-file
:ls-sessions
:stdin]]
For reference, the reported versions by the nREPL server are:
{:clojure "1.9.0", :java "1.8.0_151", :nrepl "0.2.13"}
This usually happens when some extra middleware gets injected into your nREPL server behind your back.
e.g. * Didn't you include a middleware via ~/.lein/profiles.clj or BOOT_HOME/boot.properties?
* Or maybe using Cider's nREPL stuff?
* Or maybe using some combination of ancient Clojure/Java versions?
* Or some bleeding-edge alpha versions?
* Or a rogue tools.nrepl dependency in your project or its dependencies?
Please follow Dirac installation instructions: .
-----------------------------------------------------------------------------------------------------------
I guess shadow-cljs injects :cljs/select, right?(dirac.agent/boot! {:skip-dirac-nrepl-middleware-check true}) or something like that:browser vs :node-script[org.clojure/clojurescript "1.10.145"] thats the version now used by shadow-cljs. if you want to continue using 946 you must downgrade the closure compilerWarning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See for more details.How do you include React in your builds? Right now it's just in my
package.json under dependencies..nrepl-port at the root directory..nrepl-port then it becomes my problem if that interferes with lein.[2018-03-15 22:55:34 - SEVERE] spark/util/mongoose-types/lib/plugins/useTimestamps.js:1: ERROR - Invalid module path "goog:shadow.js.shim.module$mongoose" for resolution mode "BROWSER"
var mongoose = require('goog:shadow.js.shim.module$mongoose')
this is supposed to be a :node-script, but this error says ‘resolution mode “BROWSER”’BROWSER is the resolution mode for the closure compiler, we always use that since the others are just flat out broken.js files with shadow-cljs?node_modules?["./util/mongoose-types" :as mongoose-types], and then in ./util/mongoose-types/ it requires other stuffvar mongoose = require('mongoose') which shadow-cljs replaces with the goog:shadow.js.shim.module$mongoosevar mongoose = shadow.js.shim.module$mongoose so all is good in the worldgoog: partimport mongoose from "mongoose" should work just finenodejs/require, using js/__dirname and relative paths:output-to folderjs/require they won't get copied from the source paths:skip-paranoid-middleware-setup-check.(require '[cljs.repl]) leads to the same error. But running (require '[cljs.core]) is just fine.
Removing all shadow-cljs lines from :init and :nrepl-middleware solves the issue.
Do you have any idea on why it might be happening?cljs.repl? why require cljs.core? does requiring your code work?cemerick.piggieback/*cljs-compiler-env* binding is set in the session{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e3908b82878c94ce808f8990a3d1cdd1cdd2d2"}, :content ("[email protected]")} which should fix your issue from yesterday. the require('mongoose') thing.ns-a with a hello-a function signature
* ns-b with a hello-b function signature
Can I have a build, that releases this as a library usable both from the browser and on the server (nodejs)?
Also another question - say that one of these functions (`hello-a` for example) needs a slighty different implementation (for example a different socket client for a browser and nodejs), but after production release I still want the user to be able to just do:
(:require my-lib.ns-a :refer [hello-a])and get the right implementation regardless of where she is running the code. Ideally without increasing the bundle size (so either without programmatically detecting the process, or by dead code elimination)? In the end:
(defn hello-a [] (if process.browser "Hello from browser" "Hello from node"))should become in the browser
function hello-a () {return "Hello from browser"}
and when required in nodejs env it becomes:
function hello-a () {return "Hello from node"}goog-define which works with DCE and should do what you wantThe required namespace "p5.core" is not available, it was required by "play_cljs/core.cljs".. I tried npm install p5 which did update my package.json --- however cljs-play uses foreign libs ( https://github.com/oakes/play-cljs/blob/7fa4c33cf1cb734985366e8bdca1d7ed78546715/src/deps.cljs ) that I'm unable to satisfy using npm install p5 Any tips?clj-run is a good solution. there is nothing built-in for this (yet).foreign-libs an extra shim file is required. they look like this https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/d3.cljs(ns p5.core (:require ["p5" :as p5])) (js/goog.exportSymbol "p5" p5). basically all they to is load the package properly from npm and export the global name that cljsjs would otherwise createweb3.js into .node_modules files don't go through :advanced, so you don't need externs.(defn ^:on-jsload some-hook [] ...). I think you already have some special metadata in figwheel to do this stuff.:before-load, :before-load-async and :after-load to hook into the respective points in the reload cycle:defs(for [[ns info] (::ana/namespaces compiler-env)
:let [{:keys [defs]} info]
{:keys [name meta] :as def} defs
:when (:on-jsload meta)]
[ns name]):advanced. don't want that for dev code:fighwheel-always and things already:on-jsload?(.close srv) and immediately continued with live-reloading:before-load demo.script/stop in this case but (defn ^:dev/before-load-async stop [done] ...) would be neat:http-handler shadow.http.push-state/handle push-state is now the default so you can leave that out too 🙂:figwheel-always and :figwheel-noload on the ns name. do you support other metadata currently? and what exactly does :figwheel-always do? just always load it even if it wasn't compiled?:figwheel-always is to reload the ns on every code change:figwheel-noload is to not load on code change:figwheel-load is to load regardless of whether it is in the dependency chain or not:figwheel-noload I added already https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/worker/impl.clj#L137-L139:dev/never-loadThe required JS dependency "/assets/p5.tiledmap.js" is not available, it was required by "p5/tiled_map.cljs". Now, p5.tiledmap isn't in npm. I'm trying to require it by using the file locally, but can't quite get all the dots connected.require('../p5') is incorrect. it should be require('p5')(:require ["/abs/path/p5.tiledmap.js"]) like you were trying?require("./p5") (ie. minus one dot) https://github.com/oakes/play-cljs/blob/master/src/js/p5.tiledmap.js#L5(:require ["/js/p5.tiledmap"]) in the shim file((nil . ((projectile-project-type . lein-test)
(eval . (progn
(require 'cider)
(add-to-list 'cider-cljs-repl-types '("Shadow CLJS" "(do (shadow.cljs.devtools.server/start!) (shadow.cljs.devtools.api/watch :app) (shadow.cljs.devtools.api/nrepl-select :app))" nil))
(setq projectile-create-missing-test-files t))))))
This will make it possible to start up your cljs-repl again from emacslein right?lein would be neat since I have more control over the setup then:node-library or :node-script work for that. see https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library:npm-module also works:node-script but :npm-module is slight more flexible but also more complexnpm publish:cljsbuild. I suppose one could force fetching of that dependency via :npm-deps or lein-npm plugin, :notify or some other mechanism?cljs.corenpm is only useful if you want your code to be consumable from JS[com.google.javascript/closure-compiler-unshaded "v20180101"] explicitly in my deps. I’ve made no recent changes that should affect this. Any ideas?rm -rf .shadow-cljs/builds fixed it[:public] Build failure: FileNotFoundException: public/js/module-loader.json (No such file or directory)
public/js by handException in thread "async-thread-macro-12" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__59202 at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21) at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21) at clojure.lang.PersistentVector.reduce(PersistentVector.java:341) at clojure.core$reduce.invokeStatic(core.clj:6747) at clojure.core$reduce.invoke(core.clj:6730) at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45) at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63) at shadow.cljs.devtools.server.reload_classpath$start$fn__59234.invoke(reload_classpath.clj:92) at clojure.core.async$thread_call$fn__8239.invoke(async.clj:442) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
11:38:40.868 [nREPL-worker-0] WARN shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/sha256.js
[{:line 11, :column 9, :message "'identifier' expected"}] { }
11:38:40.875 [nREPL-worker-0] WARN shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/md5.js
[{:line 9, :column 9, :message "'identifier' expected"}] { }
11:38:40.877 [nREPL-worker-0] WARN shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/sha1.js
[{:line 9, :column 9, :message "'identifier' expected"}] { }
11:38:41.633 [nREPL-worker-0] WARN shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/doo/doo/0.1.8/doo-0.1.8.jar!/runners/nashorn.js
[{:line 21, :column 39, :message "Semi-colon expected"}] { }
11:38:42.192 [nREPL-worker-0] WARN shadow.build.classpath - failed to parse javascript file: jar:file:/usr/lib/jvm/java-8-openjdk/lib/tools.jar!/com/sun/tools/hat/resources/hat.js
(shadow-server/stop!)
shutting down ...
JS runtime disconnected.
Worker shutdown.
11:45:10.423 [nREPL-worker-2] WARN shadow.cljs.devtools.server - shutdown failed ((rt/stop-all app)) { }
java.lang.ThreadDeath: null
at java.lang.Thread.stop(Thread.java:853)
at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__62024.invoke(interruptible_eval.clj:243)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at user$eval74385$fn__74386$fn__74388.invoke(form-init5239952018706589785.clj:1)
at shadow.cljs.devtools.server.nrepl$cljs_eval$fn__62323.invoke(nrepl.clj:171)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.load_file$wrap_load_file$fn__62170.invoke(load_file.clj:79)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at shadow.cljs.devtools.server.nrepl$cljs_load_file$fn__62334.invoke(nrepl.clj:192)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.session$add_stdin$fn__62099.invoke(session.clj:238)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_debug$fn__70069.invoke(nrepl.clj:161)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_enlighten$fn__70077.invoke(nrepl.clj:187)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_macroexpand$fn__70111.invoke(nrepl.clj:264)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cemerick.piggieback$wrap_cljs_repl$fn__62286.invoke(fake_piggieback.clj:31)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_inspect$fn__70103.invoke(nrepl.clj:224)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_out$fn__70127.invoke(nrepl.clj:305)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_pprint$fn__70035.invoke(nrepl.clj:107)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_tracker$fn__70191.invoke(nrepl.clj:450)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at shadow.cljs.devtools.server.nrepl$cljs_select$fn__62315.invoke(nrepl.clj:153)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.pr_values$pr_values$fn__61940.invoke(pr_values.clj:22)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl$wrap_test$fn__70175.invoke(nrepl.clj:415)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at cider.nrepl.middleware.pprint$handle_pprint_fn.invokeStatic(pprint.clj:49)
at cider.nrepl.middleware.pprint$handle_pprint_fn.invoke(pprint.clj:44)
at clojure.lang.Var.invoke(Var.java:385)
at cider.nrepl$wrap_pprint_fn$fn__70025.invoke(nrepl.clj:88)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at clojure.tools.nrepl.middleware.session$session$fn__62084.invoke(session.clj:192)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
at clojure.tools.nrepl.server$handle$fn__62185.invoke(server.clj:28)
at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
stop!?(shadow/watch :app) but it wasn't recompilingreload! insteadException in thread "async-thread-macro-15" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__59438 at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21) at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21) at clojure.lang.PersistentVector.reduce(PersistentVector.java:341) at clojure.core$reduce.invokeStatic(core.clj:6747) at clojure.core$reduce.invoke(core.clj:6730) at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45) at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63) at shadow.cljs.devtools.server.reload_classpath$start$fn__59470.invoke(reload_classpath.clj:92) at clojure.core.async$thread_call$fn__8239.invoke(async.clj:442) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
[org.clojure/clojurescript "1.10.145" :classifier "slim"]lein clean as usual. doesn't affect shadow-cljs but I don't know what lein may have done(shadow/watch :app)(do (shadow.cljs.devtools.server/start!) (shadow.cljs.devtools.api/watch :app) (shadow.cljs.devtools.api/nrepl-select :app))
(shadow.cljs.devtools.server/stop!) and then the start above again?cljs.user> :cljs/quit :cljs/quit user> (shadow-server/reload!) Worker shutdown. shadow-cljs - HTTP server for :devcards available at :shadow.cljs.devtools.server/restarted user> Exception in thread "async-thread-macro-4" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__65735 at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21) at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21) at clojure.lang.PersistentVector.reduce(PersistentVector.java:341) at clojure.core$reduce.invokeStatic(core.clj:6747) at clojure.core$reduce.invoke(core.clj:6730) at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45) at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75) at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63) at shadow.cljs.devtools.server.reload_classpath$start$fn__65767.invoke(reload_classpath.clj:92) at clojure.core.async$thread_call$fn__9069.invoke(async.clj:442) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
tools.namespace?golein clean for safetylein deps treethread macro hasn't changed in forever so that shouldn't matter*ns* binding which is a bit scarystop! or reload! first?NoClassDefFoundError. clojure is supposed to create the class before loading it.set-refesh-dirs(set-refresh-dirs "dev/server" "src/main" "test" "src/cards")from
[clojure.tools.namespace.repl :as tools-ns :refer [set-refresh-dirs]]
set-refresh-dirs was there because figwheel would copy cljc files into resources, and then server refresh will accidentally find them and cause problems. Shadow doesn’t do that, so it probably isn’t helping anything.java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__60601__60605$fn__60606$fn__60607$fn__60609:devtools {:http-root "public"
:http-port 8088
;; :http-handler dev.server/handler
:after-load visitor.main/init}
this is my current project, the after load would be my react init function."devDependencies": {
"shadow-cljs": "^2.0.115"
}
yup too old I think 🙂public/js and configure your server to serve static files from public you are all setresources/public/js if you want to serve resources instead of filesshadow-cljs automated externs inference. Shadow-cljs will give you warnings when it can’t figure things out and you can just provide a type hint. Because shadow processes all of your JavaScript libraries, Shadow can infer externs from them, which is a real advantage over some other approaches relying on the built-in compiler’s extern inference.:http-handler push-state is the default now so you can remove that as well:after-load symbol, this is what shadow-cljs will call after hot reloading code finishes.(ns demo.bar (:require ["./foo" :as foo])) would load demo/foo.js from the classpathimport cljs from "goog:cljs.core"; cljs.assoc(nil, "foo", 1)(ns demo.bar (:require ["./foo" :as foo])) would load demo/foo.js from the classpath. [This is experimental.](https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js)
* It also allows interop in the other direction, [by embedding cljs in an existing JavaScript app](https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module).npm-module isn't related to that, { keyword } this doesn't work anymore with the latest closure compilercljs.keyword but the direct refer was broken by them 😞(ns starter.browser
(:require [rum.core :as rum]
[react-native-web :as react-native :refer (View Text)]))
(rum/defc hello-world []
[:div
[Text "hello there"]
[:h3 {:style {:color "blue"}} "Edit this and watch it change!"]])
Text element(def Text (r/adapt-react-class Text))
(defn app []
[:div
[Text {:style {:color "blue" :font-size "40px"}} "hello"]npx shadow-cljs clj-repl[:app] Build failure: The required namespace "starter.browser" is not available. [2018-03-22 13:31:05 - WARNING] stale websocket client, please reload client :app [2018-03-22 13:31:23 - WARNING] stale websocket client, please reload client :app [2018-03-22 13:31:40 - WARNING] stale websocket client, please reload client :app
[Text .... inside the Rum one was throwing a warning in the console. But it was still renderingThe required namespace "starter.browser" is not available. is it possible your ns form is busted?(:require ["react" :refer (createElement)]) then (createElement Text #js {:foo "bar"} ...)shadow-cljs watch session?The required namespace "starter.browser" is not available. like this?The required namespace "permafrost.api" is not available, it was required by "permafrost/health.cljs".src/permafrost/api.cljs directly next to src/permafrost/health.cljs?» ll src/cljs/permafrost/api.clj src/cljs/permafrost/health.cljs 09:32:53 Permissions Size User Group Date Modified Name .rw-r--r-- 704 sundbp staff 22 Mar 9:28 src/cljs/permafrost/api.clj .rw-r--r-- 1.6Ki sundbp staff 22 Mar 9:21 src/cljs/permafrost/health.cljs
.clj file[:pf] Build failure: The required namespace "permafrost.api" is not available, it was required by "permafrost/health.cljs". [:pf] Compiling ... [:pf] Build completed. (168 files, 59 compiled, 0 warnings, 42.48s)
[:browser] Build failure: The required namespace "demo.run-test" is not available, it was required by "demo/browser.cljs". "demo/run_test.clj" was found on the classpath. Should this be a .cljs file?
Rum will call sablono.compiler/compile-html in its macro. You could add a sablono.compiler namespace (a .clj file) into your project and create a compile-html function which calls Hicada with the config you like. This namespace will take precedence over any CLJ namespace on your classpath.
(html/div
(html-section-header (name build-id))
(html/div
(html/button
{:onClick #(conv/transact! this (watch-start! build-id))
:disabled (any? worker)}
"watch start")
(html/button
{:onClick #(conv/transact! this (watch-stop! build-id))
:disabled (nil? worker)}
"watch stop")
(html/button {:onClick #(conv/transact! this (db/compile! build-id))} "compile")
(html/button {:onClick #(conv/transact! this (db/release! build-id))} "release"))
(html/pre {:ref (::dom-ref this)}
(with-out-str
(pprint data))))View Text TouchableOpacity etc(rn/view ...) (rn/text ...) wrapperException: No namespace: sablono.core found
clojure.core/the-ns (core.clj:4128)
clojure.core/ns-publics (core.clj:4155)
clojure.core/ns-publics (core.clj:4155)
shadow.build.macros/find-macros-in-ns (macros.clj:32)
shadow.build.macros/find-macros-in-ns (macros.clj:30)npx shadow-cljs release my-app and then have it copy your :output-dir to wherever?public/jspublic/css and so onpublic folder and you are done?npx shadow-cljs release your-build is all you'd need to run(:require [shadow.markup.react :as html :refer ($)] ["react-native" :as rn :refer (Text View)]) then in render ($ Text {:style style-obj} "hello world")$ is just sugar for calling createElement directlyshadow.markup.react-native :as rn then (rn/text {:style ...} "foo") would just workView for one codebase and Div for the other when it's exactly the same thing visually.react-native-web works if there code example doesn't have a single reference to react-native-web(ns starter.core
(:require [reagent.core :as r]
[react-native-web :as react-native :refer (Text View)]))
(def Text (r/adapt-react-class Text))
(def View (r/adapt-react-class View))
(defn app []
[:div
[View {:style {:background-color "red" :height "100px" :width "100px"}
:accessibility-role "main"}
[Text {:style {:color "blue" :font-size "40px"}} "hello"]].....["react-native" :as react-native :refer (Text View)]:js-options {:resolve {"react-native" {:target :npm :require "react-native-web"}}} 😉["react-native" :as react-native :refer (Text View)] to ["react-native-web" :as react-native :refer (Text View)]clj-run is only meant to call clojure core directly. not as part of a build or anything.#20 has the code I am referring to.ns doesn't tell me enough to figure it out[Text ...] as something[:> NativeThing ...]. maybe sablono does too?adapt-react-class which Rum doesn't have as a utility built in.:lein true in shadow-cljs.edn and then I run lein run -m shadow.cljs.devtools.cli compile and I’m getting class not found….:source-paths you have configured:source-paths configured. those need to be configured in shadow-cljs.edn as well[:> foo] notation for Reagent component creation?GET net::ERR_ABORTEDreact-avatar-editor doesn't depend on lodashnet::ERR_ABORTED thing.node_modules directory is messed up. npm does that frequently..shadow-cljs/builds directorycleanpublic/js/cljs-runtime/lodash.debounce to verify that it works and it works just finemodule$node_modules$lodash_debounce$index.js thats missing for youNET_ABORTED. that is usually caused by some browser extension.binaryage/devtools and piggieback. how does shadowcljs handle this scenario?:dependencies on the classpath does not affect what a build does.shadow-cljs release will use their proper release version so the warning will go away thenlein integration…NaN instead of js/NaN[funcool/cuerdas "2.0.5"] to your deps:js-options {:resolve {"react" {:target :npm :require "preact"}}}react-dompreact/compact or so? might need to use thatresolve: {
alias: {
'react': 'preact-compat',
'react-dom': 'preact-compat',
// Not necessary unless you consume a module using `createClass`
'create-react-class': 'preact-compat/lib/create-react-class'
}
}:js-options
{:resolve
{"react" {:target :npm :require "preact-compat"}
"react-dom" {:target :npm :require "preact-compat"}}}:resolve currently invalidates the cache:resolve in the cache code for thisforceUpdatecreate-react-class?:js-options
{:resolve
{"react" {:target :npm :require "preact-compat"}
"react-dom" {:target :npm :require "preact-compat"}
"create-react-class" {:target :npm :require "preact-compat/lib/create-react-class"}}}(cljs :optimizations :advanced
:compiler-options {:output-wrapper true
:pseudo-names true
:pretty-print true}):pseudo-names true :pretty-print true
shadow-cljs release app --debug should be equivalent to that boot-cljs config:simple removing the conditional and only leaving one of the requires:js-options {:resolve {"react" {:target :npm :require "inferno-compat"}
"react-dom" {:target :npm :require "inferno-compat"}
"create-react-class" {:target :npm :require "inferno-create-class"}}}React.createClass to whatever create-react-class returnedinferno-create-class iscljsjs/react.cljs file in your project(ns cljsjs.react (:require ["react" :as react])) (js/goog.exportSymbol "React" react)
inferno-compat already provides the React.createClasssrc-cljs then src-cljs/cljsjs/react.cljs yesUncaught TypeError: reagent.impl.util.create_class.call is not a function
inferno-create-class does not export a function it exports inferno-create-class/createClass:resolve trick won't work since that differs from what create-react-class exportsinferno-create-class-compat packagemodule.exports = require("inferno-create-class").createClass;shadow-cljs server start never returns and it doesn’t seem to finish a compile or recompile. if i kill that and do a single build, that works. i’ve already blown away .shadow-cljs but i’m not sure where else there may be state lurkingserver start does not returnrelease------ WARNING #1 -------------------------------------------------------------- File: cljs/core.cljs:37412:13 variable Java is undeclared --------------------------------------------------------------------------------
with-redefs. Instead of generated code calling functions like this:
fulcro.ui.forms.form_reduce.call(null,root_form,...)shadow is generating:
fulcro.ui.forms.form_reduce.cljs$core$IFn$_invoke$arity$3(root_form,...Then the use of
with-redefs redefines fulcro.ui.forms.form_reduce to a function, and we end up with errors like this:
fulcro.ui.forms.form_reduce.cljs$core$IFn$_invoke$arity$3 is not a function
I can see that this looks like an optimization, but it definitely breaks code that has been working against clj and cljs for years. Seems to me it generally breaks cljs with-redefs:static-fns true. can you trying compiling with :compiler-options {:static-fns false}?(ns your.build
(:require
[shadow.cljs.devtools.api :as shadow]
[clojure.edn :as edn]
[clojure.string :as str]))
(defn release []
(shadow/release :your-build)
(let [manifest
(-> (slurp "public/js/manifest.edn")
(edn/read-string))
index-src
(slurp "public/index.html.src")
index
(reduce
(fn [index-src {:keys [module-id output-name]}]
(let [marker (str (name module-id) ".js")]
(str/replace index-src marker output-name)))
index-src
manifest)]
(spit "public/index.html" index)))(shadow/watch (keyword build-id) where build-id is provided as a string from the clishadow-cljs clj-run your.build/releasepublic/index.html.src replaces <srcipt src="/js/main.js"> with <srcipt src="/js/main.<the-hash>.js">shadow-cljs … oh waitshadow/release eh?shadow-cljs release your-build just from the clojure apishadow-cljs release prod, and in that release hook templating would take placeremote: > shadow-cljs start && shadow-cljs clj-run build.build/release && webpack -p; remote: remote: shadow-cljs - config: /tmp/build_248d245eeae37c14789671b54890ae63/_spark-spa/shadow-cljs.edn version: 2.2.14 remote: shadow-cljs - server starting .events.js:160 remote: throw er; // Unhandled 'error' event remote: ^ remote: remote: Error: spawn clojure ENOENT remote: at exports._errnoException (util.js:1026:11) remote: at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32) remote: at onErrorNT (internal/child_process.js:348:16) remote: at _combinedTickCallback (internal/process/next_tick.js:74:11) remote: at process._tickCallback (internal/process/next_tick.js:98:9) remote: at Module.runMain (module.js:592:11) remote: at run (bootstrap_node.js:394:7) remote: at startup (bootstrap_node.js:149:9) remote: at bootstrap_node.js:509:3 remote: npm ERR! code ELIFECYCLE remote: npm ERR! errno 1(I switched to
shadow-cljs start && shadow-cljs release... because shadow-cljs release... doesn’t fail, it just prints “starting with clojure” and then heroku silently moves on to the next process and nothing is compiled)clojure maybe isn't on the path?heroku/node buildpack after the heroku/jvm buildpack: curl -O && chmod +x linux-install-1.9.0.358.sh && ./linux-install-1.9.0.358.sh -p $(pwd)/.heroku/node(devtools.api/watch build-id) to work, and it seems like there’s some stateful dependencies in an existing runtime?assert failed (map? http), which if you backtrack quite a bit seems to be coming from an existing supervisor who has some http config. i’m not sure if there’s an alternative way I should be using the clj-run api or not, but this doesn’t seem to be correct 😕clj-run currently doesn't spin up a full server so watch doesn't workshadow-cljs server it should workwatchshadow.js.js:91 Uncaught ReferenceError: Buffer is not defined
at Object.shadow$provide.module$node_modules$buffer_from$index (index.js:5)
at shadow.js.jsRequire (shadow.js.js:88)Buffer is not defined error is to run the module through browserify, but I'm not sure how to integrate that with shadow-cljs.pouchdb-adapter-memory add an extra require for a (ns bugfix.buffer (:require ["buffer" :as buffer])) (js/goog.exportSymbol "Buffer" buffer)import bufferFrom from 'buffer-from'; // ponyfill for Node <6bugfix.buffer (or whichever ns you use for this) before the pouchdb thing it should work:repl-options {:init (do
(require 'dirac.agent)
(dirac.agent/boot!))}
source: https://github.com/binaryage/dirac/blob/master/docs/installation.md
is there an option like that available in shadow-cljs?clj-runclj cli tools into nixOs so I can use them later today. So I'll continue with the devtools quest tomorrow. Thanks thheller!2.1.18 makes it generate warnings instead of breakingcljs.repl ns requiring cljs.closure(require 'cljs.closure) to verify this in a clojure REPL[org.clojure/clojurescript "1.10.145"]cljs.closure namespace but that had other issuesshadow.process is the cause. don't know why that wouldn't exist though. maybe cache issue?rm -rf .shadow-cljs/buildsgoog.addDependency for shadow.js and shadow.processshadow.process wouldn't exist since it shouldn't even compile if it can't find itshadow-cljs - nrepl running at localhost/127.0.0.1:8202, which makes me think I need to manually configure it to actually start an nrepl?:nrepl {:port 9000}. i know thomas has been reluctant to use lein’s nrepl port file.nrepl-port is generated when it doesn't exist and the nrepl port is also always printed in the latest version(require '["auth0-js" :default auth0]). auth0 is nil after the require
import auth0 from 'auth0-js';
export default class Auth {
auth0 = new auth0.WebAuth({
:as and inspect the objectstr/blank? after require’ing clojure.string, etc. It threw me a little with this because I wasn’t sure the require itself was workingThere is no connected JS runtime.. Please help!(shadow.cljs.devtools.api/nrepl-select :browser) => [:no-client :browser "Please load your JS to connect to the REPL."]
shadow-cljs watch app
results in
shadow-cljs - config: /Users.......vc/shadow-cljs.edn version: 2.1.6 shadow-cljs - socket connect failed, server process dead?
.shadow-cljs/*.port. 2.2.18 which I released today handles such crashed more gracefully.lein and want to use a remote nREPL you need to configure the shadow-cljs middleware. https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_servershadow.cljs.devtools.api. calling (shadow.clsj.devtools.api/compile :foo) is identical to shadow-cljs compile foo. same for watch and release.2.2.18 fixed itwatch via clj-run. https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run since 2.2.19:optimizations :simple compiler flag. In release mode, some of its functions work, except for one. I'm wondering what's going on and how best to troubleshoot. I can live with :simple optimizations, but I'm curious what's causing the problem.Uncaught TypeError: b.wb is not a function:infer-extern :auto set? https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs(.prepare db "SELECT * FROM myTable WHERE MainID=? AND SubID=? AND ProtocolID=?;")(.exec db) works, but not (.prepare db)b.wb is not a function is because something you are calling in clojurescript is getting munged. try this : (.prepare ^js db "SELECT * FROM myTable WHERE MainID=? AND SubID=? AND ProtocolID=?;")prepare symbol from being munged(def sql (js/require "sql.js")) is also how I'm loading the library.(def sql (js/require "sql.js"))
(def fs (js/require "fs"))
(defn testDB []
(let [dbPath "/my/db/path"
fb (.readFileSync ^js fs dbPath)
db (new (.-Database ^js sql) fb)
stmt (.prepare ^js db "SELECT * FROM tblTreatment WHERE MainID=? AND SubID=? AND ProtocolID=?;")
_ (.bind ^js stmt (clj->js [1 1 1]))
_ (.step ^js stmt)
row (js->clj (.getAsObject ^js stmt))
_ (println "ROW: " row)
]))
(js/require ...) for anything or half the inference won't work(ns the.thing (:require ["fs" :as fs])) and treat it like any other namespace. eg. (fs/readFileSync ...) instead of (.readFileSync fs ...):browser things are handled entirely differently that is correct. you can however set :js-options {:js-provider :require} in your build. then they are handled exactly like :node-script[com.google.javascript/closure-compiler-unshaded "v20180101"] (to avoid that nasty bug, https://github.com/google/closure-compiler/issues/2822) I am getting:
[:browser] Compiling ...
[2018-03-27 14:51:57 - WARNING] Skipping pass rewriteScriptsToEs6Modules
[2018-03-27 14:52:05 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES
at cljs.closure__init.load(Unknown Source)
at cljs.closure__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2204)
at clojure.lang.RT.classForName(RT.java:2213)
at clojure.lang.RT.loadClassForName(RT.java:2232)
at clojure.lang.RT.load(RT.java:450)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6548.invoke(core.clj:6046)
at clojure.core$load.invokeStatic(core.clj:6045)
at clojure.core$load.doInvoke(core.clj:6029)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5848)
at clojure.core$load_one.invoke(core.clj:5843)
at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
at clojure.core$load_lib.invokeStatic(core.clj:5887)
at clojure.core$load_lib.doInvoke(core.clj:5868)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$load_libs.invokeStatic(core.clj:5925)
at clojure.core$load_libs.doInvoke(core.clj:5909)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$require.invokeStatic(core.clj:5947)
at clojure.core$require.doInvoke(core.clj:5947)
at clojure.lang.RestFn.invoke(RestFn.java:2088)
at cljs.repl$loading__5569__auto____6019.invoke(repl.cljc:9)
devtools.api/watch:
Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:103)
at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:103)
at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:27)
at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:18)
at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:85)
at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:76)
at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:102)
at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:92)
at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
at web3.build.build$watch.invokeStatic(build.clj:57)
at web3.build.build$watch.invoke(build.clj:49)
at web3.build.build$watch.invokeStatic(build.clj:52)
at web3.build.build$watch.invoke(build.clj:49)
[org.clojure/clojurescript "1.10.145" :exclusions [com.google.javascript/closure-compiler-unshaded]], but then I get the java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES error againcljs.closure. why are you pinning a specific closure version again?:shadow/requires-server thing without the latest clojure version(def warning-types ...)cljs.closure at all .. problem is that cljs.repl imports it though{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a2d1cac3c6cdd58fc1cec8d1e2908c908c9092"}, :content ("[email protected]")}. should use the latest cljs version and hopefully let you use the closure v20180101watch command which first compiles the necessary static assets (hiccup->html, garden->css) and then starts the shadow watch processError: Could not find or load main class clojure.main error when following the doco, there's obviously something that I've missed{:source-paths ["src"]
:dependencies []
:builds {:server {:target :node-script
:main server.main/main!
:output-to "target/main.js"}}}
(ns server.main
(defn main! [& cli-args]
(prn "hello world"))
shadow-cljs compile server, and shadow-cljs -v returns: shadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20npx shadow-cljs clj-repl? the error looks like there is no clojure on the classpath which is very weirdshadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20 shadow-cljs - starting ... Error: Could not find or load main class clojure.main
npm install -g shadow-cljs.shadow-cljs/classpath.edn and try the above again?shadow-cljs --cli-info should also print some useful info.shadow-cljs/classpath.edn partshadow-cljs --cli-info (before deleting anything)shadow-cljs -d org.clojure/tools.nrepl:0.2.13 -d cider/cider-nrepl:0.17.0-SNAPSHOT serverthe -d options does not seem to work when
:lein true is enabled is this expected?.shadow-cljs directory but not ~/.m2?COPY . /var/appException in thread "main" java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType, compiling:(shadow/build/cljs_closure.clj:3:1)Did a --cli-info everything looks right
=== Version cli: 2.2.20 jar-version: 2.2.20 config-version: 2.2.20
shadow-cljs.edn 😞--cli-info?MacBook-Pro:fm-ng-ui ericholiphant$ shadow-cljs --cli-info shadow-cljs - config: /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn version: 2.2.20 === Version cli: 2.2.20 jar-version: 2.2.20 config-version: 2.2.20 === Paths cli: /Users/ericholiphant/projects/fm-ng-ui/node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.cli.js config: /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn project: /Users/ericholiphant/projects/fm-ng-ui cache: .shadow-cljs === Java java version "1.8.0_152" Java(TM) SE Runtime Environment (build 1.8.0_152-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode) === Source Paths === Dependencies cache-file: /Users/ericholiphant/projects/fm-ng-ui/.shadow-cljs/classpath.edn
lein?npx shadow-cljs ....1.10.238 ... the shadow.build.cljs-closure ns was added today to work around a different problem with CLJS+Closurelein command line to inject stuff? can't find itupdate-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[refactor-nrepl\ \"2.4.0-SNAPSHOT\"\]
lein? not really worth pretending to use shadow-cljs which then just delegates to lein["moment" :as Moment]
and give it a timestamp
(str (Moment "2018-10-03 18:48:05.123")) produces nicely human readable date
but after compilation (guessing npm modules go trough :simple optimizations)
the timestamp becomes unix timestamp (ex. 1522141700340)
Someone else experienced something similar. Too busy tonight to open ticket, but can do so this weekend.v20180319 is now available on maven. will bump shadow-cljs later.shadow-cljs watch in production. Somehow build with optimizatioon :none gave me an error, wait I can send it...shadow-cljs release :admin ~/Documents/visitor
shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn version: 2.2.20
shadow-cljs - connected to server
[:admin] Compiling ...
optimizations set to :none, can't optimize
{}
ExceptionInfo: optimizations set to :none, can't optimize
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.closure/optimize (closure.clj:1081)
shadow.build.closure/optimize (closure.clj:1074)
shadow.build.api/optimize (api.clj:182)
shadow.build.api/optimize (api.clj:176)
shadow.build/optimize (build.clj:318)
shadow.build/optimize (build.clj:310)
:none is not an optmization setting .. its literally just compile:js-options {:optimizations :whitespace} to switch it from :simple(:require ["react-quill" :as Quill])
(defn component []
(let [quill-ref (atom nil)]
(r/create-class
{:reagent-render
(fn [] [:> Quill {:default-value ""
:ref (fn [el] (reset! quill-ref el))
:modules {:toolbar {:container [[{:header [1 2 3 4 5 false]}]
["bold" "italic" "underline" "strike" "blockquote"]
[{:list "ordered"} {:list "bullet"} {:indent "-1"} {:indent "+1"}]
["link" "image"]
["clean"]]
:handlers {:image (fn [_]
(let [editor (.getEditor @quill-ref)
selection (.getSelection editor)]
(.insertEmbed editor
selection.index "image"
(js/window.prompt "Please provide an image url")
"user")))}}}}])})))
headily elided, when clicking the image logo on the editor to provide img url, will work in :non the error otherwise is
admin.cljs:429 Uncaught TypeError: b.fi is not a function
at b.<anonymous> (admin.cljs:429)
at HTMLButtonElement.<anonymous> (quill.js:9393)
(anonymous) @ admin.cljs:429
(anonymous) @ quill.js:9393
For line number comparison then I'm running Quill Editor v1.3.6 one minor version above that which is declared in react-quill, same behaviour is in v1.3.5..inserEmbed editorcom.google.javascript/closure-compiler-unshaded "v20180319" the closure versionwatch? or release only?shadow-cljs release the-build --debug?b.fi is.:infer-externs :auto?:compiler-options {:infer-externs :auto} if you run into any issues--debug only gave me warnings about transit and nashorn431 | (.insertEmbed editor ---------------------------------------------------------------------------^---- Cannot infer target type in expression (. editor insertEmbed selection.index "image" (js/window.prompt "Hvað er URL á myndina?") "user")excuse the foreign language used there 🙂
^js editor (.getEditor @quill-ref)editor is a JS object and nothing that uses it should be renamed^js?^js is a standard CLJS thing for tagging a thing with a type^String:infer-externs :auto is on(ns atlas-crm.cards (:require .... namespaces with cards [devcards.core :as dc :refer-macros [start-devcard-ui!]])) (start-devcard-ui!) (defn refresh []) ;; Used for devcards live reload supportAnd a build like this:
:devcards {:target :browser
:asset-path "/js/devcards"
:output-dir "resources/public/js/devcards/"
:compiler-options {:devcards true :external-config {:fulcro.inspect/config {:launch-keystroke "ctrl-space"}}}
:modules {:devcards {:entries [atlas-crm.cards]}}
:devtools {:after-load atlas-crm.cards/refresh
:http-port 8600
:http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
:http-handler dev.test-handler/handler
:preloads [fulcro.inspect.preload]}}
(shadow.cljs.devtools.api/release-snapshot :the-build {}) then :compiler-options {:rename-prefix-namespace "App"}:modules:modules {:main {:entries ... :prepend "(function(){" :append "})();"}}<project-root>/externs/your-build.txt global:io should do it:stable-names supported?(.bind stmt) call, probably because it was in a let with no binding of its results (even though it returns nil). When I bound the result Closure let it through:
(let [db ^js (:db @state)
stmt (.prepare db "SELECT * ...")
bound? (.bind stmt ids)])
The sql.js namespace includes two JS "classes" (functions with prototype methods) of Database and Statement. I'm currently bringing them in as (ns my.app (:require ["sql.js" :as sql :refer [Database Statement]))
What's the best way to import them such that I can use them as namespaces like:
(let [ db ^Database (Database. dbBuffer) stmt ^Statement (db/prepare sqlStr) bound? (stmt/bind ids)])
sql.js your file or is it on npm?(:require ["sql.js" :as sql :refer [Database Statement])(ns my.app (:require ["sql.js" :as sql :refer [Database Statement])) that should work just fine?(let [db ^js (:db @state)
stmt (.prepare db "SELECT * ...")
_ (.bind stmt ids)]) ;; this call got elided
sql.js is a normal npm package so it gets treated like any other. so it goes through :simple. but simple can also remove code.:target :browser.js file requires *always* start with either / or ./. anything that does not start with those is a npm package.:js-options {:js-provider :require} but not :shadow:shadow only rewrites the whole npm stuff because the browser doesn't have access to require. electron does so its totally fine to do this..bind does not get removed with :require10:53:53.250 [XNIO-5 task-8] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /release-snapshots/app/latest request {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[nl-NL,nl;q=0.9,en-NL;q=0.8,en;q=0.7,en-US;q=0.6], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36], Connection=[keep-alive], Cookie=[_okbk=vi3%3Dinactive%2Ccd4%3Dtrue%2Cvi5%3D0%2Cvi4%3D1505836096585%2Cvi2%3Dfalse%2Cvi1%3Dfalse%2Ccd8%3Dchat%2Ccd6%3D0%2Ccd5%3Daway%2Ccd3%3Dfalse%2Ccd2%3D0%2Ccd1%3D0%2C; _ok=1700-237-10-3483; ring-session=1499777936043; _okdetect=%7B%22token%22%3A%2214837138200590%22%2C%22proto%22%3A%22http%3A%22%2C%22host%22%3A%22localhost%3A4040%22%7D; org.cups.sid=0ab9c463b9384ae47f668da6ac4cd702; olfsk=olfsk467559086084683; wcsid=bxjbgsCgQGydcOdD3m39N0N80JEr4BH2; _ga=GA1.1.1242069313.1495026997; hblid=BLdYcEe25b7HnC1K3m39NQDYCOR30OE6; _oklv=1505836580733%2CbxjbgsCgQGydcOdD3m39N0N80JEr4BH2], Upgrade-Insecure-Requests=[1], Host=[localhost:9630]} response {}} { }
java.lang.RuntimeException: Map literal must contain an even number of forms
at clojure.lang.Util.runtimeException(Util.java:221)
at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:682)
at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
at clojure.lang.EdnReader$VectorReader.invoke(EdnReader.java:672)
at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
at clojure.lang.EdnReader.read(EdnReader.java:145)
at clojure.lang.EdnReader.read(EdnReader.java:111)
at clojure.lang.EdnReader.readString(EdnReader.java:67)
at clojure.edn$read_string.invokeStatic(edn.clj:46)
at clojure.edn$read_string.invokeStatic(edn.clj:37)
at clojure.edn$read_string.invoke(edn.clj:37)
at shadow.cljs.devtools.server.web.release_snapshots$info_page.invokeStatic(release_snapshots.clj:41)
at shadow.cljs.devtools.server.web.release_snapshots$info_page.invoke(release_snapshots.clj:33)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at shadow.http.router$call_handler.invokeStatic(router.clj:12)
at shadow.http.router$call_handler.invoke(router.clj:11)
at shadow.cljs.devtools.server.web.release_snapshots$root.invokeStatic(release_snapshots.clj:55)
at shadow.cljs.devtools.server.web.release_snapshots$root.invoke(release_snapshots.clj:54)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at shadow.http.router$call_handler.invokeStatic(router.clj:12)
at shadow.http.router$call_handler.invoke(router.clj:11)
at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:160)
at shadow.cljs.devtools.server.web$root.invoke(web.clj:159)
at shadow.cljs.devtools.server$get_ring_handler$fn__56432.invoke(server.clj:60)
at ring.middleware.resource$wrap_resource$fn__14079.invoke(resource.clj:37)
at ring.middleware.resource$wrap_resource$fn__14079.invoke(resource.clj:37)
at ring.middleware.params$wrap_params$fn__14063.invoke(params.clj:67)
at shadow.cljs.devtools.server.ring_gzip$wrap_gzip$fn__56057.invoke(ring_gzip.clj:94)
at shadow.undertow$ring_STAR_$reify__56143.handleRequest(undertow.clj:27)
(shadow.cljs.devtools.api/release-snapshot :app {})*print-length*.shadow-cljs/release-snapshots/app/latest/bundle-info.edn probably contains elided forms(binding [*print-length* 0] (shadow.cljs.devtools.api/release-snapshot :app {}))If it is bound to logical false, there is no limit.:closure-defines {re-frame.trace/trace-enabled? true} in your build config:dev mode only:dev {:closure-defines {re-frame.trace/trace-enabled? true}}(require 'that.ns :reload):reload is ignored, will fix:reload is fixed in 2.2.21(require 'the.thing :reload):reload-all:reload-all doesn't work. will fix.rlwrap makes things more usable if you are on linux/macrlwrap just works:dependencies [:binaryage/oops "0.5.8"]:dependencies [[binaryage/oops "0.5.8"]]lein or bootshadow-cljs - server running at shadow-cljs - socket repl running at localhost:49898 shadow-cljs - nREPL server started on port 49900Damn, how many sockets does this open ?
Worker shutdown. mean that I have to restart the server process ?shadow-cljs node-repl?shadow-cljs node-repl again should work fine(ns rancher-cli.core
(:require
[cljs.nodejs :as nodejs]
[rancher-cli.request :as req]))
(ns rancher-cli.request
(:require [cljs.nodejs :as nodejs]
[request :as req]))
(require 'rancher-cli.core) on the replin-ns only works after requirerequire failed?[{:type clojure.lang.ExceptionInfo :message "failed to parse ns require"[request :as req], probably an error?request lurking in your root directory[1:1]~rancher-cli.core=> (require 'rancher-cli.core :reload)
[:result {:type :repl/error, :ex #error {
:cause "Circular dependency detected: rancher-cli.core -> rancher-cli.core"
:data {:tag :shadow.build.resolve/circular-dependency, :resource-id [:shadow.build.classpath/resource "rancher_cli/core.cljs"], :path [rancher-cli.core rancher-cli.core], :stack [[:shadow.build.classpath/resource "rancher_cli/core.cljs"]]}
I'm pretty sure I don't have circular deps, well, I had loaded that namespace with in-ns so maybe that was the problemzprint.main has (:gen-class) in its ns. this means it can't be loaded as CLJS. don't worry about it though unless you were actually planning on using that.[:browser] Build failure: The required namespace "cljsjs.react-highlight" is not available, it was required by "day8/re_frame_10x/view/components.cljs".This one seems to be a real error.
The required namespace "mranderson047.reagent.v0v8v0_alpha2.reagent.core" is not available, it was required by "day8/re_frame_10x/view/event.cljs". "mranderson047/reagent/v0v8v0_alpha2/reagent/core.clj" was found on the classpath. Should this be a .cljs file?There is a clj and a cljs file with the same name.
fulcro-lein-template. Build works, hot reload works, repl seems to work for stuff like "(+ 1 2)" but not (js/console.log "test") -> No such namespace: js,. Am I doing something wrong or is this the way it's supposed to work ?:reload still not work:reload not work? I tested it yesterday?:load functionality(require '[the.thing :as x]) then (x/foo)(require 'the.thing :reload)The required namespace "mranderson047.reagent.v0v8v0_alpha2.reagent.core" is not available, it was required by "day8/re_frame_10x/view/event.cljs". "mranderson047/reagent/v0v8v0_alpha2/reagent/core.clj" was found on the classpath. Should this be a .cljs file?There is a clj and a cljs file with the same name.
[day8.re-frame/re-frame-10x "0.3.0-1-react16"]react-highlight?(ns cljsjs.react-highlight (:require ["react-highlight.js" :as react-highlight])) (js/goog.exportSymbol "Highlight" react-highlight)
(ns cljsjs.highlight.langs.clojure
(:require ["highlight.js" :as highlight]
["highlight.js/lib/languages/clojure" :as c]))
(.registerLanguage highlight "clojure" c)-mranderson047.reagent.v0v8v0-alpha2.reagent.core is available but mranderson047.reagent.v0v8v0_alpha2.reagent.core is notshadow-cljsjs ones:preloads are not included in a release build therefore if doesn't matter if you have them on the classpathdefn and fn but I'm not sure about how to do that using shadow.deps.edn for this currently:devcards true trick will not be safe under the new AOT cache?:closure-defines to achieve this thoughdevcards does this via :devcards true:output-dir (which solved it for me). @thheller have you considered to programmatically wipe all target output between versions?user.clj. Clojure does. whatever you put in there will be loaded by clojure.) exit should not happen. it is indeed a bug.query thing however works just fine for me?RT.doInit function which is one of the first things that gets called when clojure starts(:require [devcards.core :as devcards :include-macros true]):compiler-options {:devards true}[:app] Compiling ... [:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.46s) [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.82s) [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 2.27s) [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.67s)
--verbose or :verbose true in your config. should make it clearer.:node-test builds?
My shadow-cljs.edn:
{:deps {:aliases [:dev :test]}
:cache-root ".shadow-cljs"
:builds {:main {:target :npm-module
:output-dir "lib"
:compiler-options {:source-map true}}
:main-test {:target :node-test
:output-to "lib/main-test.js"
:autorun true
:compiler-options {:source-map true}}
:delay-test {:target :node-test
:output-to "lib/delay-test.js"
:ns-regexp "-test-delay$"
:compiler-options {:source-map true}}}}
Because of some job in namespace *-test-delay will cost lots time, so I hope I can start the test manually.[:main-test] Build completed. (72 files, 0 compiled, 0 warnings, 6.19s) [:main] Build completed. (174 files, 1 compiled, 0 warnings, 6.25s) [:delay-test] Compiling ... [:delay-test] Build failure: The required namespace "utils.airtable-test-delay" is not available.
- instead of _?shadow-cljs pom and then use mvn directly to resolve the deps. maybe that prints more useful infosettings.xml is used at all but that might be the reason it can't find shadow-cljs since thats on clojars not http://maven.orgproject.clj and lein?shadow-cljs pom && mvn dependency:tree or so:runtime option stands for?:npm-module will add repl client when it see :runtime = :browser.:npm-module is very unreliable. I meant to take it out completely. don't expect things to work.:runtime decides if the browser REPL or node REPL clients get injectedns and require are probably not going to work(require '[some.thing :as x]) in the REPL yescreate-react-native-app the preferred way to create apps these days or react-native directly?mvn available?lein should run into issues as well. you can create a temp project.clj and just add shadow-cljs and let it try to resolveLeiningen 2.8.1 on Java 1.8.0_162 OpenJDK 64-Bit Server VM Could not transfer artifact org.clojure:clojure:jar:1.9.0 from/to central (): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
(defproject the-thing "0.0.0" :dependencies [[thheller/shadow-cljs "2.2.22"]])
lein deps2.2.23 which should fix all performance issues in builds with many JS files. semantic-ui-react goes from 3sec+ back down to the usual 0.4s[:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.59s) [:app] Compiling ... [:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.54s) [:app] Compiling ... [:app] Build completed. (911 files, 728 compiled, 0 warnings, 19.55s) <=== required semantic ui [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.71s) [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.98s) <== ~ compile time avg [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.95s) [:app] Compiling ... [:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.22s)
--verbose and check where all the time is going?Caused by: java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType1.10.238.(ns shadow.build.cljs-closure) .. I added that ns to work around a different issue related to CLJS versions .. can't win in this situation ...package.json but the compiler doesn't seem to be picking it up.semantic-ui-react/dist/umd is not a valid package unfortunately. commonjs should be fine. could even try the es version<- Shadow JS converting 1025 JS sources (18541 ms)cljsjs.semantic-ui-react to https://github.com/thheller/shadow-cljsjs so others don't have to do this partNullPointerException: clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301) shadow.build.output/flush-dev-js-modules (output.clj:564) shadow.build.output/flush-dev-js-modules (output.clj:560) shadow.build.targets.npm-module/process (npm_module.clj:63) shadow.build.targets.npm-module/process (npm_module.clj:54) clojure.lang.Var.invoke (Var.java:381) shadow.build/process-stage/fn--14988 (build.clj:119) shadow.build/process-stage (build.clj:116)
:builds
{:npm {:target :npm-module}}
:builds {}?:output-dir "out" or so. it defaults to :output-dir "node_modules/shadow-cljs":builds {} it works:target :npm-module requires at least :output-dir, which is set if using the built-in :npm configwatch command I get a bunch of warnings @thheller :
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/hmaurer/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider() WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
my-app.tinker namespace, or similarclj-repl no. I still need to add an option for that.:builds {:id-of-build ...}. :app or so.lein is using. might switch to tools.deps in the future.:local-repo "wherever" in your shadow-cljs.edn config.shadow-cljs/classpath.edn though:local-repo changing:main config:npm-module everything you don't ^:export is fair game and will most likely be removed:node-library generates ONE file object with exports. so you end up with ONE require("the-thing"):npm-module leaves the namespaces intact so you can require individual namespaces require("the-thing/some.ns"):node-library you specify the :exports in the config. they can be from different namespaces yes.create-react-app project. moved some things around but didn't change one line of code.(reload); it looks for files that changed and reloads the namespaces)rlwrap npx shadow-cljs clj-repl (reload)shadow-cljs browser-repl or so?(require 'some.ns :reload) should do it then:http-handler that just delegates to the var you want to switch.2.2.25. the var is now deref'd when the request happens not when starting the server. so any updates should be reflected immediately.shadow-cljs node-repl, is it possible to connect via another nrepl client? What would to port be? I want to start a node repl without having to set up build config, and then connect to it via cider.(shadow.cljs.devtools.api/node-repl).(shadow.cljs.devtools.api/node-repl) without running shadow-cljs node-repl first.:node-script target, I can start the compiled js file using node, and then connect to the nrepl using cider. However, I can't figure out how to make println statements output to the repl. When I call println, it prints in to console where I started the node js script. I would like it to print within the repl. Does that make sense? Is it possible?node ..., and I’m looking for a cleaner way to do things.JS runtime connected.
[2018-04-07 19:16:05 - ERROR] UT005071: Undertow request failed HttpServerExchange{ POST /worker/files/app/467f79fb-e0e5-4f7b-9df5-56e803f4cf44/1998cbc0-21d4-4a18-a69f-aa7b9dff54f0 request {Connection=[keep-alive], Accept=[*/*], Accept-Language=[en-us], Accept-Encoding=[gzip, deflate], Content-Type=[application/edn; charset=utf-8], Content-Length=[303], User-Agent=[HelloRN/1 CFNetwork/893.14 Darwin/16.7.0], Host=[0.0.0.0:9630]} response {}}
clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "clojure/walk.cljs"] {:resource-id [:shadow.build.classpath/resource "clojure/walk.cljs"]}
at clojure.core$ex_info.invokeStatic(core.clj:4739)
at clojure.core$ex_info.invoke(core.clj:4739)
at shadow.build.data$get_output_BANG_.invokeStatic(data.clj:168)
at shadow.build.data$get_output_BANG_.invoke(data.clj:164)
at $files_req$fn__19941.invoke(ws.clj:221)
at clojure.core$map$fn__5587.invoke(core.clj:2745)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:528)
at clojure.core$seq__5124.invokeStatic(core.clj:137)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
at clojure.core.protocols$fn__7835.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__7835.invoke(protocols.clj:75)
at clojure.core.protocols$fn__7781$G__7776__7794.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6748)
at clojure.core$into.invokeStatic(core.clj:6815)
at clojure.core$into.invoke(core.clj:6807)
at $files_req.invokeStatic(ws.clj:245)
at $files_req.invoke(ws.clj:173)
at $process_req.invokeStatic(ws.clj:283)
at $process_req.invoke(ws.clj:253)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at shadow.http.router$call_handler.invokeStatic(router.clj:12)
at shadow.http.router$call_handler.invoke(router.clj:11)
at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:160)
at shadow.cljs.devtools.server.web$root.invoke(web.clj:159)
at shadow.cljs.devtools.server$get_ring_handler$fn__21898.invoke(server.clj:60)
at ring.middleware.resource$wrap_resource$fn__21453.invoke(resource.clj:37)
at ring.middleware.resource$wrap_resource$fn__21453.invoke(resource.clj:37)
at ring.middleware.params$wrap_params$fn__19405.invoke(params.clj:67)
at shadow.cljs.devtools.server.ring_gzip$wrap_gzip$fn__21523.invoke(ring_gzip.clj:94)
at shadow.undertow$ring_STAR_$reify__21609.handleRequest(undertow.clj:28)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
I found the code
https://github.com/thheller/shadow-cljs/blob/0749e08322f5059e255fb3eb41a0f3c63c29c1d3/src/main/shadow/build/data.clj#L164clojure/walk in :output of state, there're clojure/string, clojure/data, etc.shadow$provide.module$node_modules$ramda$src$omit=function(e,k,a,p,f){e=a("module$node_modules$ramda$src$internal$_curry2")(function(a,e){for(var c={},f={},g=0,k=a.length;g<k;)f[a[g]]=1,g+=1;for(var p in e)f.hasOwnProperty(p)||(c[p]=e[p]);return c});p.exports=e}shadow-cljs watch appshadow-cljs: ^2.2.21 and when attempting to include core.async in a build with target :bootstrap I get the following error... The required namespace "java.util.concurrent.locks.Lock" is not available, it was required by "cljs/core/async/impl/ioc_macros$macros.cljc".
edn deps has [org.clojure/core.async "0.4.474"]
has anyone come across this? Cheers!
(edit: code format)core.async is not self-host compatible and cannot be compiled by :bootstrap2.2.26 should at least reload properly.:closure-defines available in shadow-cljs? The problem I'm working on is that I want one target for electron and one target for the browser. It's re-frame, so I'd like to be able to branch on that at compile time and use that to choose whether data gets loaded from filesystem (electron) or the web (browser).:closure-defines in a :compiler-options map and just at the top-level of the build, and it didn't seem to take.:compiler-options map:compiler-options governs if they're both present:compiler-options is the correct place yes but as a convenience its allowed in the build alsoindex.html ... eg <script>my.project.system.go("electron")</script> but it seems less screwable-aroundable-with in prod if I just lock it in at build time.your.project.browser and your.project.electronimport React from "react"import React, { createElement } from "react" works in webpack but not in closure:as does ...foo/bar.js with module.exports.foo to module$foo$bar.default.fooimport {foo} from ‘/foo/bar’ would would try to access module$foo$bar.foovar x = require("foo") with module.exports.foo = 1module.exports.foo = 2export let foo = 1 and later updating that fooimport React, { createElement } from "react" works in webpack but not in closure:advanced work for it(ns my.app {:css/include ["./foo.css"]} ...) or something along those linesrequire("foo.css") ... thats just horribleReact is not definedwatch?React isn't defined by shadow-cljs anywhere unless you are using cljsjs.reactshadow-cljs release your-app --debug? what is your full stacktrace when you get the React not found error?shadow-cljs release the-build --debugshadow-cljs cljs-repl app work with: https://github.com/thheller/shadow-cljs-examples/tree/master/cljs-react-native-app ? I get No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
I have the code loaded and working in the iPhone Simulator via Expo. Is there another step to get the repl connected, or did I break something?cljs-repl for :npm-module is currently in a weird state. It doesn't really work due to the way the react-native packager works.:figwheel-always?cljs.test I added this hack for my testing stuff.
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L783-L811
Basically all it does is call register-test to register the test var at RUNTIME. meaning I can completely bypass all macros to discover new tests at runtime.cljs.test rewritten to work completely without macros:figwheel-always.:dev/once (or :figwheel-no-load) but didn't add :figwheel-always since I think there are better solutionsdeftest. My macro is just a thing that makes the reporting prettier for deftest. So, your “hacked” deftest should already be picked up by it without me having to import anything. So, the problems I’m seeing were already present in shadow, it seems.specification macro to no only emit deftest but also registering the spec at runtime with your fulcro-spec. so basically (defmacro specification
"Defines a specification which is translated into a what a deftest macro produces with report hooks for the
description. Technically outputs a deftest with additional output reporting.
When *load-tests* is false, the specification is ignored."
[& args]
(let [{:keys [name selectors body]} (fss/conform! ::specification args)
test-name (-> (var-name-from-string name)
(with-meta (zipmap selectors (repeat true))))
prefix (im/if-cljs &env "cljs.test" "clojure.test")]
`(do (~(symbol prefix "deftest") ~test-name
(im/when-selected-for ~(fss/conform! ::sel/test-selectors selectors)
(im/with-reporting {:type :specification :string ~name
:form-meta ~(select-keys (meta &form) [:line])}
(im/try-report ~name
But I do understand that a rewrite just for the sake of a rewrite is not ideal. I will add support for :figwheel-always.fulcro-spec is pretty much the same that cljs.test but IMHO there is no good reason to do it this way.fulcro-spec probably looked at cljs.test to see how to do it and just copied the approach.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d1a2b9b0b5bea6fcb2bdbba291e3ffe3ffe3e8"}, :content ("[email protected]")}. either (ns ^:dev/always some.ns ...) or (ns ^:figwheel-always some.ns ...) works.:target that allows me to export namespaces so that a downstream cljs project can simply js/someExportedNS?app.js to load compiled cljs-runtime from another location other than /js/cljs-runtime? I found there are some var CLOSURE_BASE_PATH = '/js/cljs-runtime/'; in the beginning of the app.js.var CLOSURE_BASE_PATH = to another location.:output-dir option>) of the files, not :devtools { :http-handler shadow.http.push-state/handle supposed to handle more than one path? localhost:xxxx/foo still directs to /index.html, and all downstream resources still point to <asset-path>/cljs-runtime/<asset> but localhost:xxxx/foo/bar will direct to /index.html and all downstream will incorrectly(?) point to /foo/<asset-path>/main.jslocalhost:xxx/app/doc/6 or whatever it will reload the main bundle for me. is that what you are asking?:asset-path from my configuration, it looks like main.js is dumped into my :output-dir, but for some reason everything beyond the main.js file gets a js/cljs-runtime attached? if I look at the main.js file itself i see
var CLOSURE_BASE_PATH = '/js/cljs-runtime/';
<script src="/foo" .../> vs <script src="foo" >aws-sdk? I'm new to shadow-cljs and am getting errorsaws-sdk I tried installing a different version, and got a different errormodule/method and module.method are different in shadow-cljs, if module is from npm?moment.js works fine, but aws-sdk craps outmodule/method and module.method are different in shadow-cljs, if module is from npm?
What is this?(ns ...) to import, you should use module/method to call it.(ns (:require ["module" :as module]))(ns starter.browser
(:require ["moment" :as moment]
["aws-sdk"]))
aws-sdk?:as, :default also doesn't workaws-sdk is a monster...aws-amplify but I can't even get aws-sdk to :require... and I think aws-amplify depends on aws-sdk...aws-sdk and got a different error...leiningen either (or at least :foreign-libs, :npm-deps) context here: https://stackoverflow.com/questions/49767358/aws-amplify-with-clojurescriptshadow-cljs was my last attempt... it seems like it should work...aws-sdk has a weird circular dependency in their code which shadow has trouble with. will see if I can fix that.cursive
I follow the instructions to connect to the cljs repl. all works great, however, i cant access the cljs.repl apis... what am i missing?
Connecting to remote nREPL server... Clojure 1.9.0 (require '[shadow.cljs.devtools.api :as shadow]) => nil (shadow/nrepl-select :b2) To quit, type: :cljs/quit => [:selected :b2] (require '[cljs.repl :refer [doc source]]) => nil (doc map) => nilthanks
2.2.29. at least the require works. didn't know what/how to test further. let me know if you run into other issues.aws-amplify required, (steps were 1. moment, 2. aws-sdk 3. aws-amplify) Got a weird Uncaught ReferenceError: Buffer is not defined error, but it might not be related to shadow-cljs https://github.com/aws/aws-amplify/issues/140(ns starter.browser
(:require ["moment" :as moment]
["aws-amplify"]))
yarn add aws-amplify takes Done in 74.61s.(ns starter.buffer-fix (:require ["buffer" :as b])) (js/goog.exportSymbol "Buffer" b)and then require this in
starter.browser BEFORE aws-amplify:refer instead, but fixed worked like a charm! 🙂shadow-cljs release? I’m using (goog-define api-host ") along w/ :closure-defines in my shadow-cljs.edn to switch config for dev/release, but I feel like I need one more option.:release {:closure-defines ...}shadow-cljs release API_HOST= and shadow-cljs release API_HOST=shadow-cljs dev, my (goog-define api-host "") works great.:closure-defines {foo #shadow/env "API_HOST"} in your configclj-run to call (shadow.cljs.devtools.api/release* build-config-map)(shadow.cljs.devtools.api/get-build-config :your-build) loads your build config from shadow-cljs.ednrelease*(defn release [api-host] ...) could be called with shadow-cljs clj-run your.build/release clj-run might be perfect. Thanks, I’ll give it a shot! new?ls-sessions op of nrepl and try to figure out which session is Clojure and which is Clojurescript. But with the shadow-cljs repl I get back an empty array of sessions.npm install --save-dev shadow-cljs. might need to do npm init -y first if you don't have a package.json yet.ls-sessions doesn't return anything since that is handled by the default session middleware. I'll see if I'm supposed to set anything.track-state middleware from cider however you should get a :repl-type message after each evalclj or cljs..nrepl-port. shadow-cljs writes this only when lein is not using it. might consider looking at .shadow-cljs/nrepl.port as well.ls-sessions is empty because there are no default sessions. you'd first need to clone to create your owntrack-state middleware, the way I do it today is really hackish.clone. Its just what cider or lein repl :connect do when connecting. that creates a session. in case of lein repl there sessions because lein repl consists of the part that starts the server and the one that connects. nrepl-middleware is mostly a mystery to me.sessions vector is populated anyway.:lein true yesterday btw, so don't know if it behaves differently then. Will give it another try tonight.shadow-cljs says it can't inspect and thus it can't be used. Is there somewhere I can read up about such issues?ysera: [2018-04-12 09:08:24 - WARNING] failed to inspect resource "jar:file:/Users/pez/.m2/repository/ysera/ysera/1.1.0/ysera-1.1.0.jar!/ysera/state.cljc", it will not be available.
ysera.state from CLJS(is= and such..cljc files although they only work in clojureysera/state.cljc is empty. meaning it has no ns form, meaning "it will not be available" at runtime?rel=1523416697167. so whatever code you have loaded is not the one produced by shadow-cljsdevcards just fine. nothing in there requires you to use figwheel.1.2.0 seems to have an empty state.cljc file that shadow-cljs then complains about not being able to analyze. Checking the repo it seems like the file is removed in master. Not that ysera starts working in shadow-cljs just because of this, but at least one complaint less.js/React not defined inside of reagent.implcljsjs/react.cljs file in your project?cljsjs/react/dom/server etc.js/React is coming fromcljsjs files in your project?React is not defined and if I pull apart the compiled source I see a bunch of cljs.core.apply.cljs$core$IFn$_invoke$arity$4(React.createElement, so some lib I’m using depends on window.React it seemsgoog.set window React react(ns cljsjs.react) that just did nothingoset! ...)cljsjs.react in your project that effectively overrides the one in shadow-cljsjsboot.core file I have to manually require ["react"] just to ensure it’s there before some other lib tries to invoke it*"react" or cljsjs.react? then yes that may lead to load order issues`[2018-04-12 13:19:47 - WARNING] provide conflict for #{authentication.views} provided by compiled/authentication/views.js and {"/authentication/views.cljs" #{authentication.views}}
(do (require (symbol (namespace `router-component)))
((find-var `router-component) {:uri "/abc"})) <- this works after redefing
but shadow-cljs’ server remains stuck on the initial value until I restart the whole instance.:output-dir is on the classpath. that is not a good idea.yarn add takes.$ shadow-cljs cljs-repl app shadow-cljs - config: …shadow-cljs.edn version: 2.2.29 shadow-cljs - connected to server [1:1]~cljs.user=> (+ 1 2) No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.What am I not understanding?
shadow-cljs REPL connected in the console when you load the pageshadow-cljs watch app. you open whatever that produces in the browser?:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:game-of-life {:entries [game-of-life.main]}}
:devtools {:after-load app.main/render!
:http-root "resources/public"
:http-port 8080}}}
loaded in your browser?<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="https://clojurescript.org/images/cljs-logo-icon-32.png">
</head>
<body>
<div id="app">
<h2>Static HTML from index.html</h2>
</div>
<script src="js/compiled/game_of_life.js" type="text/javascript"></script>
</body>
</html>
- to _ for the output files?resources/public/js/compiled to be safe(shadow.cljs.devtools.api/nrepl-select :app) to switch the current session over to cljs:cljs/quit will drop that session down to CLJsrc/my/app.cljc (ns my.app) (js/console.log "foo")(require 'my.app) in a Clojure REPL it will blow upjs/console.log(ns my.app (:require [])).cljc files actually makes sure that they work in both platformscljs.test is horrible to use, too many macros.ls-sessions and get a vector of sessions w/o cloning. But with shadow-cljs I must first clone to populate the vector. What I would think makes most sense is that the vector is populated to begin with, then I clone sessions that Calva can connect to.lein repl what you are cloning is the repl-y session which may already have put stuff in the session you don't actually needlein repl as a baseline IMHOclj won't have that either{:op "shadow-cljs/hello"} or so. shadow-cljs could reply with something while others will just reply with an error(shadow.cljs.devtools.api/nrepl-select :app) and see if that works.
I might start out with jsut letting the user manualy select what kind of session to connect to.Ctrl-C on shadow-cljs watch app sometimes leaves server running, so next time shadow-cljs watch app doesn’t do anything?server. https://shadow-cljs.github.io/docs/UsersGuide.html#server-modeshadow-cljs watch only one server will be usedwatch however should be stopped by the watch process that created itshadow-cljs clj-repl (shadow/stop-worker :app) to stop it if its "stuck":web-worker true setting inside shadow-cljs.edn. However, I'm getting the following problem: ReferenceError: document is not defined (`at hud.cljs:47`) when running the service worker. If this is a bug I'm happy to open a Github issue, just wanted to check that I'm not just doing something stupid.:web-worker in a module has a very distinct meaning. it is not suitable for making standalone webworkers or serviceworkers. that should be individual :target configsreact-native. will create simplified ones for worker after that, then we can properly evaluate whether it makes sense to use cljs for service workers(defn foo [...])?(defn foo [req] {:status 200 :body "hello world"}):body, load-file and reload the browser I see the updated version:http-handler dev.http/handle but the ns was demo.http/handle so I got a NullPointerException`. I added a warning for that.dev.http/handle the full ns or an alias? I’m wondering what I’m doing wrong. Also since I’m using shadow-cljs embedded, is there a way to pass the config in dynamically instead of through shadow-cljs.edn? I’m asking because the library I’m working on (releasing soon) is generating the shadow-config for the user and currently does some ugly macro magic to pretend that there is config when there is none. I wonder if that has anything to do with it.shadow-cljs watch app basically calls (shadow.cljs.devtools.api/watch :app) which calls (shadow.cljs.devtools.api/watch* the-config-map {})(with-shadow-config (shadow-config config) (shadow-server/start!) (shadow-api/watch :app))
shadow.cljs.devtools.api/watch*get-or-start-worker. just take a look at https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/api.clj should be easy to followbrowser target. Is that supported?source-paths (its a common theme for people to do a /src/clj and /src/cljstarget to browser(defmacro h1 [props & children] `[:h1 ~props
shadow-cljs watch app (app is my build name)Call to clojure.core/defn did not conform to spec
-- Syntax error -------------------
(... [{:keys (attrs)} ...] ...)
^^^^^^^^^^^^^^^
has extra input
and
-- Spec failed --------------------
(... [{:keys (attrs)} ...] ...)
^^^^^^^^^^^^^^^
should satisfy
vector?
{:keys [attrs]}?defmacro… let me try to remove it again, one sec(defmacro h1 [props & children] `[:h1 ~props
@ and it compiled, it might have been just that.cljc file?.clj at the moment, then I have a .cljs that require-macroes it, I’m copying the example from https://github.com/thheller/shadow-cljs-examples/blob/master/macrosbrowser target rather than node{:keys (attrs)}. should be somewhere in your codeh1 is not the causeshadow-cljs watch :id? i’m using vim-fireplace and I can’t seem to make a connectino:Connect host/port/blah (vim), and also from a shadow-cljs cljs-repl using the api/nrepl-select :id .. but in the first case I get some unhelpful compilation error. in the second case I get cannot read prop 'nrepl_select' of undefined.(shadow.cljs.devtools.api/nrepl-select :id)shadow alias exists~/.shadow-cljs/config.edn is merged into the main config yes./app/ I can invoke :Eval (+ 1 2) and the nrepl will return 3./app/src/some-mod.cljs and attempt to Eval it will always give me a compiler error in the output(cemeric.piggieback/cljs-repl :id), except when I do that I always get [:no-worker :main]watch is not runningclj-run build/dev where my builder does some stuff and ultimately defers to shadow/watch build-cfg optsshadow-cljs watch id, i think it’s running?(cemeric.piggieback/cljs-repl :id) which would return [:no-worker :id] not [:no-worker :main]:main which is my module, i just used :id to confuse youshadow-cljs server(shadow.cljs.devtools.api/watch :main) and then I think :Piggieback :main?shadow-cljs server, then connect to the nrepl, then run /watch :main spits back “no build with id :main”--
and here’s my config
:nrepl {:port 8001}
:builds {:app
{:modules {:main {:entries [boot.core]}}
...
:app:watching. if from another buffer (cljs); i load the browser to connect to the js environment; I :Eval (shadow/nrepl-select :app); now i can eval in my cljs bufferapi/watch <id> automatically start a server, right? is there something different about that server versus starting it at the command line shadow-cljs server i wonder?shadow-cljs watch app starts a server if it isn't running yesclj-run to start a task that eventually calls shadow/watch config opts initializes a server differently{:shadow/requires-server true} this is the important bit(defn dev
{:shadow/requires-server true}
[& args]
(let [c (config/get-build! :app)
build (merge c dev-cfg)]
(move-index (:index-in build) (:index-out build))
(shadow/watch build {:verbose true})))
shadow-cljs clj-run build/dev invocationwatch only takes a keyword id, not the actual configdev-cfg?(def cfg {:index-in "resources/index.html"
:index-out "public/index.html"
:manifest "public/js/compiled/manifest.edn"})
(def dev-cfg (merge cfg {:compiler-options {:closure-defines {'build-tools.constants/graphql-uri (or (System/getenv "GRAPHQL_URI")
index.html maybe?watch since that is slightly more involved when doing thingsstarter.browser.init("the-actual-url"); and have the init function set it to whatever varshadow-cljs watch app the server will be runningshadow-cljs server and doing everything via the REPLshadow-cljs check your-build:advancedcheck a shotexterns/<your-build-id>.txt and the you add one word per lineendBlockhandleOuterClickProperty ... never definedshadow-cljs server separatelyshadow-cljs check until the warnings are gone 😉:infer-externs :autoShadowJS is the "type" assigned to anything returned by require Property core never defined on instaparseCannot infer target type in expression - from what I read in the shadow-cljs doc the other day, you can effectively get rid of them by marking them with ^js metadata - however, is that really required when the whole thing ends up going through closure?^goog or ^clj to make the warnings go away^goog is for stuff from the closure lib^clj variable Java is undeclaredglobal:Java to the .txt fileshadow-cljs release app --debug but I doubt that would change anything renderMark: renderMark,decorateNode: function decorateNodeFoo() {decorateNode issue we can probably try to create a minimal repro and report to the closure compilerrenderMark is coming from but if you can change the name for that var as well try that too.shadow-cljs/builds/<your-id>/dev/closure-jsrenderNode:renderNode$$module$gen$editor(_this.props.readOnly), renderMark:renderMarkFoo$$module$gen$editor, decorateNode:function decorate() {\n return undefined;\n }, value:_this.props.value, :Eval (+ 1 2) and get 3 (yay the connection to nrepl works)
4) cannot use :Eval from inside a .cljs buffer (always spits out Fireplace: class clojure.lang.Compiler$CompilerException)
5) from a .clj buffer run shadow...api/watch :app — get back :watching — success!
6) connect to the js environment by opening a browser
7) still no Eval in a .cljs buffer
8 ) from a clj buffer run shadow...api/nrepl-select :app — get back [:selected :app] — success!
9 ) from a clj buffer :Eval (js/alert) yay it works
10 ) still nothing works from a .cljs buffer:Piggieback or so?nrepl-select :id was going to already put me in a cljs environment?:Piggieback :app?:Piggieback [{env}] Create a new nREPL session and invoke
cemerick.piggieback/cljs-repl with the given or
default (Rhino) environment. This will also happen
automatically on first eval in a ClojureScript buffer
if not invoked explicitly. If {env} is a number, the
piggieback repl-env will will use a cljs.repl.browser
(rather than a Rhino) env with the port set to the
number provided.
:Piggieback :app?user ns? I can’t remember which.shadow-cljs clj-repl (assuming you already have a server running in the background)?shadow-cljs clj-repl and then ( "rewrite_clj/parser/string.cljs")jar:... or file:.. urls[clojure.string] to the requiressrc/rewrite_clj/parser/string.cljs in your project:expo target, following the example project.exp and create-react-native-app?"dependencies": {
"expo": "^26.0.0",
"react": "16.3.0-alpha.1",
"react-native": "0.54.0"
}create-react-native-app{
"name": "DemoApp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.13.1",
"jest-expo": "26.0.0",
"react-test-renderer": "16.3.0-alpha.1"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^26.0.0",
"react": "16.3.0-alpha.1",
"react-native": "0.54.0"
}
}
I think we have the same dependencies.2.4.7.1013849DemoApp/out-ios/bundle.ios.js file and look at the lines directly until source maps work16258 case 'blob':
16259 if (typeof this._response === 'object' && this._response) {
16260 this._cachedResponse = BlobManager.createFromOptions(this._response);
16261 } else {
16262 throw new Error("Invalid response for blob: " + this._response); <--- Here
16263 }
16264
16265 break;
can you find this part in your bundle.ios.js?Dismiss+ button. It was there2.4.6 was running the simulator? how did you start the simulator?exp to start a ios simulator, it will download expo and install it automatically.10:36:35 [exp] Installing Expo on device \10:36:38 [exp] Couldn't start project on Android: Error running adb: Failed to install C:\Users\thheller\.expo\android-apk-cache\Exponent-2.4.0.apk:
exp android. I'm on windows so no iOS.exp://...?"exponent-sdk-version" "26.0.0,25.0.0,24.0.0,23.0.0,22.0.0,21.0.0,20.0.0" header on connect. can just pretend to by any of those 😉"26.0.0,25.0.0,24.0.0,23.0.0,22.0.0,21.0.0,20.0.0" as versions"20.0.0,21.0.0,22.0.0,23.0.0,24.0.0,25.0.0,26.0.0"shadow.module.test.append.js:2 Uncaught TypeError: Cannot read property 'devtools' of undefined
at shadow.module.test.append.js:2
(anonymous) @ shadow.module.test.append.js:2
lein new fulcro app shadow-cljs demo, running the test build.lein new fulcro app shadow-cljs demo and shadow-cljs watch test with 2.2.31?:npm-module target for expo to build a release version? (also should provide a index.js manually)release support in 2.2.31shadow-cljs release it generates an optimized.ios.js in the :output-dir2.2.31exp build or any of the release stuff since it asked me a bunch of questions I didn't want to answer at the timereact-native and expo targets work in the same way?...
:simple-deploy {:target :browser
:output-dir "resources/public/simple-deploy/js/"
:modules {:main {:entries [simple-deploy.core]}}
}
...
and a simple reagent mini app... with a single dependency on reagent
(ns simple-deploy.core
(:require [reagent.core :as r]))
...
...
;; app code
...
...
(defn ^:export run []
(r/render [simple-example]
(js/document.getElementById "app")))
when I run shadow-cljs release simple-deploy --debug
I get...
[:simple-deploy] Compiling ... Closure compilation failed with 1 errors --- EXTERNS:/Users/javierabanses/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670 Object literal contains illegal duplicate key "scaleSequential", disallowed in strict modeso the question is? when/why is d3 being included? NOTE: this is the first time i've run
shadow-cljs release ... so maybe it is scanning the local maven repo for indexing or something?
thanks in advance.npx shadow-cljs clj-repl
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.101
shadow-cljs - connected to server
shadow-cljs - REPL - see (help), :repl/quit to exit
[11:0]~shadow.user=> (shadow/release-snapshot :simple {})
:simple being build id
i get
ExceptionInfo closure errors clojure.core/ex-info (core.clj:4739)
keep in mind shadow-cljs release :simple never finished and exited with an error... so maybe this means there is nothing to examine...lein clean equivalent or even need for it? I am very new to the tool and can't see any in the docscljsjs.d3 on your classpath.2.3.0 which removes this behaviour. about time.-a arg1 -b arg2 ... etc. throws with a shadow-cljs clj-run “unrecognized argument”--shadow-cljs clj-run foo.bar/run -- a b cpackage.json and project.clj. So I can change it to say '2.3.0' in both those places. Then what do I need to do? I never saw this outlined in the documentation, yet everyone seems to be doing it. If I just run npx shadow-cljs watch main (the only command I ever run) the version change is not picked up.package.json and then run npm install. restart shadow and it should pick it up[:app] Compiling ... [:app] Build failure: FileNotFoundException: /home/matthys/projects/personal/learning/src/learning/web/topic_notes/core.cljs (Too many open files) java.io.FileInputStream.open0 (FileInputStream.java:-2) java.io.FileInputStream.open (FileInputStream.java:195) java.io.FileInputStream.<init> (FileInputStream.java:138) (io.clj:229) (io.clj:229) (io.clj:69) (io.clj:165) (io.clj:165)
lsof -p <pid> to list the open files of the shadow-cljs process. jps should list the pid. not sure where the leak could be coming from so knowing which files are open would help a lotand then you simply download 'emacs'... speech when trying to infect them with The Clojure” goodmagit and org-mode before get too serious about Code as a daily driver, but Calva seems to do really well for a REPL 🙂magit-level, keyboard-wise, but still good.download emacs thing is a good way to weed out the weak. 😃emacs or JVM stacktraces or whatever for awhile to get what I’m selling hehe:server build is :node-script running in node. :app build is :browsermy.app.server file open. it imports various node packages:app REPL:browser builds. I have one for the website and one for the admin interfacereact-native app to the mix and so on:output-dir for :dev and :release? it seems the answer is yes from the docs... but maybe i am having a slow day and can't see it clearly.
use case is i have watch running but i also have a quick test deploy script the compiles the same build but in release and deploys to surge.sh.:release {:output-dir "foo/bar"}clj-repl mode, shadow/watch and shadow/repl can be used in shadow.user namespace. how to have these setup in server mode, or have a headless repl in clj-repl mode?(require '[shadow.cljs.devtools.api :as shadow]) works anywhere?require dance for using the twitter npm packagemodule.exports = Twitter, where Twitter is a functionTypeError: shadow.js.shim.module$twitter.Twitter is not a function(:require ["twitter" :as Twitter])module.exports = ... directly that is :as. if they do exports.foo = ... that is :refer (foo)cljsjs. namespaces or rewrite your code to use npm directly?devcards comes up a lot. should probably create a proper example for it. server running for development. I get a 404 on localhost:7000. Everything seems to build nicely.yarn page?target/ to entry/app.page/main!npm install -g calcit-editor on an Unix/Linux OS and launch my editor. Contact me when you need help about the editor. It's a mind blowing piece.shadow-cljs watch xxx takes 10-30 seconds when recompiling for a small project. It takes few seconds before that.shadow-cljs watch and every time I changed a cljs source file, it takes 10-30 seconds to recompile.Build completed. (1030 files, 2 compiled, 0 warnings, 15.31s) Does that mean all files are recompiled?shadow-cljs watch app --verbose^Cshutting down ... JS runtime disconnected. Worker shutdown. shutting down ... shutdown complete. shutdown complete.when I try to stop
watch1.67s just the initial compile when watch started or is that your recompile time when you change a file?shadow-cljs watch the recompile time used to be 10-30s .[:usercreatedata] Compiling ... -> Analyzing Module: :app <- Analyzing Module: :app (28 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: usercreatedata/views.cljs <- Compile CLJS: usercreatedata/views.cljs (180 ms) Cache write: usercreatedata/views.cljs -> Compile CLJS: usercreatedata/core.cljs <- Compile CLJS: usercreatedata/core.cljs (19 ms) Cache write: usercreatedata/core.cljs -> build target: :browser stage: :compile-finish <- build target: :browser stage: :compile-finish (0 ms) -> build target: :browser stage: :flush -> Flushing 1030 sources <- Flushing 1030 sources (81 ms) -> Flushing unoptimized modules <- Flushing unoptimized modules (64 ms) <- build target: :browser stage: :flush (152 ms) [:usercreatedata] Build completed. (1030 files, 2 compiled, 0 warnings, 2.79s)
shutting down two shutdown complete when I tried to stop the problematic shadow-cljs watch session , does that mean something is wrong?^Cshutting down ... JS runtime disconnected. Worker shutdown. shutting down ... shutdown complete. shutdown complete.
shadow-cljs there are only one` shutting down...`<- ... (152 ms) timing infos together2.79s"shadow-cljs": "^2.2.21"
when adding as a dependency,
and compiling with shadow-cljs watch mybuild
it can't seem to find io's dependencies and starts asking me to install each one of them...
anyone came across this? on the client?socket.io-clientcljsjs compatibility layer. Is the following correct? (1) shadow-cljs ignores the :foreign-libs compiler directive, (2) instead it looks at package.json to extract information would would otherwise have been provided via :foreign-libs, (3) when a project imports a cljsjs dependency or provides a :foreign-lib wrapped package, what we must do in shadow-cljs is provide an empty namespace (of whatever name is expected) that does a :require using shadow-cljs syntax and does a goog.exportSymbol.node_modules directly. never looks at the project package.json. 3) yes. cljsjs packages typically provide some global variable, eg. cljsjs.react provides js/React. if you use (:require ["react" ...]) that would not provide the global so we need to export it separately for those still expecting to find a js/React:npm-deps declaration that would download bluebird instead of packaging it?deps.cljs {:npm-deps {"bluebird" "version"}}yarn watchshadow-cljs watch app slow appear again: it takes a long delay before each of two Cache write: xxx/xxx.cljs , but the times are not reported.shadow-cljs first? 2.2.26 nowproject.clj. definitely upgrade all of them before continuing.shadow-cljs is 2.3.0shadow-cljs watch app1, I shadow-cljs release app2 (another app)?cljs.spec in both apps?app1.shadow-cljs/builds/app1/dev/ana/your/ns.cljs.cache.transit.json is?/buildslein or deps.edndevcards does this via :devcards true. this seems more suitable since its just a compiler options.:target npm-module?fulcro.client.primitives.cljc.
I’ll be going off to bed now. Dropping this message hoping to catch you during your day, because timezones.fulcro/client/primitives.cljcnpm-module shadow target to get my cljs code to work with it, but now want to include re-frame-10x and I’m having a little troublere_frame_10x.preload namespace, but it I get some react rendering errors when doing that, something about vbox not returning a valid componentre-frame-10x.preload in your stories namespace?:closure-defines?Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of day8.re_frame_10x.utils.re_com.v_boxshadow-cljs command.shadow-cljs server or lein repl (when working on shadow-cljs itself). connect to nREPL remotely. run everything else through the REPL.shadow-cljs release ...shadow-cljs watch isn't shutting down cleanly when stopped via CTRL + C?.
Said library uses (js/require ... ) to include the acorn-jsx js parser.
I have forked it to patch it, what would be the correct approach to make libs that use js/require universally compatible?cider-connect, and then opening a cljs-repl as described (`(s/nrepl-select :build-id)`)package.json dependencies. Why?node_modules, so what you do is install them normally using npm or yarn and a package.json.:foreign-libs declaration. but shadow-cljs doesn’t support foreign-libs, so it just fakes the namespace and continues to rely on node_modulesshadow-cljs watch app1,app2etc
reagent has React as cljsjs dependency. And if you download and compile the sample project above - you'll see that it pulls React from cljsjs. The question is - can I use :exclusions like in leiningen project setup to exclude that dependency?:dev and :release configuration options. But can I have dev dependencies? Or it does not make sense?lein or deps.ednfn and defn.check command doesn't show any of them)closure/convert-sources-simple instead of closure/convert-sources, but perhaps unsurprisingly that doesn't really work, it doesn't recognize the es6 module export/importslein install to install it locallyclosure/convert-sources(if false ... so that the other branch is always chosen.js files will still call cljs.core or whateverxC or so:simple that is fine^:export that?React.createElement props getting mangled?'onlyIn'shadow-cljs release app --pseudo-names or --debugcompile (not release) and add the converted form to the gist?<output-dir>/cljs-runtime/module$whatever$name$it$had.js.shadow-cljs/builds/<build-id>/release/closure-js/file/name.js{
"presets": [
["env", {
"modules": false
}]
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties",
"transform-react-jsx"
]
}check stuff just does not check any objects/** @nocollapse */ {onlyLn:[...]}module.exports = or exports.fooonlyIn for example{tmp/alex.js=[hasMark, data, handleListOpClick, plugins, focus, type, hasInline, collapseTo, renderNode, ref, fontFamily, leaves, typeCell, checked, text, href, state, fontWeight, editorDeserialize, showLinkModal, onChange, textAlign, constructor, alt, textDecoration, renderMark, readOnly, check, fontStyle, handleBlock, node, borderRadius, style, object, tableOp, onKeyDown, flexGrow, blockName, typeItem, handleHideLinkModal, document, editorStateFromText, className, typeDefault, title, renderEditor, writable, spellCheck, listOp, flex, enumerable, handleLinkButtonClick, handleTableOpClick, disabled, onlyIn, hasBlock, placeholder, value, key, __proto__, editor, padding, types, backgroundColor, editorSerialize, typeTable, src, typeRow, handleMark, flexDirection, display, onPaste, marks, renderToolbar, toggleMark, prototype, handleHeading, editorEmptyState, nodes, toggleBlock, decorateNode, nodeKey, Editor, configurable]}.shadow-cljs/builds/<build-id>/release/externs.shadow.js has them?export.foo props but that didn't work well enough so I added everything:js-properties set in the compiler state:js-options {:js-provider :closure}:shadow-js stuff (ie. node_modules) is never passed to the :advanced compile:simple and then added to the final build AFTER :advanced:advanced destroys everythingmasterlein install?.shadow-cljs/builds just in caselein install should invalidate all cache since the shadow-cljs jar changed:shadow-js 😉:js-propertiesonlyIn doesn't appear in externs.shadow.js anymore, and the generated code is mangled incorrectly, as before{:target :browser, :output-dir /home/akash/.boot/cache/tmp/home/akash/workspace/voidwalker/gw3/-fmvxaj/resources/public/js, :asset-path /js, :compiler-options {:optimizations :simple}, :modules {:app {:entries [voidwalker.source.app]}}, :id :app, :build-id :app, :cache-root /home/akash/.boot/cache/cache/project/home/akash/workspace/voidwalker/com.joshuadavey.boot-shadow-cljs/cache}
When accessing the file.. I get response map is nil.
My shadow-cljs.edn
{:source-paths ["src/cljs"]
:nrepl {:port 55000}
:http {:port 9070
:host "0.0.0.0"}
:dependencies [[reagent "0.8.0-alpha2"]
[reagi "0.10.1"]
[funcool/bide "1.6.0"]
[cljs-ajax "0.6.0"]
[proto-repl "0.3.1"]
[day8.re-frame/http-fx "0.1.3"]
[hickory "0.7.1"]
[re-frame "0.10.5"]
[cider/cider-nrepl "0.17.0-SNAPSHOT"]
[refactor-nrepl "2.4.0-SNAPSHOT"]]
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:optimizations :simple}
:modules
{:app
{:entries [voidwalker.source.app]}}}}}
What should I look into?public/js since that is what is served. :man-facepalming:{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a3d0cbc2c7ccd48ec0cfc9d0e3918d908d91"}, :content ("[email protected]")}[:app] Compiling ... [:app] Build completed. (338 files, 2 compiled, 0 warnings, 0.81s) [:app] Compiling ... [:app] Build completed. (338 files, 2 compiled, 0 warnings, 0.94s)I added:
(:require ["firebase/app" :as firebase]
["firebase/auth"]
["firebase/database"])
And now I'm seeing smth like:
[:app] Compiling ... [:app] Build completed. (592 files, 2 compiled, 0 warnings, 5.14s) [:app] Compiling ... [:app] Build completed. (592 files, 2 compiled, 0 warnings, 4.44s)How could I mitigate that and keep the same developper experience? 🙂
2.3.0shadow-cljs watch app --verbose please and tell me where the time is going?[2018-04-22 18:56:31 - WARNING] classpath update failed ... clojure.lang.ExceptionInfo: failed to inspect cljs file
2.3.1 ?
while I'm at it 😁 : do we need the local npm install of shadow even though it's installed globally?lein deploy yes 😉lein instructions I guess(defproject your/lib "version" :dependencies [...] :source-paths ["src"])
lein deploy clojarsresources dir make sure its empty and doesn't inlude anything compiledlein jar and then jar -tvf target/your-lib-version.jar to verify what is in it:repositories
{"clojars" {:url ""
:sign-releases false}} if you don't want to deal with the gpg stuffns :dev/always -> :figwheel-always and :dev/once -> :figwheel-noload:figwheel-* are also supported, so either works:dev/before-load + :dev/before-load-async to call before reloading any code:dev/after-load + :dev/after-load-asyncshadow-cljs - Using IP "10.240.18.219" from Interface "utun1" Apr 23, 2018 4:23:05 PM shadow.cljs.devtools.server invoke INFO: Found multiple IPs, might be using the wrong one. Please report all interfaces should the chosen one be incorrect.and in the app itself:
REPL client error { Error: connect ETIMEDOUT 10.240.18.219:9630
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: '10.240.18.219',
port: 9630 }
REPL client disconnected
2.3.4 should be betterwatch running? did you nrepl-select it?nrepl-select(require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :build-id-to-focus-on)in the clj repl after it starts?
shadow-cljs watch script on the command lineshadow-cljs node-repl + (shadow/nrepl-select :node-repl) for thisnode-repl is just a standalone node-repl not tied to any build(require 'your.script) and work as usualafter-load hook in my shadow-cljs.edn which calls instrument. I am getting spec errors for existing specs, but when I add a new spec I don't see anything. Can anyone help me with this issue?instrument is a macro so if the code must be recompiled in order for it to update which specs to instrumentinstrument call via (ns ^:dev/always that.ns ...)instrument file loaded before or after the code that contains the specs?instrument in CLJS only works on vars that are compiled BEFORE instrument is compiled.instrument file is loaded after the code that contains the specs.:compiler-options {:static-fns false} in your build config(defn bla [x] (+ 1 x)) (s/fdef bla :args (s/cat :x number?))And calling the function with a
string to trigger an errorinstrument with a println and I noticed that the new specs I add are not included in the output of instrumentstatic-fns to my compiler options nowstatic-fns did not fix the issue eitherinstrument?(defn bla [x] (+ 1 x)) (s/fdef bla :args (s/cat :x number?)) (bla 1) (bla "foo") (st/instrument)
after-load function when calling instrument. if you call a specced function and that does not properly validate thats a bug. anything else is probably an issue related to when things happen.instrument macro is kinda icky to use in that regardinstrument and afterwards refreshing my fulcro application. In my application I have a call to the mentioned bla function.(ns ^:dev/always some.thing (:require [your.app :as x] [cljs.spec.test.alpha :as st]))(st/instrument) and then (x/reload)?(ns ^:dev/always demo.instrument
(:require
[demo.browser :as x]
[cljs.spec.test.alpha :as st]))
(defn ^:dev/after-load instrument []
(st/instrument)
(js/console.log "instrument called")
(x/bla 1)
(x/bla "foo"))demo.browser I only added the defn bla no specinstrument file it works, but not if I don't:modules {:main {:entries ... :prepend "(function() {" :append "})();"}}:output-wrapper as a simplified version of the above. all my builds use multiple modules where you kinda can't use a wrappercljs.closure copied from CLJS to fix one particular bug. it is not used at all.:output-wrapper is useful. also gave you the solution you can use for now. same effect.:modules the :output-wrapper breaks thingsinstrument namespace is not the best solution:entries ns since that will have required everything else?clojurescript from my deps, and now when I try to compile I'm getting this:shadow-cljs - config: /Users/wilkerlucio/Development/fulcro-shadow-boot/shadow-cljs.edn version: 2.3.5 shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch test Exception in thread "main" java.lang.RuntimeException: No such var: ana/cacheable-files, compiling:(shadow/build/cljs_closure.clj:569:19) at clojure.lang.Compiler.analyze(Compiler.java:6792)
leinlein with-profile cljs deps :treecommand-line-args and command-line-usagecommand line-args integrates very easilycommand-line-usage:target :node-script?node_modules without any processingnil?node package/main.js --inspect-brk and then turn on pause on exceptionsnode --inspect-brk package/main.js ? should show the node process thendomain.jsbootstrap_node.jsmodule.jsinternal/module.jsvouch-admin-cli.main/main the exception might be clearer(vouch-admin-cli.main/main ...)node_modules/command-line-usage/lib/chalk-format.js:8:13 in the debuggermodule.js and the other stuffstr = undefinednpx shadow-cljs node-repl(ns foo.bar (:require ["command-line-usage" :as x]))(x (clj->js [{:header "My CLI"
:content "Manage your environment"}
{:header :Options
:optionList [{:name "create-xxxx"
:alias :c
:typeLabel "{underline name}"
:description "Create xxxx with that name"}
{:name "help"
:alias :h
:description "Print this usage guide."}]}]))" My CLI\r \r Manage your environment \r Options\r \r -c, --create-xxxx name Create xxxx with that name \r -h, --help Print this usage guide. \r "
:description keydeps.edn. directly from shadow-cljs noreact-native things? they don't need to be runningmyFile.myHandler, which magically makes AWS look for exports.myHandler in myFile.js.:node-library does this. :exports {:myHandler your.ns/handler}. so it is basically exports.myHandler = your.ns.handler;:exports wayrelease builds with AWS though. it probably wont unterstand the dev stuffshadow-cljs release. Must’ve done something else wrong.:exports. Thanks!(ns live.client.components (:require [reagent.core :as r] #and I get
The required namespace "live.client.components" is not available, it was required by "filemporium/client/live.cljs".@ shouldn’t be there:node before and can’t find it documented. I’m not sure you can discern on compile-time? On run-time you could ask if some node-specific api exists:node@ is for splicing here, taken from https://groups.google.com/forum/#!topic/clojure-dev/8YJJM8lJuQslive.client.subscriptions always?The required namespace "live.client.components" is not available happens when the compiler failed to parse the ns formlive.cljs.cljc filescomponents.cljscljc for some timecljx before I knew about shadow-cljs. thank you very much!npm install'ed. I have ["react-countup" :as countup] required in my ns. countup/CountUp is undefined though. If I look at the countup object itself, I can see a few functions defined: formatNumber and startAnimation but not the class: https://github.com/glennreyes/react-countup/blob/master/src/index.js#L105. I must be missing something simple here.import CountUp from 'react-countup';, I do not need to do countup/CountUp. It should just be available under countup.(:require ["react-countup" :as countup]) ;; this is the React component? countup
(:require ["react-countup" :as countup]) ;; this is the React component countup/default
2.3.9 which has :output-wrapper. also documented it here: https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper(:require ["react-countup" :default CountUp]) would be the translation of import CountUp from 'react-countup';:default is definitely confusing:refer-esque approach. I much prefer to use aliases./default in the future.import'ing. Perhaps I don't fully understand the advantage of it.:as. The .default property only exists to make things compatible with CommonJS require. strict ES6 does not have this.:default syntax in the :require 😣(:require ["react-countup" :default Foo]) works just fine:default so you might actually be better off using countup/default for the time being if you care about compatibility. https://dev.clojure.org/jira/browse/CLJS-2376:default?.default is part of the spec. Just re-read the spec and it is definitely defined as a getter.:default is still useful though so that doesn't changemyalias/default?:default syntax just because I like aliasing things over referring them.thing/default everywhere depending on what JS you are working withdef in my project so I don't need to do exactly that.:default Foo is just syntax sugar for :rename {default Foo} so that also works in CLJS[:devtools :preloads]. This tool reads from its own .edn configuration file. The same tool works with Figwheel and the instruction was to (reload-config) after making changes to the configuration file. Is there an equivalent command for cljs-shadow? What worked for me was to rm -rf the builds directory.cljc! so, I've defined a few lines in .cljc file:
#?(:node-script (.log js/console (str "HAHAHAHA.1"))) #?(:browser (.log js/console (str "HAHAHAHA.2"))) #?(:cljs (.log js/console (str "HAHAHAHA.3")))and I also have this in build conf:
:reader-features #{:node-script}
:target :node-script
but I get only :cljs branch compiled, for some reason. Tried to use :node instead, same result:compiler-options {:reader-features #{:node-script}}shadow-cljs.edn at all. it will pick whatever version is installed by npm so only package.json matters.:cache-blockersdefault-db-format.prefs since that does a side-effecting read of the config file//shadow-cljs.edn
{:builds {...
:target :node-script}}
$ shadow-cljs release <script-id>
and based on the documentation it's supposed to output some single-file
stand-alone script. But when I take it out of the directory it was built and put
it inside a new dir, it won't run. I've tried to debug the problem and it seems that
use the nodejs require as such:
shadow.js.shim.module$react_dom$server=require("react-dom/server")
So I then figured that maybe I can use the :js-options :shadow and I did but now I'm stuck because while it works on the watch mode it will fail on release.
I'm running it likeso:
$ shadow-cljs release <script-id> --debug IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword clojure.lang.RT.seqFrom (RT.java:550) clojure.lang.RT.seq (RT.java:530) clojure.lang.APersistentMap.cons (APersistentMap.java:40) clojure.lang.RT.conj (RT.java:670) clojure.core/conj--5112 (core.clj:85) clojure.core/merge/fn--5679 (core.clj:3041) clojure.core/reduce1 (core.clj:936) clojure.core/reduce1 (core.clj:926)And I have no idea how to debug from this 😞
node_modules files since node will load these. so if you move the file you need to move it together with the package.json and install the deps in a new location.:js-provider :shadow can work in theory but I never tested it in combination with :node-scriptshadow-cljs is not required after the file is compiled. it does not mean that node_modules will be bundled.:js-provider :shadow work with :node-script later but as I said this severly limits the number of packages you'll be able to use.package.json. Either way, great work on this tool! 🙂:output-to "out/foo.js" directory with a dedicated out/package.json file that only contains stuff actually required to run the script. eg. no devDependencies.(ns foo.core (:require ["jsonld/dist/jsonld.js" :as jsonld]))and using
:js-options :resolve to redirect the require e.g.
:js-options {:resolve {"jsonld" {:target :npm
:require "jsonld/dist/jsonld.js"}}}
(ns foo.core (:require ["jsonld" :as jsonld]))should be equivalent?
:target :karma, and the shadow-cljs build goes through fine, but when doing karma start I’m getting a reference error require is not definedrequire is not defined where? any chance your code has a js/require call somewhere?:target :browsershadow.js.shim.module$react = require("react");:js-options {:js-provider :shadow :resolve ...}shadow was the default provider @thheller :shadow is only the default for the :browser, otherwise :requirejsonld error here https://github.com/google/closure-compiler/issues/2909(ns cljsjs.jquery
(:require ["jquery" :as jquery]
["$" :as jq]))
(js/goog.object.set jquery "$" jq)
(js/goog.exportSymbol "jquery" jquery)
The first error: The required namespace "cljsjs.jquery" is not available, it was required by "re_pressed/impl.cljs". is gone, but now it complains about $: `The required JS dependency "$" is not available, it was required by "cljsjs/jquery.cljs".
Any idea how to reference that? My code above does not work.(ns cljsjs.jquery (:require ["jquery" :as jquery])) (js/goog.exportSymbol "jQuery" jquery)
jsonld/dist/jsonld.js require redirect but that wasn't working with our :target :karma build where we got require is not defined errors running the tests. It worked when I put the path in the require directly which seemed strange, hence the question. So it looks like we were running into the same issue as @colindresj2.3.11 release I just pushed. or just add :js-provider :shadow to your :js-options.$ is only the variable, it is not an npm package. you can just add the additional (js/goog.exportSymbol "$" jquery) if you likelein deploy clojars so pretty quick to do.last-index-of in next release.node_modules is minimized by Closure :simple optimizations yes. It sometimes even makes already minified stuff smaller but going out of your way to specifically select minified builds is not required no.(shadow/watch :app {:autobuild false}) will disable the automatic reloading.(shadow/watch-compile-all!) to trigger a recompile on all running watches(shadow/watch-compile! :app) for a single buildcider-create-sibling-cljs-repl, I can easily create a javascript shadow-cljs repl. This works, but the only problem is that The only slight "snag" I've run into is that shadow-cljs exits with [:no-client :devcards "Make sure your JS environment has loaded your compiled ClojureScript code."] if I try to create the repl before first loading the web page. But, of course I can't, because cider-create-sibling-cljs-repl also starts the watch and compiles the code (it runs (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :%s) (shadow/nrepl-select :%s))). Is there a way to disable the initial check for connected JS environment?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "eb98838a8f849cc688878198abd9c5d8c5dad9"}, :content ("[email protected]")}. if you start using the triggered compile I'd love some feedback about that. I have often though about using that myself since file watching seems to do a lot of unnecessary compiles. just to lazy to set it up.:modules, with a :worker modules that depends on :main and has :web-worker true. However, when I try to start my webworker, I get the following error: index.js:1 Uncaught ReferenceError: shadow$provide is not defined. This happens in the following line: shadow$provide["module$node_modules$object_assign$index"] = function(global,process,require,module,exports) {. Am I doing something obviously wrong?2.3.13.nrepl.port file does not seem to be located in target/shadow-cljs/nrepl.port. Do I need to set a config value to get shadow-cljs to create it?.shadow-cljs/nrepl.port. target/shadow-cljs was used in old versions.target/shadow-cljs here: https://github.com/thheller/shadow-cljs/wiki/Cursive#connecting-to-a-shadow-repldocument variable, which is not available in web worker context. This makes it impossible to require the prosemirror namespace, because it throws an exception inside the webworker. I can definitely restructure the app into separate modules, but before doing that I just wanted to check because the Conditional Reading option would be much easier.require to work for requiring JS files. I have structured the src directory the same way as under *Requiring JS* in the User Guide: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_jsrequire is very problematic. ES6 works much better if you can use that instead(:require []) I don’t get to work.utilities.js at the root of the src/js directory from a cljs file in a subdirectory to src/main. But whatever I type except for "utilities" fails, Shadow says no:
The required JS dependency “../utilities” is not available, it was required by “repl/message.cljs”.
./../utilities?/../utilities 😃{:source-paths
["src/main"]
:dependencies
[[org.clojure/core.async "0.4.474"]
[cider/cider-nrepl "0.16.0"]
[org.clojure/tools.nrepl "0.2.12"]]
:builds
{:calva
{:target :node-library
:output-dir "out-cljs"
:output-to "src/js/main.js"
:exports {:message repl.message/message}
:modules {:main {:entries [repl.message]}}
:devtools {}}}}
repl.message/message is a map with symbols from the module. I am hoping I can access that map from js code.src but you added a src/main?src/js must also be in :source-paths:output-to "src/js/calva/main.js":output-to "dist/calva.js" or so and then use that as the main in package.jsonmain in package.json must remain ./src/js/extension for now.extension.js then maybe…[:calva] Build failure: NullPointerException: shadow.build.classpath/find-js-resource (classpath.clj:1017) shadow.build.classpath/find-js-resource (classpath.clj:998) shadow.build.resolve/eval14123/fn--14126 (resolve.clj:192) clojure.lang.MultiFn.invoke (MultiFn.java:243) shadow.build.resolve/resolve-string-require (resolve.clj:227) shadow.build.resolve/resolve-string-require (resolve.clj:210) shadow.build.resolve/resolve-require (resolve.clj:393) shadow.build.resolve/resolve-require (resolve.clj:386)
{:source-paths
["src/cljs"
"src/js"]
:dependencies
[[org.clojure/core.async "0.4.474"]
[cider/cider-nrepl "0.16.0"]
[org.clojure/tools.nrepl "0.2.12"]]
:builds
{:calva
{:target :node-library
:output-to "dist/calva.js"
:exports {:message repl.message/message}
:modules {:main {:entries [repl.message]}}
:devtools {}}}}:modules map. Will try with putting it back.:exports is relevantsrc/main or something and put everything in theresrc/main/calva folder and putting all the files in theresrc/main/calva/utilities.js and so onmain?src/test src/dev and so on laterrequire and module.exports/utilities and then tries to resolve ./state/utilities which is nilsrc/main and the namespace calva.repl.message it might work?const { message } = require('../../calva/main');import X from "goog:calva.repl.message";goog: prefix is a special syntax from the closure compiler to access namespacesextension.js should maybe solve the problem with where to output-to.calva to avoid the NPE) then I get things to compile and the extension to load. But I access the exported map incorrectly atm.wip-cljs-toolchain branch with these changes. If you want to try it, just move the generated dist/calva.js to src/main/calva before reloading the extension host.(boot/init state {.... is it posible to pass options like in a regular build def
...
:my-build {...
:compiler-options {:my-flag true}
} ....
}
that will show in (get-in @cljs.env/*compiler* [:options]) ?
looking at the source at shadow.cljs.bootstrap.browser , but first time digging under the hood... 🙂
use case is :
expanding / implementing something like https://github.com/bhauman/devcards/blob/ae6d1a459b91cfbccb4594c0e6970b2de289a4b3/src/devcards/core.clj#L133 deftest macro that works across cljs/browser.init(defonce c-state (cljs/empty-state))
(swap! c-state assoc-in [:options :my-option ] false)
(defonce _ (boot/init c-state
{:path "/js/bootstrap"
:load-on-init '#{b2repl.user}}
(fn []))
I did, it works. I wasnt sure it was the right way. Thanksboot/init is just about loading pre-compiled code. does nothing beyond thatFailed reading cache for scratchpad.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source:
shadow-cljs check takes quite a while to finish, which may as well just be the Closure compiler, but if it's slow due to the cache failing for some reason, it'd be great if it could be sped up.compile doesn't complain about cache?release? or watch?checkwatch isn't complaining, release is:
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
compile pleasewatch not to complainrelease first, before starting the watch, will do again, hang on...watch just uses the cache once otherwise it'll be in memory alreadyFailed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
shadow-cljs compileWARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available.
ns form?.clj fileWARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available. the file will not be available`❯ shadow-cljs compile scratchpad 1s 862ms
shadow-cljs - config: /Users/gnl/Code/re-frame-playground/shadow-cljs.edn version: 2.3.14
shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm compile scratchpad
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/gnl/scratchpad/0.1.0-SNAPSHOT/scratchpad.1.0-SNAPSHOT.jar!/scratchpad/core.cljc", it will not be available.
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/zprint/zprint/0.4.7/zprint-0.4.7.jar!/zprint/main.cljc", it will not be available.
[:scratchpad] Compiling ...
May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: node_modules/highlight.js/lib/languages/tp.js:14: WARNING - String continuations are not recommended. See
begin: '(AR|P|PAYLOAD|PR|R|SR|RSR|LBL|VR|UALM|MESSAGE|UTOOL|UFRAME|TIMER|\
^
May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)
------ WARNING #1 --------------------------------------------------------------
File: node_modules/highlight.js/lib/languages/tp.js:14:11
String continuations are not recommended. See
--------------------------------------------------------------------------------
nil
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
[:scratchpad] Build completed. (602 files, 483 compiled, 0 warnings, 49.68s)scratchpad so why is scratchpad.1.0-SNAPSHOT.jar on the classpath?lein install because I was messing around with lein checkouts before shadow-cljs and now I'm directly referring the source-path of the current versionlein checkouts supposedly needs that#" please(comment) block(comment) block(s/def ::foo #"hello world") this is fine so thats not it(s/def ::color (s/or :keyword keyword?
:literal (s/and string?
#(re-matches #"#[a-fA-F0-9]+" %)
#(or (= (count %) 7) (= (count %) 4)))))shadow-cljs check takes though, so apparently that's just the Closure compiler needing a while. Is there any way to speed this up, do you think? Somehow just recheck changed files or something or does it need to go over the whole project every time?long?shadow-cljs check-ns cljs.core or something like that{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9eedf6fffaf1e9b3fdf2f4eddeacb0adb0afab"}, :content ("[email protected]")}. should fix the cache issuerelease take?shadow-cljs check [:scratchpad] Build completed. (161 files, 0 compiled, 0 warnings, 4.80s) 34s 786ms shadow-cljs release [:scratchpad] Build completed. (161 files, 130 compiled, 0 warnings, 41.58s) 55s 530m
build completed and the actual time it took?check that's where the actual checking happens--verbosecheckingnpx shadow-cljs server runningcheck happens(shadow/check ...) in the REPL is done in 14seconds now.(shadow/check :scratchpad {:verbose true})message module looked resonably simple to start the porting with, but it is also very central to most everything Calva does. 😃utilities.js is sometimes not imported correctly, I get errors saying things like module$calva$utilities.X is not a function from places like hover.js and messages.cljs. However shadow.js seems to get a correct import, because it can use utilities.js functions.2.3.16cjs-to-es6 tool I used to migrate the exports did some weird stuffexport default { some, stuff, ... }import x from "./utilities" and then does x.someimport { some, stuff } from "..."export without the default and adjust the othersimport * as util from "./utilities" and then util.<thing>message.cljs module of course produces proper clojure maps. But the bencoder(.js) module of course has none of that. So I made a small migrate.cljs module that converts it back to a Javascript object. I use it from client.js before giving the message to bencoder. If I can port client.js to Clojurescript I will be able to remove this migration module, I think.[2018-05-01 23:27:27 - SEVERE] Unhandled REPL handler exception processing message {:ns user, :op eval, :code (ns learning.web.web-worker.core
(:require [learning.web.module.core :as m]
[keechma.toolbox.pipeline.core :as pp]
[keechma.controller :as controller]
[learning.js-utils :as j]
[keechma.toolbox.pipeline.controller :as pp-controller]
[goog.object :as go]))
, :file /home/matthys/projects/personal/learning/src/learning/web/web_worker/core.cljs, :line 1, :column 1, :session 6e5b0609-56d9-4d5f-9b08-91f627139e22, :id 15}
java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.errors$user_friendly_error$fn__16179
at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:290)
at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:289)
Is this something you've seen before? I can create an issue and try to figure out what's causing it, but it doesn't seem to do anything bad.(format "%d bottles of beers on the wall" 99)
=> TypeError: Cannot read property 'call' of undefined
at eval (eval at <anonymous> (), <anonymous>:1:23)
I have no idea how to go about figure out what I’m doing wrong here. I’m using shadow-cljs version 2.3.16.format never made it into any actual release of clojurescript..shadow-cljs for any reason? or using :cache-root "target/shadow-cljs" and deleting the target dir (lein does this)? or any other classloader/classpath trickery?format doesn't exist. there is goog.string.format but it requires a weird require setup (:require [goog.string.format] [goog.string :refer (format)])scopes something..js. Stepping the cljs code does not work very well.scopes.Error processing "scopes": TypeError: Line must be greater than or equal to 1, got -1
at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/node_modules/source-map/lib/source-map-consumer.js:584:13)variable cljs.core.inc redefined with type function(?): ?, original definition at EXTERNS:externs/clojure.core.js:12 with type function(number): number
cljs.core?[:div {:foo "bar"} "hello world"] when it also may be [:div "hello world"] and so on(def ^{:jsdoc ["@type Foo"]} foo ...):jsdoc meta is emitted as is into the codecheck is sort of a failed experiment in that regard{cljs.core/inc {:jsdoc ["whatever"]}[2018-05-03 02:09:34 - WARNING] HTTP startup failed java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found
2.2.18 worksdeps.edn? if so you might need to upgrade that:scope "runtime" dep so older versions of tools.deps wouldn't pick that up. https://dev.clojure.org/jira/browse/TDEPS-26["codemirror" :as codemirror].
thanks!, lein's plugin that lets me get a high level view of a project'.release-snapshot function I linked above produces a bundle-info.ednstu and found a tree in there.
makes sensesources entry in the source-map files? VS Code allows me to place breakpoints in my actual source files if I edit the source map. For instance for the message module in Calva shadow puts calva/repl/message.cljs in sources. If I change that to ../../src/main/calva/repl/message.cljs things start to work.:output-dir "out" in my build config, which puts the generated files in out/cljs-runtime):source-map-path as unsupported or non-applicable. But maybe that is actually meant to point to where the source maps are…:source-map-path only applies to the browser context I think when you want to have source maps in a different path not matching :asset-path.16?.16window.shadow$provide in my bundle, with 2.3.16.shadow$provide, since it's defined with var somewhere in the file.2.3.17:output-wrapper 😛:output-wrapper with multiple :modules:output-wrapperboolean logic.2.3.17. cool.npm install --save-dev shadow-cljsif we're just using the jar and compiling to browser, right? seems to work (get a warning)
babel) so you definitely should always add it:file-watch option to switch to :polling but I got an error about key (sorry can't seem to find that option to tell the exact error)node_modules.<link rel="stylesheet" href="/css/main.css">, I had a few issues to begin with, with electron development, first thing was that it couldn't figure the WS url, since I was opening the file using file:// URL and it was expecting http(s). But I suspect that issue isn't related to this (may be). I run the shadow-cljs dev server and open the URL from electron.:verbose and :debug mode for shadow-cljs, to see if it prints any log messages etc. but still quiet. Whenever a code change is made however, its super quick and I see changes immediately 😕:aliases of deps.edn? https://clojure.org/reference/deps_and_cli#_aliases It doesn’t see dependencies provided in :extra-deps as i don’t have way to specify which alias it should be using:npm-modulepages/*.js manually and require the CLJS code from them{:source-paths ["src"]
...
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main
{...}}
:dev {:source-paths ["env/src/dev"]}
:prod {:source-paths ["env/src/prod"]}
:compiler-options {:closure-warnings {:global-this :off}
?:devtools {:preloads [...]}<script>my.app.init(some_data_here);</script>:closure-defines also works:source-pathsgenerated htmlclosure-defines is what I need:builds {:app {:dev {:clojure-defines {...}}}}, right)?node server.js path/to/config.edn instead I can look at the config to see whats in itCompilerException java.lang.RuntimeException: No such var: shadow.cljs.devtools.api/start-worker, compiling:(null:1:1)the other two commands: (shadow.cljs.devtools.api/compile :app) (shadow.cljs.devtools.api/nrepl-select :app) are working flawlessly... Any ideas?
start-worker? watch is probably what you are looking for?tools.deps to fix the undertow issuerelease-snapshot eventually yes.lein-cljs-lambda is nice, but that couples me to cljs-build (and leiningen)shadow-cljs clj-repl? I'd like to set it to user instead of shadow.user as I have some helper functions defined there.:compiler-options:pseudo-names true, but then throw an exception when released without that option?node_modules .js file:pseudo-names you get long variable names that are less likely to clash, so it sometimes fixes things.a,b,c,d,... and then picks aa,ab,ac,... and so on. if you have enough vars you eventually get to ga which google analytics already uses and clashes// a.js
module.exports = {
setString: xxx
}
If a is an export of module b, and I require like this
(:require ["b" :refer [a]])
I can use setString with following code:
(def a-set-string (aget a "setString")) (a-set-string xxx)but this won't work
(a.setString xxx)is this an expected behavior?
a/setStringa.a/setString, it will say can't find variable a.b?(:require ["b" :refer [a]]) this doesn't make sense?a.js involved in that?"b" is "react-native" and a is Clipboard.(:require ["react-native" :refer (Clipboard)]) (.setString Clipboard "foo")a.setString working sometimes? well ... blame weird choices in the CLJS compiler. it only works for locals not ns aliases.setString a and a.setString is different?:as sets up a namespace alias so it acts like any other CLJS namespace(.b a) is not valid for CLJS namespaces and you must use a/b there(:require [clojure.string :as foo]) then foo is not a variable and you can only use (foo/upper-case ...) not (.upper-case foo):as must create a variable since some CommonJS uses module.exports = function() ... which would not be callable otherwisea.setString in any circumstance. the only exception to this is anything in the js/ namespace (eg. (js/console.log "foo")) IMHO.a.setString would not be valid in Clojure so I never do it.a.setString is even possible or allowed...
:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}
:bootstrapped-assets-for-test {:target :bootstrap
:output-dir "out/bootstrap"
:entries [eval-and-parse.botstrapped-libs]
:exclude #{cljs.js}}
....
and...
(ns eval-and-parse.core-test
(:require
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.browser :as boot]
[cljs.test :refer-macros [deftest is testing run-tests async]]))
(deftest library-gets-loaded-and-accesible-on-bootstrap-mode
(async done
(let [c-state (cljs/empty-state)]
(boot/init c-state
{:path "/bootstrap"
:load-on-init '#{eval-and-parse.bootstrapped-libs}}
(fn []
;; --------------- tests
(done))))))
I am getting ...
SHADOW import error ... ... ... .shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.module.main.append.js
........shadow-cljs/builds/test/dev/out/cljs-runtime/goog.net.xmlhttp.js:175
return new XMLHttpRequest();
Is this because of the env where the tests are running? ie: :target :node-test :entries [eval-and-parse.botstrapped-libs] seems to be missing an oc-state should be a comiler env. not an analyzer env. eg. (cljs.env/default-compiler-env)shadow.cljs.bootstrap.browser only works in the browser .. hence the name{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}
:browser-test instead of :node-testshadow.cljs.bootstrap.node that works the same(ns eval-and-parse.core-test
(:require
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.browser :as boot]
[cljs.test :refer-macros [deftest is testing run-tests async]]))shadow.cljs.bootstrap.browser which clearly has "browser" in the namenodeboot/init utility function assumes it is running in a browsernode. I just have not written that yet.fs/readFileSync:bootstrap target basically just pre-compiles files so they can be loaded at runtime:bootstrap then creates a index.transit.json containing all the information for the compiled filesboot/init loads that index and then loads whichever namespaces are requiredcljs.env/*compiler*c-statecljs.core you would find in (get-in @c-state [:cljs.analyzer/namespaces 'cljs.core])init completes)(:require ..... ["an-npm-lib" :as an-npm-lib] ...)where does that go in the
cljs.env/*compiler*:js-module-index is involvednsshadow.build.ns-form and shadow.build.resolve:entries [foo.bar] it get called with (resolve-entries state [foo.bar])shadow.build.npm has the npm specific stuffshadow.build.resolve(->> "
(do
(ns my.somns (:require [clojure.string :as string]))
(def g 90)
(ns my.r (:require [clojure.string :as string]))
(def lo 90)
)
"
cljs.tools.reader/read-string
(cljs.analyzer/analyze user-env)
cljs.compiler/emit-str
)
cljs.analyzer stuff thoughshadow-cljs stuff is pretty specific to shadow-cljsmodule$node_modules$codemirror$addon$edit$closebrackets
is that how shadow builds a look up for the bootstrapped libs?node_modules/codemirror/addon/edit/closebrackets.js file yesindex.transit.json data(ns foo.bar) would be :provides #{foo.bar} :requires #{cljs.core} and so on(ns foo.bar (:require ["react" :as r])) basically gets rewritten to (ns foo.bar (:require [module$node_modules$react... :as r]))git depsshadow-cljs as a git dep for example since it has some java code that needs to be compiled firstcljsjs.my-package and make a shim like the one in the link I send beforewss:// connection failsFirefox can’t establish a connection to the server at . browser.cljs:315:8
shadow-cljs: websocket error
error
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
explicitOriginalTarget: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }
isTrusted: true
originalTarget: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }
target: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }
timeStamp: 4402
type: "error"
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
browser.cljs:27:10
shadow-cljs: WebSocket disconnected! browser.cljs:27:10
shadow-cljs watch x via npm script and i'm receiving status 130 when Ctrl + Cing it. is this normal? never noticed it beforelein new luminus +re-frame or something similar.npm ERR! code ELIFECYCLE npm ERR! errno 130 npm ERR!
errors in file: /Users/devmbp42/tst/admin-destination-guides/node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less", :js-requires [], :js-errors [{:line 1, :column 0, :message "Character '@' (U+0040) is not a valid identifier start char"}], :goog-requires [], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /Users/devmbp42/tst/admin-destination-guides/node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.npm/get-file-info* (npm.clj:520)
shadow.build.npm/get-file-info* (npm.clj:428)
shadow.build.npm/get-file-info (npm.clj:556)
shadow.build.npm/get-file-info (npm.clj:553)
shadow.build.npm/find-resource* (npm.clj:650)
shadow.build.npm/find-resource* (npm.clj:610)(def asset-exts
#{"css"
"png"
"jpg"
"jpeg"
"svg"})require("./agent-navigation.less") in the code (or import)shadow-cljs clj-repl(in-ns 'shadow.build.npm) then (def asset-exts
#{"css"
"scss"
"sass"
"less"
"png"
"gif"
"jpg"
"jpeg"
"svg"})clj-repl itself which then acts the server(shadow/watch :app) in the REPL as wellnode_modules. this is getting out of hand. 😛nwb.config.js with a section for devServer and a proxy setting below that.proxy: ... entry in package.json is all I need? Does that apply to the dev server used by shadow?undertowless fix as well 😉1.10.238:dependencies in the shadow-cljs.edn ? When I do that it doesn't give me the shadow-cljs - updating dependencies message that I normally see.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2f5c474e4b4058024c43455c6f1d011c011d1f"}, :content ("[email protected]")}. you can set :devtools {:proxy-url ""} and all requests that would otherwise 404 will be proxied to that url insteadThe development server will only attempt to send requests without text/html in its Accept header to the proxy.cider-test-run-all-tests and cider-test-run-ns-tests. i guess i don't get this kind of emacs integration with shadow-cljs easily, right?cljc testsrlwrap shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn version: 2.3.19
shadow-cljs - connected to server
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 7.92s)
[1:1]~cljs.user=> JS runtime connected.
[1:1]~cljs.user=> (require '[cljs.test :refer (deftest is)])
nil
[1:1]~cljs.user=> (deftest foo-test (is (= 1 2)))
{:namespaces {cljs.user {:vars {foo-test #'cljs.user/foo-test}}}, :hooked true}
[1:1]~cljs.user=> (foo-test)
FAIL in (foo-test) (at C:476:9)
expected: (= 1 2)
actual: (not (= 1 2))
nil
[1:1]~cljs.user=>less files?tubax to my edn file, and when the page refreshes that has the dependency, I see this: The required namespace "ext.saxjs" is not available, it was required by "tubax/core.cljs".assets/deps.cljs filesax.js with it:default key in shadow cljs requires?
These are my requires:
["react" :refer [createFactory]] ["@atlaskit/field-radio-group" :default radio-group]Here I create a factory and use the component:
(def radio-group (createFactory radio-group))
(radio-group #js {...})
I assumed the call to radio-group here would result in a call to the factory and not the class radio group. Is this a wrong assumption?
If I change my require from ["@atlaskit/field-radio-group" :default radio-group] to ["@atlaskit/field-radio-group" :as radio-group] and my def from (def radio-group (createFactory radio-group)) to (def radio-group (createFactory radio-group/default)) my code does work.:default is tricky since it depends on whether the npm lib was packages as commonjs or es6:foreign-libs are not supported. it appears to be this package https://www.npmjs.com/package/saxnpm install sax and then create a (ns ext.saxjs (:require ["sax" :as sax])) (js/goog.exportSymbol "sax" sax")react-select component works great, but the X icon for removing a ‘chip’ from the multi-select mode is rendering as a ~A or something like that. It’s supposed to me ×. Would that have anything to do with shadow?<meta charset="UTF-8"> in your <head>2.3.21. as a bonus :devtools {:repl-init-ns my.app} is now also supported$ shadow-cljs watch app
shadow-cljs <project-home>
shadow-cljs - config: <project-home>/shadow-cljs.edn version: 2.3.19
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" java.lang.RuntimeException: Unable to find static field: ECMASCRIPT6 in class com.google.javascript.jscomp.CompilerOptions$LanguageMode, compiling:(shadow/cljs/closure.clj:712:13)
at clojure.lang.Compiler.analyze(Compiler.java:6792)
lein you need to put clojurescript into your depslein deps :tree which clojurescript version you are using (and which closure-compiler version)[org.clojure/clojurescript "1.10.238"] should fix it[org.clojure/clojurescript "1.10.238" :scope "provided"] is in the dependencieslein deps :tree if its actually used thoughcom.google.javascript/closure-compiler-unshaded version in particular as that is causing the problemv20180319$ lein deps :tree | grep clojure-compiler-unshaded lein ... Possibly confusing dependencies found: [thheller/shadow-cljs "1.0.20170629"] -> [org.clojure/tools.reader "1.0.0"] overrides [re-frame "0.10.5"] -> [org.clojure/clojurescript "1.9.908"] -> [org.clojure/tools.reader "1.0.5"] and [com.taoensso/tempura "1.2.0"] -> [com.taoensso/encore "2.94.0"] -> [org.clojure/tools.reader "1.2.1"] and [org.clojure/clojurescript "1.10.238"] -> [org.clojure/tools.reader "1.3.0-alpha3"] Consider using these exclusions: [re-frame "0.10.5" :exclusions [org.clojure/tools.reader]] [com.taoensso/tempura "1.2.0" :exclusions [org.clojure/tools.reader]] [org.clojure/clojurescript "1.10.238" :exclusions [org.clojure/tools.reader]] [thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]] overrides [ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] and [ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] and [ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"] and [ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"] and [ring "1.6.3"] -> [ring/ring-core "1.6.3"] Consider using these exclusions: [ring "1.6.3" :exclusions [ring/ring-core]] [com.rpl/specter "1.1.0"] -> [riddley "0.1.12"] overrides [thheller/shadow-cljs "1.0.20170629"] -> [aleph "0.4.3"] -> [manifold "0.1.6"] -> [riddley "0.1.14"] Consider using these exclusions: [thheller/shadow-cljs "1.0.20170629" :exclusions [riddley]] [thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]] -> [commons-fileupload "1.3.2"] overrides [ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"] and [ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"] and [ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"] and [ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"] and [ring "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"] Consider using these exclusions: [ring "1.6.3" :exclusions [commons-fileupload]] [compojure "1.6.0" :exclusions [instaparse]] -> [ring/ring-codec "1.0.1"] -> [commons-codec "1.6"] overrides [org.clojure/clojurescript "1.10.238"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.clojure/clojure]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"] and [thheller/shadow-cljs "1.0.20170629"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.msgpack/msgpack]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"] Consider using these exclusions: [org.clojure/clojurescript "1.10.238" :exclusions [commons-codec]] [thheller/shadow-cljs "1.0.20170629" :exclusions [commons-codec]]
thheller/shadow-cljs "1.0.20170629"?2.3.21lein though?project.clj things like yagni, kibit, yagni etc. I'm not sure how to do it in shadow-cljs:
:aliases {"eastwood" ["with-profile" "lint" "eastwood"]
"kibit" ["do"
["with-profile" "lint" "shell" "echo" "== Kibit =="]
["with-profile" "lint" "kibit"]]
"yagni" ["do"
["with-profile" "lint" "shell" "echo" "== Yagni =="]
["with-profile" "lint" "yagni"]]
"bikeshed" ["do"
["with-profile" "lint" "shell" "echo" "== Bikeshed =="]
["with-profile" "lint" "bikeshed" "--max-line-length=140"]]
"cljfmt-check" ["do"
["with-profile" "lint" "shell" "echo" "== cljfmt check cljs =="]
["with-profile" "lint" "cljfmt" "check" "src/cljs"]]
"cljfmt-fix" ["do"
["with-profile" "lint" "shell" "echo" "== cljfmt fix cljs =="]
["with-profile" "lint" "cljfmt" "fix" "src/cljs"]]
"check-deps" ["with-profile" "lint" "ancient" "all"]
"lint" ["do" ["eastwood"] ["kibit"] ["yagni"] ["bikeshed"] ["cljfmt-check"]]}
lein plugins require lein 😉lein. just curious why. lein plugins is good reason 😉:http-port 8020 :proxy-url ""(ns build.browser-post-process
(:require [shadow.build :as build]
[shadow.build.targets.browser :as browser]))
(defn core [{::build/keys [stage mode config] :as state}]
(let [state (browser/process state)]
(when (and (= :flush stage) (= :dev mode))
;; do task here
state)))
and config :target build.browser-post-process/core in a build called b2
when running shadow-cljs watch b2 in "shadow-cljs": "^2.3.20"
I get
...
...
shadow-cljs - watching build :b2
[:b2] Configuring build.
[2018-05-09 16:32:38 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.AssertionError: Assert failed: (build-api/build-state? %)
at shadow.build$configure.invokeStatic(build.clj:175)
at shadow.build$configure.invoke(build.clj:175)
...
...
am i missing something? cheers!build.browser-post-process/core must always return the state it receivesstate into the when(ns build
(:require [shadow.build :as build]
[shadow.build.targets.browser :as browser]))
(defn custom [{::build/keys [stage mode config] :as state}]
(let [state (browser/process state]
(when (and (= :flush stage) (= :dev mode))
(call-rsync)
state))
(browser/process state and also the closing paren for the (when
I can fix the docs and send a pull request if it helps you.{...
:builds {:ci-tests {:target :karma
:output-to "target/ci.js"
:ns-regexp "-spec$"}
below this in the how to run snnippets the build is referenced as ci
$ shadow-cljs compile ci $ karma start --single-run
shadow.cljs.devtools.api/nrepl-select and shadow.cljs.devtools.api/repl ?emacs user so I don't know how to configure anything. help is definitely welcome. repl delegates to nrepl-select nowadays so it doesn't matter much which on is used..js filesStep 7/14 : RUN npm install --save-dev shadow-cljs && shadow-cljs release client server ---> Running in 2718b0f65743 npm WARN app No repository field. npm WARN app No license field. +
clojure is missing? maybe thats not availableclojure - <<<"nil":devtools {:enabled false}:devtools {:console-support false} or not putting them on the classpath should do it(ns ^:dev/always my.thing).html files can pretty much just be .cljs files with one simple macroshadow-cljs watch app, I got the error: HTTP startup failed
java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found. Adding org.jboss.xnio/xnio-nio {:mvn/version "3.4.6.Final"} to deps.edn fixed it and the clojurescript compiled. Am I doing something wrong?tools.deps you must upgrade that to the latest version. needs this fix https://dev.clojure.org/jira/browse/TDEPS-26<my-awesome-component/> to be able to render it - this component should be bundled with it’s renderer. If it’s handwritten/Svelte or similar - it’s ok, but it can come with React or something else:browser targeted renderer in electron? It seems like (defonce fs (js/require "fs")) works for me but (:require ["fs" :as fs]) results in Uncaught SyntaxError: Unexpected token .
Also, this might be unrelated, but when I (defonce fsr (js/require "fs-readdir-recursive")) after installing the package with npm I get Uncaught ReferenceError: fs_readdir_recursive is not defined
This is all after adding only these modifications to the shadow-cljs electron example. Any obvious things I'm doing wrong here?require in the renderer or not?:js-options {:js-provider :require} in the renderer config which should make all packages work:js-provider :require. this will just call js/require basically instead of trying to bundle/convert the code that :browser usually doesfs thanks! Still having issues with the external node dep ["fs-readdir-recursive" :as fsr] ... (def x2 (fsr/read dir)) getting shadow.js.shim.module$fs_readdir_recursive.read is not a function(def x2 (fsr dir)) should worknpm install -g shadow-cljs git clone cd shadow-cljs shadow-cljs watch bootstrap-host bootstrap-support open
shadow-cljs watch bootstrap-host bootstrap-support bootstrap-workershadow-cljs watch bootstrap-host bootstrap-support:bootstrap-support
{:target :bootstrap
:output-dir "out/demo-selfhost/public/bootstrap"
:exclude #{cljs.js}
:entries [cljs.js demo.macro demo.lib]
:macros []}(require '[demo.lib :as x]) (js/console.log "x" (x/hello))
demo.selfhost.simplelein with cursive?"some-lib" :default SomeExport in the ns :require, etc., but not sure how to include the CSS. In JS I could use a similar import statement for the CSS, but here I've resorted to copying the file out of the npm_modules subdir and into my :http-root(assets/include "./some.scss")(assets/resource-uri "./some.png" :size "300x200")node-sass in my work project[cljsjs/auth0-lock "11.5.2-0"]auth0-lock to package.json"dependencies": {
"auth0-lock": "^11.6.1",
...
}
The required JS dependency "auth-lock" is not available, it was required by "ui_app/components/navbar.cljs". You probably need to run: npm install auth-lock
auth0-lock or auth-lock? which one is it? 😛(shadow.cljs.devtools.server/reload!)(shadow.cljs.devtools.server/reload!) from the timed out repl?:cljs/quit didn't timeout? I can't see what you sent before the first :cljs/quit and :cljs/quit technically cannot timeout since it is never sent to the client[:app] Compiling ... [:app] Build failure: The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".
[:app] Compiling ... [:app] Build completed. (928 files, 2 compiled, 0 warnings, 0.78s) [:app] Compiling ... [:app] Build failure: The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/core.cljs".
tools.namespace can critically mess with the internal state of the shadow-cljs server runtimereload! that at some point( "net/cgrand/xforms.cljc") after it failslog4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{HH:mm:ss,SSS}] %m%n
log4j.logger.shadow=DEBUGlog4j.properties[org.slf4j/slf4j-log4j12 "1.7.25"]
[log4j "1.2.17"]src/dev or dev source path already configuredlog4j.properties there with the content I pasted above[10:59:38,136] classpath updates total:2
[10:59:38,137] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,205] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,271] :shadow.cljs.devtools.server.system-msg/resource-update {:namespaces #{module$shadow$cljs$ui$dist$js$ui}, :deleted #{}, :updated #{module$shadow$cljs$ui$dist$js$ui}, :added #{}}[15:29:41,605] XNIO version 3.3.8.Final [15:29:41,639] XNIO NIO Implementation Version 3.3.8.Final 15:29:42.237 WARN [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "/Users/den/Dropbox/dev/code/vimsical/web-stack/resources/templates/frontend/core.cljs", it will not be available. 15:29:49.381 WARN [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "jar:file:/Users/den/.m2/repository/vimsical/web-stack/0.1.01/web-stack-0.1.01.jar!/templates/frontend/core.cljs", it will not be available. 15:29:49.610 WARN [shadow.build.babel] (nREPL-worker-1) can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs. shadow-cljs - HTTP server for :app available at shadow-cljs - server running at shadow-cljs - socket repl running at localhost:61783 shadow-cljs - nREPL server started on port 61785 [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (928 files, 3 compiled, 0 warnings, 7.10s) [:app] Compiling ... [:app] Build failure: The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".
[net.cgrand.xforms :as x]graphqlgraphql-tag, which translates GraphQL strings to an AST), I get this error:
source.js:15 Uncaught TypeError: Cannot call a class as a function
at new C.Source (source.js:15)
at C.parse (parser.js:34)
at c (graphql-tag.umd.js:136)
...function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
shadow.cljs.devtools.client.browser.js:811 WebSocket connection to '' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
:closure-defines {shadow.cljs.devtools.client.env/devtools-url ""}Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-8QW/FL/JEeHNL6TDE0m/ACLlRnGNJ8rr574pBcCZ1hM='), or a nonce ('nonce-...') is required to enable inline execution."content_security_policy": "'unsafe-inline'", to the manifest, but chrome doesn't allow that =/:whitespace, or anything that outputs everything in a single file, is there a way to do this in dev mode?:devtools {:devtools-url ...} is shorter or :devtools {:use-document-host false} should also work2.3.23 and this seems to work then https://github.com/thheller/shadow-cljs/blob/master/out/chrome-ext/manifest.json#L10script-src: 'self' 'unsafe-eval';2.3.21 before)::devtools-url manually for it, while before it worked without setup:whitespace compilation for it so it loads on a single filecontent-script?09:41:46.304 main.js:3027 GET 404 (Not Found) (anonymous) @ main.js:3027 env.load @ main.js:3020 (anonymous) @ main.js:3065 09:41:46.306 main.js:3027 GET 404 (Not Found) (anonymous) @ main.js:3027 env.load @ main.js:3020 (anonymous) @ main.js:3065 09:41:46.307 main.js:3027 GET 404 (Not Found) (anonymous) @ main.js:3027 env.load @ main.js:3020 (anonymous) @ main.js:3065 09:41:46.307 main.js:3027 GET 404 (Not Found) (anonymous) @ main.js:3027 env.load @ main.js:3020 (anonymous) @ main.js:3065 09:41:46.308
content-script is when you want a chrome extension to inject code in the user pagemanifest.json is like this:"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/content-script/main.js"],
"run_at": "document_start"
}
],:dev builds will never be reliable for this:release is probably the only safe thing for this:dev thing that only outputs a single file so the debug loader is not usedcljs, goog and so onAlthough the execution environments of content scripts and the pages that host them are isolated from each other, they share access to the page's DOM. "content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/content-script/main.js"],
"run_at": "document_start"
}
],:chrome-content-script {:target :browser
:output-dir "shells/chrome/js/content-script"
:asset-path "js/content-script"
:closure-defines {:devtools-url ""}
:modules {:main {:entries [fulcro.inspect.chrome.content-script.main]}}}:browser config is not really suited for this though"run_at": "document_start" to you? would document_idle be enough?document_idle will be enoughdocument_start?document.write to load scriptsdocument_start that is true:target :node-script:
var shadow$provide = {};
#!/usr/bin/env node
(function(){
...
shadow-cljs node-repl?defmacro? using yes, writing no.node-repl.shadow-cljs clj-replnode-repl since that is a CLJS repl(ns shadow-macros.core
(:require
[shadow-macros.macros :include-macros true :as macros]))shadow-macros/macros.cljs AND the .clj file.clj file exists this fails------ WARNING #1 -------------------------------------------------------------- File: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: com/cognitect/transit/types.js:384:70 variable Buffer is undeclared --------------------------------------------------------------------------------
:require-macros and that did not work either..cljs file and .clj file with the same namecljs file does a require-macros for itself.macros namespaces. thats just makes things more confusingapp/lib.cljapp/main.cljs.cljs file but it is very important to have that:require-macros or :include-macros all over the place:require-macros ONCE and only to require itself:include-macros then?shadow-cljs check your-build might helpImplicit Sugar:require-macros from recent defn podcast where you've talked about it 😄chrome.runtime.OnInstalled :jvm-opts ["-Dclojure.spec.compile-asserts=false"] in shadow-cljs.edn but it's not seeming to be working. is there a standard way to address this?(:require ["js-lib" :as js-lib"] ...) string form causing issues but I could be wrong:chrome-content-script
{:target :browser
:output-dir "shells/chrome/js/content-script"
:asset-path ""
:modules {:main {:entries [fulcro.inspect.chrome.content-script.main]}}
:devtools
{:devtools-url ""
:http-root "shells/chrome/js/content-script"
:http-port 8020}}document_idle for now:browser is complete overkill for this though. :chrome-ext
{:target :chrome.content-script
:output-to "out/chrome-ext/background.js"
:entry demo.chrome-bg}Uncaught TypeError: Cannot call a class as a function error in shadow-cljs 2.3.22_classCallCheck(this, Source); from the source of the npm modulenode_modules/? I see that I can redirect what it resolves to, but the only options I see are either :global or :npm. I'd like to stick it in another dir that I can commit to source controlgraphql right?node_modules/graphql directory and publish it under @lilactown/graphql or so:resolve {"graphql" {:target :npm :require "@lilactown/graphql"}}public/index.html that doesn't need to be moved or anything:browser one?ctrl+shift+e trying to profile my background page 😛lein deps :tree:target :chrome.content-script I though it was outmaster:chrome-bg
{:target :chrome-extension
:output-to "out/chrome-ext/background.js"
:entry demo.chrome-bg}
:chrome-content
{:target :chrome-extension
:output-to "out/chrome-ext/content-script.js"
:entry demo.chrome-content}:chrome-extension for all, I would guess content-scripts would have a different setting compared to background/popups/devtools, I guess we will figure that soon:chrome-extension:browser does that we don't need there?manifest.json:chrome-extension generates a single filewatchscript-src 'unsafe-eval':flush (362 ms) with index map with only cljs.core:flush (9 ms) without any mapsmaster now has source maps and REPL but not live-reload doesn't work:autorun is specifically only for :node-test? what else do you mean?shadow compile test with :autorun true it will launch the node ./out/node-tests.js and spit the results, but then the node process dies… is there a built in way to keep rerunning that node command every time node-tests.js changes?shadow watch test.23 version yet, not sure how to use it shadow from masterlein installlein installnpm stuff. it is not required.[:chrome-content-script] Build failure:
invalid require
{:entry [fulcro.inspect.chrome.content-script.main]}
ExceptionInfo: invalid require
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.resolve/resolve-require (resolve.clj:492)
shadow.build.resolve/resolve-require (resolve.clj:482)
shadow.build.resolve/resolve-entry (resolve.clj:496)
shadow.build.resolve/resolve-entry (resolve.clj:495)
clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
clojure.core/reduce (core.clj:6747):entry is to be a namespace, right?.nrepl-port like figwheel does? That way cider could auto-detect the port:entry. if the entry "reaches" the newly added file it will be automatically added"background":
{"persistent":false,
"scripts":
["out/background.js", "out/cljs-runtime/goog.debug.error.js",
"out/cljs-runtime/goog.dom.nodetype.js",
"out/cljs-runtime/goog.string.string.js",
"out/cljs-runtime/goog.asserts.asserts.js",
"out/cljs-runtime/goog.reflect.reflect.js",
"out/cljs-runtime/goog.math.long.js",
"out/cljs-runtime/goog.math.integer.js",
"out/cljs-runtime/goog.object.object.js",
"out/cljs-runtime/goog.array.array.js",
"out/cljs-runtime/goog.structs.structs.js",
"out/cljs-runtime/goog.functions.functions.js",
"out/cljs-runtime/goog.math.math.js",
"out/cljs-runtime/goog.iter.iter.js",
"out/cljs-runtime/goog.structs.map.js",
"out/cljs-runtime/goog.uri.utils.js",
"out/cljs-runtime/goog.uri.uri.js",
"out/cljs-runtime/goog.string.stringbuffer.js",
"out/cljs-runtime/cljs.core.js",
"out/cljs-runtime/clojure.string.js",
"out/cljs-runtime/shadow.cljs.devtools.client.console.js",
"out/cljs-runtime/shadow.module.shared.append.js",
"out/cljs-runtime/demo.chrome_bg.js",
"out/cljs-runtime/shadow.module.background.append.js"]},manifest.edn matters. manifest.json is generated.:browser?:chrome-background {:target :browser
:output-dir "shells/chrome/js/background"
:asset-path "js/background"
:devtools {:devtools-url ""}
:modules {:main {:entries [fulcro.inspect.chrome.background.main]}}}:target:browser is no longer used.:browser, I don't have to refresh the extension when I do updates on the background codeOnInstalled callback(ns demo.chrome-bg) (js/console.log "chrome-bg")
:background {:entry demo.chrome-bg}chrome-bg in the log:browser is that the code is loaded async and from remote:browser. all of this could work identically in :chrome-extension:background since you can't use OnInstalled for exampleOnInstalled can only run in the initial code, so async loading for it on :browser is broken, correct?:browser loader is semi-smart and detects if it can document.write which means it appears sync:browser. that is not the intention here. keeping all the features but with easier configs is the goal. :browser is too complicated and does too many things we don't needmanifest.edn vs. having multiple separate builds:content-scripts can always load async remotely. they don't have any special lifecycle callbacks anyways right? eg. no OnInstalleddocument_start then that breaksdocument_start:shadow/entry?:entry not sure what else we needentry key for anything(js/chrome.runtime.reload) actually does a full reload of the extension. could bind that to a key in cursive.:dev/before-load but it loses all state so not super greatshadow-cljs watch app does both in one command. Other than having the ability to stop one or the other, is it advised to use the shadow-cljs command over npx?npx is only useful in case you do not have shadow-cljs installed globally. if you do you can skip npx.server instance separately however is recommended but not requiredwatch is fine if you only have one buildlein works fine so I recommend that.deps.cljs at the root of you lib via {:npm-deps {"react" "some-version"}}shadow-cljs npm-deps:npm-deps support in CLJS that might not work too well outside shadow-cljscljsjsdeps.edn is going to support npm anytime soonmanifest.edn, did you though about how to add extra compilations there? (besides content-script and background):page-action {:shadow/entry foo.bar :shadow/output-to "page_action.js"}popup.html and just <script src="page_action.js">130 on ctrl+c expected?cli version: 2.3.23 node: v8.11.2npm -v?6.0.1v9.4.0 and 5.6.0npm -v seems like overkill)130 a few days ago. no idea where that comes from but it is not happening in v5document_start)document_start? I tested on idle and that worked.main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.120 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.120 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.121 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.121 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.140 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.140 main.js:3016 GET 0 () (anonymous) @ main.js:3016 env.load @ main.js:3009 (anonymous) @ main.js:3054 20:57:00.141
GET anything? maybe outdated?idle, let me try that just to check if the document_start is really the problem:content_scripts [{:matches ["<all_urls>"]
:entry fulcro.inspect.chrome.content-script.main
:run_at "document_idle"}]:content-scripts_ in keywords 😛-- team too- will be converted to _ before writing the JSON:content-scripts not :content_scriptsbrowser.cljs:310 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
:devtools {:devtools-url ""} might work??192.168.0.121 refused to connect.ifconfig maybe?en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether a4:5e:60:d9:ad:3b inet 192.168.0.121 netmask 0xffffff00 broadcast 192.168.0.255 media: autoselect status: active p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 ether 06:5e:60:d9:ad:3b media: autoselect status: inactive awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 ether 1a:77:42:f7:ca:78 inet6 fe80::1877:42ff:fef7:ca78%awdl0 prefixlen 64 scopeid 0x8 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:00:34:ba:00 media: autoselect <full-duplex> status: inactive en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:00:34:ba:01 media: autoselect <full-duplex> status: inactive bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=63<RXCSUM,TXCSUM,TSO4,TSO6> ether 6a:00:00:34:ba:00 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en1 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 9 priority 0 path cost 0 member: en2 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 10 priority 0 path cost 0 media: <unknown type> status: inactive utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 inet6 fe80::8ea2:2eee:6e4c:561e%utun0 prefixlen 64 scopeid 0xe nd6 options=201<PERFORMNUD,DAD> utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 inet6 fe80::d746:7a38:7b:f32%utun1 prefixlen 64 scopeid 0xf nd6 options=201<PERFORMNUD,DAD> utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 inet6 fe80::bdc0:d124:6bee:608b%utun2 prefixlen 64 scopeid 0x10 nd6 options=201<PERFORMNUD,DAD> EHC64: flags=0<> mtu 0 en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV> ether 40:6c:8f:55:95:d7 nd6 options=201<PERFORMNUD,DAD> media: autoselect (none) status: inactive fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078 lladdr 00:0a:27:02:00:49:ca:5f nd6 options=201<PERFORMNUD,DAD> media: autoselect <full-duplex> status: inactive
which is my machinedocument.location so its easier there but that breaks for chrome exts:devtools-url should fix it:devtools-url works finedocument_start works fine:before-load hook prevent reloading by returning false or something like that?{:source-paths ["src"]
:dependencies [[reagent "0.8.1"]]
:builds {:app {:target :node-script
:output-to "target/main.js"
:main server.main/main!
:devtools {:after-load server.main/reload!}}}}
This is my require:
(ns server.main
(:require [reagent.dom.server :refer [render-to-static-markup
render-to-string]]))
The required namespace "react" is not available, it was required by "reagent/impl/template.cljs".although I see react listed in the dependencies of Reagent?
$ /tmp/html.js
internal/modules/cjs/loader.js:573
throw err;
^
Error: Cannot find module 'react-dom/server'
while it works in the project directorypackage.json there with the dependencies you needshadow-cljs - config: /Users/kenny/compute_software/clake/cli/shadow-cljs.edn version: 2.3.21 shadow-cljs - starting via "clojure" [2018-05-19 15:10:33 - WARNING] failed to inspect resource "/Users/kenny/compute_software/clake/cli/test/clake_cli/core_test.cljs", it will not be available. [:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (26 files, 0 compiled, 0 warnings, 1.98s)... and could not figure out what was wrong. I had a pretty vanilla test file:
(ns clake-cli.core-test (:require [cljs.test :refer :all])) (deftest my-test (is (= 1 1)))Turns out I forgot
:refer :all isn't support in CLJS which caused that issue. I suggest make the error message more clear for this case (especially because that is the default file Cursive generates for CLJS tests).22 | ^{:key letter} [letter-button letter])
23 | "Now in the drum-kit-lesson"])
24 |
25 | (create-lesson letters)
-------^------------------------------------------------------------------------
ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Named
clojure.core/namespace (core.clj:1589)
clojure.core/namespace (core.clj:1589)
cljs.analyzer/fn--1733 (analyzer.cljc:1491)
cljs.analyzer/fn--1733 (analyzer.cljc:1473)
clojure.lang.MultiFn.invoke (MultiFn.java:251)
cljs.analyzer/analyze-seq* (analyzer.cljc:3348)
cljs.analyzer/analyze-seq* (analyzer.cljc:3346)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3353)
--------------------------------------------------------------------------------
(defmacro create-lesson [component]
`(def 'lesson (if style
(with-meta `'~component {:style style})
`'~component)))
'lesson. that is the error you are seeing.(def ~'lesson ...) should do that(def lesson (with-meta fn {:style style})) if the style var was definedtest folder to my source-paths, and for some reason, now on my chrome compilations I'm getting start code from fulcro-spec, which doesn't make sense, on my chrome entry points there is nothing pointing to fulcro-spec, and this start code from spec is messing up other things, just removing the test from :source-paths and recompiling fixes it, any idea what that might be?(shadow.cljs.devtools.api/find-resources-using-ns 'fulcro.spec) or whatever the ns is.shadow/nrepl.port by default. you can however configure a fixed portcljs.user in the test directoryshadow.loader where the moduleInfo is undefined, and thus 'isLoaded' is undefined.
I have modules defined as in {:module-loader true, :modules {:main {:entries []}, :login {:entries [app.login] :depends-on #{:main}}}}. It compiles fine. I get a module-loader.edn and module-loader.json in my :output-dir, containing {:module-uris {:login ["files paths", …]} :module-infos {:login #{}}}
In the console:
shadow.loader.load("login"); // => Error: Unknown module: login
shadow.loader.set_loaded("login") // => Cannot read property 'onLoad' of undefined
shadow.loader.mm.getModuleInfo("login") // => undefined
I have been through the doc multiple times but now I'm feeling stuck. Did I miss something ?main.js. it should contain a call to shadow.loader.setupmain.js ends with SHADOW_ENV.load(["path", …]) and no call to loader.setup in the file unfortunately. Neither in login.js 😕main.js is the first file to load, no code is referencing shadow.loader before it finish loadingshadow.cljs.devtools.client.browser.module_loaded('main');
shadow.loader.enable();
cljs.core to the entries of main. there might be a bug with empty :entriesisLoaded call was renamed to isActive. so that explains why that failsisLoaded is still around. you are just missing the setup call for some reason.cider-connectmaster has support for release. I changed :entry to :shadow/entry as you suggested so you need to update those.▼ and ▶ for tree views, but on adv compilation they are rendering as â–¼ and â–¶, you know what that can be about?:browser target<meta charset="UTF-8"> typically fixes it for the browser. not sure about chrome extension though.console.log("\u25B6\u2764\u25C0"); which works fine without setting a charset. Closure will optimize and turn that into console.log("▶❤◀"); however which then fails to load properly without a specified charset. see https://dev.clojure.org/jira/browse/CLJS-1547?focusedCommentId=42617:compiler-options {:closure-output-charset "US-ASCII"} it will keep the same escaped sequence that CLJS emits and the problem goes awaywatch build to send updates to the browser. Seems a two-part problem; first, figuring out how to get (require 'the-ns :reload) to work (currently I have to dissoc a namespace from :cljs.analyzer/namespaces before it will do anything), maybe modifying shadow.cljs.bootstrap.browser/load-namespaces to accept a :reload parameter, and second - any idea how a client could be notified when namespaces in a bootstrapped build are modified? i would guess one just wants a callback to be fired, maybe w/ a list of changed namespaces, as there is no way for shadow to know anything about what’s going on with compiler states in the browser:reload?load-namespaces will reload itshadow.cljs.bootstrap.browser. I implemented that as a proof of concept but what you are asking goes way beyond what I planned for it$ shadow-cljs compile em-admin shadow-cljs - config: /Users/grav/repo/eddie-michel/em-poc/shadow-cljs.edn cli version: 2.3.23 node: v8.6.0 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm compile em-admin Exception in thread "main" java.lang.RuntimeException: No such var: module-graph/validate-inputs, compiling:(shadow/build/cljs_closure.clj:931:3) at clojure.lang.Compiler.analyze(Compiler.java:6792)What to do?
:lein true in my shadow-cljs.edn, and I’ve added [thheller/shadow-cljs "2.3.23"] to the deps in my project.cljmy-package.namespace I would assume maps to my_package.namespace, but that ends up being undefined. Works if I remove the dash from the namespace and use e.g. mypackage.namespace(def proc (watch))
(def output-chan
(let [c (chan)]
(tap (:output-mult proc) c)
c))
(defn bootstrap-compiled-sources [{:keys [type build-config info]}]
(when (and (= :build-complete type)
(= :bootstrap (:target build-config)))
(:compiled info)))
(def bootstrap-loop
(go-loop []
(let [evt (<! output-chan)]
(some-> (bootstrap-compiled-sources evt)
(println))
(recur))))
my-package.namespace maps to my_package.namespace but must also be in a my_package/namespace.cljs. otherwise - is totally fine.(tap (:output-multi proc) c true) so the c closes when the worker stopswebpack-bundle-analyzer for shadow-cljs?undefined
I import them like this:
[“moment” :default moment]
[“react-datepicker” :default DatePicker]:as DatePicker or :as moment. you can try using :as x always and (js/console.log x) to see which properties it has. :default only works if there is a default property."module": "es" - so I thought it should provide es modules 😅:runner-ns:ns-regexp "my.only.namespace-test":dev {:compiler-options {:devcards true}} does?{:something 1
:chrome/options {:matches [""]
:run-at "document_idle"}}
{:chrome/matches [""]
:chrome/run-at "document_idle"
:something 1}:compiler-options, :js-options etc.cider/cider-nreplbrowser.cljs:39 Uncaught TypeError: Cannot read property 'written' of undefined
useing
shadow-cljs.edn cli version: 2.3.23 node: v9.6.1tried deleteing
target, this is a website I did few months back, and I updated shadow-cljs, and now can't see my changes
stacktrace
browser.cljs:39 Uncaught TypeError: Cannot read property 'written' of undefined
at Object.shadow$cljs$devtools$client$browser$goog_is_loaded_QMARK_ [as goog_is_loaded_QMARK_] (browser.cljs:39)
at shadow$cljs$devtools$client$browser$src_is_loaded_QMARK_ (browser.cljs:48)
at Function.G__35120__1 [as cljs$core$IFn$_invoke$arity$1] (core.cljs:4222)
at cljs.core.filter.cljs$core$IFn$_invoke$arity$2 (core.cljs:5124)
at cljs.core.LazySeq.sval (core.cljs:3394)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (core.cljs:3452)
at Object.cljs$core$seq [as seq] (core.cljs:1210)
at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2445)
at cljs.core.LazySeq.cljs$core$IReduce$_reduce$arity$3 (core.cljs:3458)
at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2517)
TypeError: React.DOM.p is undefined. I'm using shadow-cljsjs.(:require [goog.events :as events]
[p5.core]
[p5.tiled-map]
...
When I try to compile this with shadow-cljs I get
The required namespace "p5.core" is not available, it was required by "play_cljs/core.cljs".Is there a way to make this work? (edit: I have already installed p5 in my project with npm)
React.DOM stuff has been deprecated for a while.play-cljs with shadow-cljs but I forgot how exactly. typically you'll just need to install p5 via npm and create a shim file ala https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjsexport default () =>
<BootstrapTable keyField='id' data={ products } columns={ columns } />
[:> BootstrapTable {:data (clj->js content) :keyField "id"}]] or [BootstrapTable {:data (clj->js content) :keyField "id"}]]Cannot call a class as a function["react-bootstrap-table-next" :default BootstrapTable]BootstrapTable?(defn start []
(js/console.log "Starting...")
(r/render [app]
(.getElementById js/document "app")))
(defn ^:export init []
(start)):columns key abovelein deps :tree and see which com.google.javascript/closure-compiler-unshaded version you get? [com.google.javascript/closure-compiler-unshaded "v20180506"].21 already had the upgraded version but guess notshadow-cljs.edn?:app bundle… What would I have to do?devcards.core then it will not be included.(:require [devcards.core ...])npm packages installed but it would not matter to your build unless you require them alldeps.edn or lein to still do it if you really want toshadow-cljs -A:some-alias compile the-buildclj -A:x -m shadow.cljs.devtools.cli compile the-buildshadow-cljs directly. clj works just fine too. just a tiny bit more to type out(ns ...
(:require
["react-bootstrap-table-next" :default BootstrapTable]
["react-bootstrap-table2-filter" :refer [textFilter] :default filterFactory]))
(defn generate-columns [fields]
(map (fn [[fieldname title props]]
(merge {:dataField fieldname
:text title}
props)) fields))
(let [
columns (generate-columns
[["name" (i18n [:general/name]) {...
:filter (textFilter) )}]
["email" (i18n [:general/email]) {...}]])]
[:div [:> BootstrapTable {:data ...
:keyField "id"
:filterFactory (filterFactory)
:columns columns}]]))
shows the filter, properties to set work fine, but when I start to type (and hence, the filter should start):
text.js:102 Uncaught TypeError: c.props.onFilter is not a function
at text.js:102
:onFilter prop somewhere(def columns
(-> [{:dataField "id"
:text "Product ID"}
{:dataField "name"
:text "Product Name"
:filter (textFilter)}
{:dataField "price"
:text "Product Price"
:filter (textFilter)}]
(clj->js)))generate-columns route(clj->js columns)clj->js:filter (filterFactory) not :filterFactory (filterFactory):after-load, it should be able to give you a super high quality error message(s/def ::y (map-spec :req {:foo string?} :closed? true))
(s/explain ::y {:foo "1" :x 1}):chrome-extension support. I extended it to support other scenarios like page/browser actions and it all works ok enough but has some drawbacks. might just end up recommending using a separate build for the extreme edge casesjs/. Is this only available during compilation.(shadow.cljs.devtools.api/nrepl-select :my-target) which drops me in the cljs-repl.:my-target is from your shadow-cljs.edn)Baruchs-MBP-2% shadow-cljs compile chrome-ext shadow-cljs - config: /Users/baruchberger/stah/cljsc2/shadow-cljs.edn cli version: 2.3.23 node: v8.9.4 shadow-cljs - starting ... [:chrome-ext] Compiling ... Target ":chrome-extension" for build :chrome-ext was not found. The built-in targets are: - :browser - :browser-test - :node-script - :node-library - :npm-module - :karma - :bootstrap
masterlein install:chrome-extensionsource-paths as in my project.clj with lein, but am getting
The required namespace "cljsc2.cljs.content-script" is not available.. Any hints?content-script.cljs? shadow-cljs is pretty strict about enforcing _ but the error message for that is still missing (or rather ends up in the wrong place)The required namespace "cljsc2.cljs.contentscript" is not available..src you should have a src/cljsc2/cljs/contentscript.cljs correct?{:source-paths ["src/cljsc2/cljs"]
:dependencies [[org.clojure/clojurescript "1.9.946"]
[fulcrologic/fulcro "2.5.2"]
[org.clojure/core.async "0.3.443"]
[com.cognitect/transit-cljs "0.8.243"]
[cljsjs/d3 "4.12.0-0"]]
:builds {:chrome-ext {:target :chrome-extension
:extension-dir "out/chrome-ext"}}}
src would be correctnpm install react react-dom[:chrome-ext] Build completed. (257 files, 135 compiled, 0 warnings, 57.26s) Hooray. Let's see if it runs!master though. https://github.com/thheller/shadow-cljs/issues/279#issuecomment-392007641Uncaught TypeError: cljsc2.cljs.contentscript.core.init_BANG_ is not a functionUncaught TypeError: $goog$string$$.format is not a function ?
I thought Closure library is somewhat bulletproof to name munginggoog.string.format you need to require the goog.string namespace and goog.string.format namespace,
look at this example : https://github.com/reagent-project/reagent-utils/blob/master/src/reagent/format.cljs#L6:content-scripts entry from manifest.edn since that will now be generated from :shadow/outputs:shadow/entry there is no longer correct(:require ["./some-script.js" :as x]) and its exports will be available via CLJS.cljs file"/somewhere/some-script.js" as well:source-paths"out/cljs-runtime/cljs.pprint.js", ...],
*print-length* which messes with things in pretty annoying waysmaster should fix that:advanced(fn [^js cell] ...) would fix one of them. is native interop and the compiler sometimes needs a hint to figure out if you are working with a JS object which it shouldn't rename:devtools {:after-load ns/fn} is the analog. But I get can't find fn cljsc2.cljs.contentscript/on-js-reload. Funnily enough it also reports that when I remove that from the shadow-cljs.edn and add ^:dev/after-load as function meta.window.cljsc2....2.3.24 which has the latest version of the chrome stuff as welllein install later:chrome-extension yet so I still consider that a WIPclj-runshadow.loader can’t be used immediately when a page loads? one must have it called later (or after a 0ms timeout) otherwise an “Unknown module: …” error pops upshadow.loader.setup function call is added to the end of the base module<script async src="/js/base.js"></script>(defn init []
(routing/listen
(fn [{:keys [path] :as location}]
(try-module-load))))
(-> js/document
(.addEventListener "DOMContentLoaded" init))
(init) or so<script type="shadow/run" data-fn="my.app/init">["some" "args"]</script> which basically invokes (my.app/init "some" "args") when the JS is loaded(cljs 'some.ns/fn & args){:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "32415a53565d451f515e584172001c011c0007"}, :content ("[email protected]")} which changes the shadow.loader init so it should be immediately availableutils.async_fetch._GT__BANG__BANG_.call(null,c,"hello");
^
TypeError: Cannot read property 'call' of undefined
>!! does not exist in CLJS>!?goresolve macro is not exactly the thing I would want/expect for module loading; there’s no need to include the var’s metadata, and it shouldn’t be necessary to provide the symbol statically at compile time. I am looking at using a function like this instead:
(defn resolve-to-value [sym]
(->> (.split (str sym) #"[./]")
(map munge)
(to-array)
(apply gobj/getValueByKeys js/window)))
then I can pass symbols around as values instead of having to wrap them in the resolve macro,
(def handlers {:home 'my-app.views.pages/home})
...
(resolve-to-value (:home handlers))
Otherwise, I had to use something like a case statement
(defn handler-var [k]
(case k
:home (resolve 'my-app.views.pages/home))
:advancedshadow.loader business. (async-require [[some.ns :refer (foo)] [some.thing :as x]] (x/bar) (foo))
:require-ish forms and the body would execute when all required modules are readycase form b/c of the :advanced bit.(:require ["@material-ui/core/Button" :default Button]) [:> Button {:variant "raised" :color "primary"} "Hello World"] might workimport React from 'react';
import Button from '@material-ui/core/Button';
const App = () => (
<Button variant="raised" color="primary">
Hello World
</Button>
);yarn add mdbreact (:require ["mdbreact" :as mdb]) [:> mdb/Button ...](defn main-panel [] [:div "foo"])
after-load callback to actually re-render?on-jsload I think["@material-ui/core/Styles" :default Styles]
["@material-ui/core/AppBar" :default AppBar]
["@material-ui/core/Toolbar" :default Toolbar]
["@material-ui/core/Typography" :default Typography]
["@material-ui/core/Button" :default Button]
...
[@material-ui/core/ :foo [Styles AppBar Toolbar]] or import all or …?const styles = {
root: {
flexGrow: 1,
},
};
function SimpleAppBar(props) {
const { classes } = props;
return (
<div className={classes.root}>
<AppBar position="static" color="default">
<Toolbar>
<Typography variant="title" color="inherit">
Title
</Typography>
</Toolbar>
</AppBar>
</div>
);
}
SimpleAppBar.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(SimpleAppBar);
while I am using reagent with hiccup.2.3.27 I finally merged the :build-hooks stuff I had laying around since forever. should have done this way sooner but here it is now: https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooksclj-run stuff alreadyindex.html for the build. :build-hooks could now do stuff like that.clj-run:compile-start, :timings, :modules, :sources, :compiled:compiled is the closest, but I didn’t see that it indicates which file changed:compiled is the set of resources that where recompiled:sources is the list of all sources in that build:sources where :resource-id is contained in :compiled gives you the sources that were recompiled(->> sources
(filter #(contains? compiled (:resource-id %)))
...)active-namespaces (set (keys (:cljs.analyzer/namespaces @carton/compiler)))
compiled-namespaces (-> (:sources @bootstrap-env/index-ref)
(select-keys compiled)
(vals)
(->> (filter (comp active-namespaces :ns))))
def’d things appearing in arbitrary/nice wayspathom for using graph queries to expose shadow-cljs internal datapathom looks promising in that the same description of analyzer data could be resolved on the shadow side or in the browser, depending on which compiler-env you wanted to inspect(-> (shadow.cljs.devtools.config/load-cljs-edn) :builds keys)Error detected while processing function <SNR>28_piggieback[1]..fireplace#platform: line 32: E605: Exception not caught: Fireplace: :Connect to a REPL or install classpath.vim
[2018-05-28 13:02:24 - SEVERE] Unhandled REPL handler exception processing message {:id fireplace-lap1-1527501741-5, :op clone}
java.net.SocketException: Socket closed
at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
at clojure.tools.nrepl.transport$bencode$fn__20978.invoke(transport.clj:103)
at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
at clojure.tools.nrepl.middleware.session$session$fn__22346.invoke(session.clj:188)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__21967.invoke(middleware.clj:22)
at shadow.cljs.devtools.server.nrepl$start$fn__22599.invoke(nrepl.clj:344)
at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
at clojure.tools.nrepl.server$handle$fn__22419.invoke(server.clj:28)
at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
at clojure.lang.AFn.call(AFn.java:18)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:844)
clonelein with-profiles +cljs repl and then (require 'repl) (repl/go)localhost port 8202cider-nrepl in project.clj first. its still v16tools.deps or leiningen for dependency management, shadow-cljs will ignore -d command line argument?lein the command is printed on startup, you can literally just use that instead-d, this will not work if I use leiningen or tools.deps.:lein you are effectively using lein not shadow-cljsopts has :dependencies key which are those added by -d https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L2868bb0cf436a928a804e42ec094e77b7e774a5aac3 is where it breaks fireplace.user=> [13:38:34,327] nrepl-receive {:id "fireplace-lap1.local-1527503914-1", :op "clone"}
[13:38:34,332] nrepl-receive {:id "fireplace-lap1.local-1527503914-2", :op "describe", :verbose? 1}
[13:38:34,367] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-3", :op "eval"}
[13:38:34,373] nrepl-receive {:id "fireplace-lap1.local-1527503914-4", :op "classpath"}
[13:38:36,086] nrepl-receive {:id "fireplace-lap1.local-1527503914-5", :op "clone"}
[13:38:36,089] nrepl-receive {:id "fireplace-lap1.local-1527503914-6", :op "describe", :verbose? 1}
[13:38:36,119] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-7", :op "eval"}
[13:38:36,125] nrepl-receive {:id "fireplace-lap1.local-1527503914-8", :op "classpath"}
[13:38:36,132] nrepl-receive {:id "fireplace-lap1.local-1527503914-9", :op "clone"}
[13:38:36,135] nrepl-receive {:code "((or (resolve 'cider.piggieback/cljs-repl)(resolve 'cemerick.piggieback/cljs-repl)) :browser)", :id "fireplace-lap1.local-1527503914-10", :op "eval"}
[13:38:37,311] nrepl-receive {:id "fireplace-lap1.local-1527503914-11", :op "close"}
[13:38:37,314] nrepl-receive {:id "fireplace-lap1.local-1527503914-12", :op "close"}
[13:38:37,316] nrepl-receive {:id "fireplace-lap1.local-1527503914-13", :op "close"}
Bye for now!
user=> [13:39:21,353] nrepl-receive {:id "fireplace-lap1.local-1527503961-1", :op "clone"}
[13:39:21,357] Unhandled REPL handler exception processing message {:id fireplace-lap1.local-1527503961-1, :op clone}
java.net.SocketException: Socket closed
at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
at clojure.tools.nrepl.transport$bencode$fn__724.invoke(transport.clj:103)
at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
at clojure.tools.nrepl.middleware.session$session$fn__1254.invoke(session.clj:188)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__903.invoke(middleware.clj:22)
at shadow.cljs.devtools.server.nrepl$start$fn__20723.invoke(nrepl.clj:344)
at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
at clojure.tools.nrepl.server$handle$fn__1327.invoke(server.clj:28)
at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
at clojure.lang.AFn.call(AFn.java:18)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:844)
:greeting-fn maybe?lein install2.3.28{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "56253e373239217b353a3c251664786578646f"}, :content ("[email protected]")}#shadow-connection-error is position: absolute and not position: fixed?:http-host should just be the host, not a url.deomens-l53.test is that your machine?deomens-l53.test/adminthis page is served from
phpdiv#application and then the <script> where my cljs app lives:devtools {:devtools-url ""} in your build config?:devtools-url just configures where the websocket tries to connect toshadow-cljs.. and then release snapshots because you are probably on ... somewhere:http-port and :http-host from your config:devtools {:devtools-url ""} and you should be good[:> some-react-class] anymore?Uncaught Error: Assert failed: Expected React component in: [:> #js {:DayPicker #object[b], :DateUtils #js...[:> foo ..] instead of [:> foo/DayPicker ...]?foo but now I understand how it worksnode-sass watch target to compile my sass. it seems like a lot of complexity to add lein in just to do thatplugin defining a clojure map with :start and :stop functions:start function is called. whatever that returns will be called be passed to :stop on server shutdownjava.lang.Process in :start and .destroy that in stop :plugins [demo.dummy-plugin] in shadow-cljs.edn:depends-on can be used if you want access to some of the other shadow-cljs components.travis.yml with shadow-cljs & karma tests?run-p command. thanks!/src/cm/theme.js
const theme = createMuiTheme({
palette: {
primary: purple,
secondary: green,
},
status: {
danger: 'orange',
},
});
How to use theme in cljs?["/cm/theme.js" :refer [theme]] but it doesn’t workexport { theme };createMuiTheme come from?import or require?import { createMuiTheme } from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';
const theme = createMuiTheme({
palette: {
primary: purple,
secondary: green,
},
status: {
danger: 'orange',
},
});
This is whole content of js fileexport const theme = ...export { theme }; somewhere["/cm/theme.js" :refer [theme]] is ok to import it to cljs?release might get you into troubletext-decoration instead of testDecoration and error is visible only in console. Not in web browser. Because of that I will probably stay with cljs.cljs.spec.alpha? We've just started to see and error with the compiled modules with:
- shadow-cljs 2.3.30
- clojurescript 1.10.238
- node 10.2.1
Uncaught TypeError: L.l is not a function
at dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307
TypeError: L.l is not a function
at $n (dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307)
at no (dist/cljs/spec/alpha.cljs:300:33 <- dist/shared.js:519:141)
at dist/io/comp/spec/user_spec.cljc:7:0
The line in question is: (s/def :user/first-name u/non-empty-string-conformer), which passes all node, doo and clojure testsshadow-cljs release app --pseudo-names or --debugdeftype and not defrecordu/non-empty-string-conformer is(defn- non-empty-string [s]
(if (or (not (string? s))
(string/blank? s))
::s/invalid
(string/trim s)))
(def non-empty-string-conformer (s/conformer non-empty-string))
--pseudo-names output. that is just for debugging purposes.shadow-cljs check app--pseudo-names solved the problem.check shows we have a few places we can fix up. I'll see if inferring helps shortlyIllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistryIllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistry clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28) shadow.build.closure/register-cljs-protocol-properties (closure.clj:387) shadow.build.closure/register-cljs-protocol-properties (closure.clj:372) shadow.build.closure/check/fn--13533 (closure.clj:1078) shadow.build.closure/check (closure.clj:1073) shadow.build.closure/check (closure.clj:1071) shadow.build/check (build.clj:371)
shadow-cljs - config: ... cli version: 2.3.30 node: v10.2.1, Clojure 1.9.0, lein 2.8.1lein ...lein deps :treeclosure-compiler-unshaded version you getlein...[com.google.javascript/closure-compiler-unshaded "v20180506"][org.clojure/clojurescript "1.10.238"
:exclusions
[com.google.javascript/closure-compiler-unshaded]]clojurescript dep entirely. shadow-cljs will bring that ingetGlobalType error. I've got a few warnings that may be the underlying cause (externs related). I'll let you know how I go 🙂check may be reporting a few false positives. it is not perfect. happy to help if you have questions(s/def is doing something else funky:modules?:compiler-options {:output-wrapper true} just to be sure (in your build config)L.l is not a function which is closure-shortened variable. with :pseudo-names it will not be that short by rather $something$.$fooBar$.l conflicting with somethingexterns/<your-build>.txt and adding one line with just ll is coming from in the first place.txt file fixes it or if it just becomes another character 😛L maybe?window.L or soL by default?L is in the console.l property was the problem but maybe its just the L global:output-wrapper is fine to use as wellL globalL by default now so the compiler will never attempt to use it:output-wrapper to true as well. its not currently default when using multiple modules because the build gets slightly largerUse of undeclared Varresolve(let [something (resolve 'some.ns/foo)] (something));; foo.bar is part of module :foo
(def some-var (resolve 'foo.bar/x))
(-> (loader/load "foo")
(.then (fn []
;; foo.bar is now loaded
(some-var))))some-var you probably need to wrap it in a load call to ensure it is loaded(loader/loaded? "foo") as wellresolve - agnostic of any routing…bidi implementation would be enough - you might need more of your own boilerplate to make it work though(defn async-component [the-module the-var]
(let [loading-ref (r/atom false)]
(-> (fn []
(if loading-ref
[:div "Loading ..."]
(the-var)))
(with-meta
{:component-did-mount
(fn [this]
(-> (loader/load the-module)
(.then #(reset! loading-ref true))))}))))(async-component "foo" (resolve 'some.foo/var))(ns some.foo) (defn var [] [:div "hello world"])[live/live] you do the async-component call:set-current-page or so:set-current-page in a callbackdebug level?lein however you are in charge of configuring your logging:browser build and I'd like them both to run continuously in the backgroundshadow-cljs watch karma browsernpm install -S libraryA? I mean the whole npm ecosystem is managed by npm and shadow-cljs provides a bridge to it:npm-deps key.:asset-path to "/", it tries to load scripts from :web-worker true for the module but I think service workers should probably be their own build.nrepl-select command”?nrepl-select?nrepl-select magic and pasting into the replnrepl-select magic?(require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :app)every time
(shadow.cljs.devtools.api/nrepl-select :app) directlyshadow.user not user anymore(shadow/nrepl-select :app) should work by defaultrequire anymore:repl {:init-ns something.foo} to make yours the default------ ERROR -------------------------------------------------------------------
File: C:\Users\thheller\code\shadow-cljs\src\dev\demo\es6.js:15:16
--------------------------------------------------------------------------------
12 | console.log("await value", value);
13 | }
14 |
15 | var obj = {hello-World: 1};
----------------------^---------------------------------------------------------
'}' expected
--------------------------------------------------------------------------------
16 |
17 | export { foo, someAsyncFn };
18 | export default "defaultExport";
--------------------------------------------------------------------------------.js support will soon get proper errors for thoseshadow-cljs.edn and just put runtime deps in project.clj... plus there's also npm deps...shadow-cljs deploy involves a lot of work so thats still ways offdeps.cljssrc/main/deps.cljs {:npm-deps {"react" "^16.3.0"}}deps.cljs is officially supported by CLJS, I did not "invent" thatcljsjsreact-flatpickr component and I'm trying to do this: https://flatpickr.js.org/plugins/#weekselect
Everything else seems to work, but adding a plugin seems to fail... Here's some relevant code:
(ns ...
(:require ...
["react-flatpickr" :default Flatpickr]
["flatpickr/dist/l10n/nl.js" :refer [Dutch]]
["flatpickr/dist/plugins/weekSelect/weekSelect" :default weekSelectPlugin]))
(defn week-picker [...]
[...
[:> Flatpickr {:options (clj->js {:locale Dutch
:defaultDate (coerce/to-date selected-calendar-date)
:plugins [(weekSelectPlugin. {})]
:weekNumbers true})
:onChange (fn [selected-dates _ _ ] (js/console.log "--" selected-dates))}]
...
I'm getting this error:
Uncaught TypeError: module$node_modules$flatpickr$dist$plugins$weekSelect$weekSelect.default is not a constructor(require '["flatpickr/dist/plugins/weekSelect/weekSelect" :as x]) then (js/console.log x).default property the :default will work:as ... instead of :default(weekSelectPlugin. {}) maybe you are supposed to call (weekSelectPlugin {})?new Thing() vs Thing();new is correct ... nvmjs/console.log gives me:
ƒ (){return function(a){function b(b){var c=b.target;if(c.classList.contains("flatpickr-day")){b=a.days.childNodes;var d=c.$i/7;c=b[7*Math.floor(d)].dateObj;d=b[7*Math.ceil(d+.01)-1].dateObj;for(var h=…
:as weekSelectPlugin and that should work(weekSelectPlugin. #js {}) though as it won't understand CLJS maps[1:1]~cljs.user=> (require '["flatpickr/dist/plugins/weekSelect/weekSelect" :as x])
nil
[1:1]~cljs.user=> (x. #js {})
#object[Function]shadow-cljs watch app, hot reload doesn't seem to work as expected. I have a page with a menu, let's say page1 and page2. When I'm on page1, the content of page1 is shown, obviously. However, when I update that page (the content of page1), it is not updated in the browser. When I click in the menu page2 and page1 again, the update is there...{:lein true
:jvm-opts ["--add-modules" "java.xml.bind"]
:nrepl {:port 3333}
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [ui-app.core]}}
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}}
:devtools {:http-root "resources/public"
:http-port 3449
:preloads [shadow.cljs.devtools.client.hud
devtools.preload
day8.re-frame-10x.preload]}}}}
:after-load callback. do you have one configured in the code? using ^:dev/after-load somewhere in the code?^:dev/after-load anywhere 🙂. I'm still new to shadow-cljs 🙂:on-jsload callback in the config(defn render [] ...) in your ui-app.core just add (defn ^:dev/after-load render [] ..):devtools {:after-load ui-app.core/render ...} to your config. same result.init from the HTML. if you pass config into that method you add a (defonce config-ref (atom nil)) and then (reset! config-ref the-config) in initstart then just derefs the config-refatom now, but I already kept it in the re-frame app state (db). I'm just reading it from there. Thx a lot! Love shadow-cljs more and more..shadow-cljs folder and then do a clean npm installgit clean -xfd wipe doesn't helppackage.json so that it contains:
"react": "16.3.2",
"react-dom": "16.3.2",
package-lock.json which should get generated(ns cljsjs.react (:require ["react" :as react])) (js/goog.exportSymbol "React" react)Not sure if that is still necessary with the newest shadow-cljs
(ns cm.core
(:require [reagent.core :as reagent]
[re-frame.core :as re-frame]
[cm.events :as events]
[cm.views :as views]
[cm.config :as config]
[bidi.bidi :as bidi]
[goog.events :as goog-events]
[goog.history.EventType :as EventType]
[taoensso.timbre :as l])
(:import goog.History))
(def route ["/" {"log-in" :log-in
"log-out" :log-out
"sign-up" :sign-up}])
(defmulti handler #(:handler %))
(defmethod handler :default [request]
(l/info "page" request)
(re-frame/dispatch [:handler (:handler request)]))
(defn hook-browser-navigation! []
(doto (History.)
(goog-events/listen
EventType/NAVIGATE
(fn [event]
(->> (.-token event)
(bidi/match-route route)
(handler))))
(.setEnabled true)))
(defn dev-setup []
(when config/debug?
(enable-console-print!)
(println "dev mode")))
(defn ^:dev/after-load mount-root []
(re-frame/clear-subscription-cache!)
(reagent/render [views/page]
(.getElementById js/document "app"))
(hook-browser-navigation!)) ;; <<<<<<<< this line
(defn ^:export init []
(re-frame/dispatch-sync [::events/initialize-db])
(dev-setup)
(mount-root))
After reload page in web browser without any change of code (like add enter on the end of file) I get this HTML in page:
<html><head></head><body><input type="text" name="history_state1" id="history_state1" style="display:none"></body></html>So I end with this error:
env.cljs:168 error when calling lifecycle function cm.core/mount-root Error: Target container is not a DOM element.
at h.exports (invariant.js:43)
at sa (react-dom.development.js:17117)
at Object.render (react-dom.development.js:17196)
at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:20)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs:44)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs:39)
at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs:74)
at cm$core$mount_root (core.cljs:51)
at shadow.cljs.devtools.client.env.make_task_fn (env.cljs:165)
at shadow$cljs$devtools$client$env$do_js_reload_STAR_ (env.cljs:173)
Why? How to fix it?
What I want to achieve: URL navigation like url#/log-in. That is why I added (hook-browser-navigation!) but in some magic way it has conflict with shadow-cljs during development.Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/externs__init.class or cljs/externs.clj on classpath., compiling:(shadow/build/cljs_bridge.clj:1:1) at clojure.lang.Compiler.load(Compiler.java:7526) at clojure.lang.RT.loadResourceScript(RT.java:379) at clojure.lang.RT.loadResourceScript(RT.java:370) at clojure.lang.RT.load(RT.java:460) at clojure.lang.RT.load(RT.java:426) at clojure.core$load$fn__6548.invoke(core.clj:6046) at clojure.core$load.invokeStatic(core.clj:6045) at clojure.core$load.doInvoke(core.clj:6029) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5848) at clojure.core$load_one.invoke(core.clj:5843) at clojure.core$load_lib$fn__6493.invoke(core.clj:5888) at clojure.core$load_lib.invokeStatic(core.clj:5887) at clojure.core$load_lib.doInvoke(core.clj:5868) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:659) at clojure.core$load_libs.invokeStatic(core.clj:5925) at clojure.core$load_libs.doInvoke(core.clj:5909) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:659) at clojure.core$require.invokeStatic(core.clj:5947) at clojure.core$require.doInvoke(core.clj:5947) at clojure.lang.RestFn.invoke(RestFn.java:2793) at shadow.build.classpath$eval17191$loading__6434__auto____17192.invoke(classpath.clj:1) at shadow.build.classpath$eval17191.invokeStatic(classpath.clj:1) at shadow.build.classpath$eval17191.invoke(classpath.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7062)
shadow-cljs.edn, it works there, so it's something around lein integration:exclusions [org.clojure/clojurescript] automatically for every dep to avoid thatgoog.History. It uses document.write to insert an iframe dynamically. (defn do-route [token]
(->> token
(bidi/match-route route)
(handler)))
(defn hook-browser-navigation! []
(doto (History.)
(goog-events/listen
EventType/NAVIGATE
(fn [event]
(do-route (.-token event))))
(.setEnabled true)))
(defn dev-setup []
(when config/debug?
(println "dev mode")))
(defn ^:dev/after-load mount-root []
(re-frame/clear-subscription-cache!)
(reagent/render [views/page]
(.getElementById js/document "app")))
(defn ^:export init []
(re-frame/dispatch-sync [::events/initialize-db])
(dev-setup)
(mount-root)
(hook-browser-navigation!))History object twice. so the above calls it in init once and not in start which is called for each live-reload.mount-root. not sure what makes most sense.react v16. a React global only exists when you use cljsjs.react since by default there will be no React global exported?(:require ["react" :as x]) that won't create a global?React during dev due to some preload?goog.history.Html5History instead since that uses normal paths instead of append #/...url#/foo/bar/foo/bar or url#/foo/bar. the first requires server support while the second doesn't. but beyond that they pretty much work the sameurl# it just needs onelocalhost:8020/foo/bar/baz and click refresh?pushState routing. the shadow-cljs server will serve the index.html by default for all urls that don't exist otherwise(ns ui-app.core
(:require-macros [secretary.core :refer [defroute]])
(:import goog.History)
(:require ...
[orchestra-cljs.spec.test :as st]
...))
...
(defn ^:dev/after-load start
[]
(println "starting...")
(let [...
dev ...
...]
(when dev
(println "instrumenting...")
(st/instrument))
...))
...
(ns ...
(:require ...
[orchestra.core :refer-macros [defn-spec]]
...))
(defn-spec some-fun #(repeatedly true)
[arg (s/cat :arg #(repeatedly true))]
...)
#(repeatedly true) to anything else seems to make the specs fail for nowfeature-container component that is conditionally rendered by the server, and when rendered it could put some code on the page that would dynamically load the feature client-side modulemanifest.edn can help automate the config part(cljs 'some.app.entry 1 2 3) which basically calls (some.app/entry 1 2 3) and figures out which module some.app is in so ensures that the module is loaded first(cljs 'some.app.entry 1 2 3) gets translated to some JS that gets put on the page that will call (some.app/entry 1 2 3)?shadow.loader/load to do what I want 😄 yeah?<script> tags for the required modules<link rel="preload" ...> to make it even fastershadow.loader totally works toomanifest.edn is for?(ns-ready))shadow.api + ns-ready you still need to do in all your :entries that have these exported methods basicallyshadow.loader you may however use the load deferred to do stuff on loadshadow.loader respect the preloads? as in, would it refetch the module or realize it was already loaded?SEVERE: node_modules/tether/dist/js/tether.js:384: ERROR - Duplicate let / const / class / function declaration in the same scope is not allowed.
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
^^^^^^^^^^^^^^^- src - file.cljs - file-js.js
file.cljs I'm trying (:require ["./file-js"]) but I get The required JS dependency "./file-js" is not available, ...The required JS dependency ... instead of actually showing the error in the file. It most likely just has a parse error.tether thing. will need to check it out later.src/file.cljs is bad. try src/thing/file.cljs instead so at least one level nested. JS file should be nested with it. Generally everything on the classpath should be properly scoped as you'd otherwise just get into trouble with dependency conflicts.:compiler-options {:externs ["datascript/externs.js"]}. I didn't got the issue with cljsbuild, so I suppose the extern was automatically injected, moreover this detail is not mentionned in the datascript documentation. Is there a reason shadow-cljs behave differently regarding externs ?deps.cljs(set/union …) of all available externs ? Wherever they comes from a file A or a file B ?:advanced since it can't remove anything that is mentioned in externsoverflow: scroll; so it doesn't go beyond a certain heightnode_modules even in whitespace modenodejs target)shadow-cljs doing that instead?node_modules files just fine with shadowbundle isn't aware of npm either so it changes nothing in that regard:js-options {:js-provider :shadow} for your node build and it will bundle everythingBUNDLE was for thatBUNDLE will do nothing as its just a lighter-weight version of WHITESPACE:browser):autorun set to true that has failing tests. This does not seem like the expected exit status.cljsjs/react.js & node_modules/react is this expected ?cljsjs.react is just a "bridge" to the npm react. see https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljscljsjs.react instead of react directly. it does not include the actual cljsjs code ever:autorun is mostly meant for watch and therefore cannot emit an exit code. you are probably better off running tests manually instead(:require ["mousetrap/plugins/global-bind/mousetrap-global-bind"]).
I wonder - is it the correct usage in a scenario where a library developer just wants you to include a <script> tag on your page? It appears to be working, with and without .js extension.<script> question? the .js is optional and doesn't affect the output whether you use it or not<script src="%path-to-plugin.js%"></script> in my HTML. And I guess the above :require does just the same, with no potential problems?Mousetrap global and don't properly express their dependency on mousetrap itself but if it works it works2.3.35 with some perf improvements. please let me know if things actually got faster and not slower 😉[:init-store-fn] Compiling ... Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source:
1.10.238 if I remember right1.10-alpha4 maybe that is why[:app] Build completed. (741 files, 615 compiled, 1 warnings, 31.53s) [:app] Build completed. (743 files, 617 compiled, 0 warnings, 27.73s)
deps.edn for what is worth... so not sure about caching, or how to debug the problem2.3.30: [:app] Build completed. (743 files, 617 compiled, 0 warnings, 31.35s) 2.3.35: [:app] Build completed. (743 files, 617 compiled, 0 warnings, 27.73s)
watch recompiles should be faster too:node-library or :npm-module:node-script prepends a #! and webpack barfs 😄release-snapshot really usefull ( https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/11). Could not find in the user guide release-snapshot any reason why it's not there ?:npm-module{:http-root "public"
:http-port 8020}
:asset-path look like (in the build config)?:asset-path "js"/js instead:require-macros on my cljs file, but when I use the macro shadow is warning me that I'm using an undefined symbol, but my macro is a def-like macro, so I don't understand why I'm getting these warnings(defmacro defcard [sym settings]
(let [fqsym (if (namespace sym)
sym
(symbol (name (ns-name *ns*)) (name sym)))]
`(init-card ~fqsym ~settings)))(ws/defcard sample-card
{::ws/node-props
{:className ""}
::ws/render
(fn [node]
(gobj/set node "innerHTML" "Hello World"))})5 | (ws/defcard sample-card -------^------------------------------------------------------------------------ Use of undeclared Var my.ns/sample-card
.clj or .cljc filesinit-card itself a macro which expands to (def ~the-name ...)? I don’t see a def form in the macro so I don’t know where that var is being defined init-card is just a functiondef behind the scenes to create a var which can be referenced like any other. (Not all of course.)'~fqsym(quote ~fqsym)shadow-cljs - Using IP "10.83.10.6" from Interface "tun0" Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke INFO: Found multiple IPs, might be using the wrong one. Please report all interfaces should the chosen one be incorrect. Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke INFO: Found IP:10.83.10.6 Interface:tun0 Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke INFO: Found IP:192.168.1.220 Interface:wlan0 Jun 06, 2018 1:56:37 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Jun 06, 2018 1:56:37 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - server version: 2.3.23 shadow-cljs - server running atThe problem here is that it uses
tun0 interface, which is a VPN interface in my case. I casually switch VPN throughout the day, and when I do that, I also have to restart shadow-cljs.
Maybe it shouldn't use tun interfaces? Is there anything I can do on my setup to make it always use localhost?(deftest wfirma
(with-redefs [wfirma.api/request-api (constantly (read-string (slurp "test/bind-input/products-wfirma.edn")))]
(let [products-wfirma (db-products/get-products :wfirma)]
(testing "wfirma -> products"
(is (every? nil? (map (partial s/explain-data ::sp/product) products-wfirma))
"spec")
(is (= "00014" (:code (first products-wfirma)))
"parse")))))
or
(deftest estore->db
(with-redefs [atomstore.soap/connection (constantly nil)
atomstore.soap/get-products (constantly (slurp "test/bind-input/products-all.xml"))]
(testing "atomstore->products"
(is (= (:body (core/app (mock/request :get "/shops/hc/db/products/refresh")))
"done")))))
deps.edn, but this time also an errorFailed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source:
:output-dir. the validation for that is missing.ps -ef | grep java arichia+ 23173 22953 0 12:22 pts/1 00:00:00 grep --color=auto java
arichia+ 23272 23266 0 12:23 pts/1 00:00:00 bash /home/arichiardi/.local/bin/clojure -J-Djava.util.logging.config.file=/home/arichiardi/git/laputa/lambda-cqrs/.shadow-cljs/logging.properties -Sdeps {:aliases {:shadow-cljs-inject {:extra-deps {thheller/shadow-cljs {:mvn/version "2.3.35"}}}}} -A:cljs-jvm:shadow-cljs-inject -m shadow.cljs.devtools.cli --npm compile init-store
arichia+ 23285 23272 99 12:23 pts/1 00:00:30 /usr/bin/java -Djava.util.... <- shadow?
compile call?.shadow-cljs/builds/init-store/dev/ana/cljs/core/async.cljs.cache.transit.json fileclj -Stree would help although deps shouldn't play a role here. doubt there is the JSON impl that writes invalid JSON and then complains about it when trying to read ittun devices and constant IP changes? Thanks!localhost. detecting the IP is way too unreliable https://github.com/thheller/shadow-cljs/issues/296{:target :node-library :exports some.ns/some-fn} (defn some-fn [] the-exported-fn)module.exports = some.ns.some_fn();use strict looks like band-aid rather than an actual fix:npm-module it seems:target :node-library explicitely when mentioning it:npm-module:target :npm-module :output-dir "foo"index.js module.exports = require("./foo/your.ns").foo; and (defn ^:export foo [...] ...)index.js manually and use that as your main "entry":node-library creates a single file:npm-module creates commonjs files to they behave like any other commonjs:node-library:npm-module is mostly intended to be processed by other tools, ie. including cljs output in a webpack build.jar not uberjarnode_modules + mine:npm-module is the way to go:node-library will also work. its just way less flexible.package.json?fn1 - index.js - node_modules fn2 - fnn
:node-library works$ node init-store/unbundled.js Hello World
fn1 directory. put a package.json into it.:builds {:fn1 {:target :node-library :exports your.fn1/foo :output-to "fn1/index.js"}}:target :azure-fn if it needs some custom processing or config options:node-library probablypackage.json and maybe this from metadata? https://github.com/Azure-Samples/functions-node-sas-token/blob/master/GetSasToken-Node/function.jsonshadow would already improve things phenomenally. So that you get js + node-modules without using webpack(defn my-handler
{:azure/bindings
[{:authLevel "function"
...}]}
[context req]
...)defn and the target could read that to generate the function.jsonfunction.json contains a lot more{:shadow.build/stage :flush}?dev folder is:
(ns ep-cloud.shadow)
(defn hook
{:shadow.build/stage :flush}
[build-state & args]
(prn [:hello-world args])
build-state)
:source-paths:build-hooks [(ep-cloud.shadow/hook 1 2 3)]Button.Group below via shadow-cljs?
import React from 'react'
import { Button } from 'semantic-ui-react'
const ButtonExampleGroup = () => (
<Button.Group>
from: https://react.semantic-ui.com/elements/button#groups-groupnpm install reactnpm install create-react-class(:require ["semantic-ui-react" :as sem]) sem/Button.Group(when-let [open js/OpenFileInEditor] (open "some/file.cljs" 10 1))js/OpenFileInEditor:lambda-fn - and the metadata dropped - easy to write anyways`.
Will try to come up with a PR today and probably I will ask you more questions on how to package everything, node_modules included, in a single file(meta &form), but the path there seems relative to its own source path, do you know if I can get the absolute path there somehow?shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1) in the console/home/thheller/code/shadow-cljs/src/... or other absolute paths into the compiled outputopen-classpath fn that maps the classpath path to an absolute path and opens thatshadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)
VM52189:1 Uncaught TypeError: Cannot read property 'open_file' of undefined
at <anonymous>:1:26shadow.cljs.devtools.client.hud.open_file("shadow-cljs.edn", 1, 1):open-file-command setup correctly?{:open-file-command
["idea" :pwd "--line" :line :file]}$ yarn shadow-cljs clj-eval "(println \"hello\")" yarn run v1.7.0 warning package.json: No license field $ /home/oscar/Projects/penny-profit/redux/node_modules/.bin/shadow-cljs clj-eval '(println "hello")' shadow-cljs - config: /home/oscar/Projects/penny-profit/redux/shadow-cljs.edn cli version: 2.3.36 node: v10.4.0 shadow-cljs - starting via "clojure" hello nil
yarn? I used with deps.edn before, didn't had this issue, also there is a strange thing about the 130 status code return, I wonder if that + yarn is getting you in this placenpx for yarn yields the same results.shadow.user> (shadow.cljs.devtools.api/watch :node) :already-watching shadow.user> (shadow.cljs.devtools.api/nrepl-select :node) To quit, type: :cljs/quit [:selected :node] cljs.user> :a No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. cljs.user> (shadow.cljs.devtools.api/nrepl-select :node) No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. cljs.user>here I already started a watch, also when I start server and manually ignite the watch, I get the same error message.
$ node <your-build.js> and then try evaling again.node-repl command directlyshadow server always on * I have this symbols instead of * for required fields in material ui<meta charset="utf-8">(shadow.cljs.devtools.api/repl :app) after connecting?:repository entry you can do that in shadow-cljs.edn just like lein:repositories
[["private-maven"
{:url "",
:snapshots false,
:sign-releases false,
:username :env/aws_access_key_id,
:password :env/aws_secret_access_key}]]
shadow-cljs - dependency update failed - Vector arg to map conj must be a pair with that{"private-maven" {...}}:env/ stuff. that might be something lein does?:username #shadow/env "aws_access_key_id"repositories map as well, or will shadow merge my map with defaults?:exports:exports-var in my configshould contain keys: :exports, :exports-fn, :exports-sym | key | spec | |--------------+------| | :exports | nil | | :exports-fn | nil | | :exports-sym | nil |
cli version: 2.3.36:exports-var in there, so maybe it has not been deployed yet?:output-to in a :release map?(ns material-ui.colors
(:require ["@material-ui/core/colors/deepPurple" :default deepPurple]
["@material-ui/core/colors/green" :default green]
["@material-ui/core/colors/blue" :default blue]))
(def deepPurple deepPurple)
(def green green)
(def blue blue)
Is there any way to do something like that?
In that case blue is nil when load from another namespace [material-ui.colors :as colors]
In the same namespace blue has value.cblue or something like that, but it would be so ugly(def deepPurple deepPurple) is basically a self-reference:default mui-deepPurple(def deepPurple mui-deepPurple)(def deepPurple (js->clj mui-deepPurple)) whats this supposed to do?(aget colors/blue "A400")(defn color [x y] ...) so you can do (color :blue 400)js->clj is at runtime(def theme (mui/create-mui-theme
(clj->js
{:palette {:primary {:main (aget colors/blue "A400")}
:secondary {:main (aget colors/deepPurple "500")}}
:overrides {:MuiAppBar {:root {
;:color "#00ff00"
;:background-color "white"
}}
:MuiButton {:root {:text-transform "none"}}}})))
:palette {:primary {:main "#42a5f5" ...dev folder to shadow's classpath?:source-paths ["src" "dev"]?:release:aliases in :releaseshadow-cljs -A:release --force-spawn release your-appmy-org.dev namespace that uses the dotenv library to load environment variables only when using the REPL:release, so I added:
(when goog.DEBUG (dev/load-env-vars!))
:preload:preloads(defn main [config-path] (let [config (-> (fs/readFileSync config-path) str (reader/read-string))] ...))node server.js dev-config.ednnode server.js prod-config.edn ...:preloads is finedev folder will need to always be on the classpath:target :node-script?:node-librarynode process do you not?(shadow/node-repl)?node-repl(shadow/node-repl {:node-env {"hello" "world"}}) help? (adding extra env vars to the node process so js/process.env.hello works?dotenv is kind of nice because it automagically reads from .env the variables(shadow/node-repl {:node-env (read-from-dotenv)})?dotenv[DEPRECATED]?dotenv actually. it could be env.edn or somethingjs/process.env.DB?:preloads is the best optionclj alias:preloads are never included in release builds?:preloads) then it won't even be compiled in release{:target :node-library :exports .... :devtools {:preloads [my-org.dev]}}:source-paths in CLJS usuallynrepl-select in emacs, and I have a server in another window that compiles. Is there a way to stop receiving the compilation logs in the nrepl-select-ed buffer?watch messages appear wherever the watch was startednrepl-select has nothing to do with those messagesuser> (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :init-store)(shadow/nrepl-select :init-store))
To quit, type: :cljs/quit
[:selected :init-store]
JS runtime disconnected.
JS runtime connected.
JS runtime disconnected.
JS runtime connected.
JS runtime disconnected.
JS runtime connected.
[:init-store] Compiling ...
[:init-store] Build failure:
------ ERROR -------------------------------------------------------------------
File: /home/arichiardi/git/laputa/lambda-cqrs/src/ep_cloud/init_store.cljs:23:3
--------------------------------------------------------------------------------
20 |
21 | This function is idempotent, you can call it multiple times."
22 | [ctx request]
23 | (let [azure-callback
---------^----------------------------------------------------------------------
Call to cljs.core/let did not conform to spec
-- Spec failed --------------------
([... ... (partial ... ...) ... ... ... ...] ... ...)
^^^^^^^
should satisfy
vector?
...
(shadow/watch :init-store) there?workshop.cljs
|
-> react.cljs
|
-> react.clj
|
-> compiler/core.clj
|
-> compiler/parser.clj
|
-> compiler/analyzer.clj
|
-> compiler/generator.clj
(require-macros ns : reload) or :reload-all should work. It usually reads the source on disk and loads it(require-macros ..) iis a REPL only thing:require-macros is fully supported(require-macros 'the.macro :reload-all) literally just open a CLJ REPL and (require 'the.macro :reload-all):require-macros in the ns is metadatarequire-macros actually evals code:require-macros does nothing until the compiler is actually ready to do somethingrequire-macros isn't supported is because I have never needed itimport React from 'react';
import ReactDOM from 'react-dom';
import { Column, Table } from 'react-virtualized';
import 'react-virtualized/styles.css'; // only needs to be imported once
// Table data as an array of objects
const list = [
{ name: 'Brian Vaughn', description: 'Software engineer' }
// And so on...
];
// Render your table
ReactDOM.render(
<Table
width={300}
height={300}
headerHeight={20}
rowHeight={30}
rowCount={list.length}
rowGetter={({ index }) => list[index]}
>
<Column
label='Name'
dataKey='name'
width={100}
/>
<Column
width={200}
label='Description'
dataKey='description'
/>
</Table>,
document.getElementById('example')
);
(ns simple.virtual-table
(:require ["react-virtualized" :refer (Table Column)]))
(enable-console-print!)
(def rows
[{:name "brian vaughn" :description "one"}
{:name "brian vaughn" :description "two"}
{:name "brian vaughn" :description "three"}
{:name "brian vaughn" :description "four"}
{:name "brian vaughn" :description "five"}
{:name "brian vaughn" :description "six"}])
(defn react-virtualized-table []
[:div
[:h3 "React Virtualized Table"]
[:> Table {:headerHeight 30
:height 300
:rowCount 5
:rowGetter (fn [m]
(get rows (aget m "index")))
:rowHeight 50
:width 400
}
[:> Column {:label "Name"
:dataKey "name"
:width 100}]
[:> Column {:label "Description"
:dataKey "description"
:width 100}]
]])
<div class="ReactVirtualized__Table__rowColumn" role="gridcell" title="" style="flex: 0 1 100px; overflow: hidden;"></div>
:rowGetter fn you are returning a clojure map from rows which react-virtualized then will try to row["name"] via :dataKey I think. the other example you linked does clj->js which you are missing.SHADOW import error […]/resources/server/cljs-runtime/shadow.js.shim.module$ws.js
I solved it with yarn add ws. Is this normal?npm install --safe-dev shadow-cljs➜ Monolith git:(mw-jest-tests) ✗ shadow-cljs compile app shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Monolith/shadow-cljs.edn cli version: 2.4.0 node: v9.5.0 shadow-cljs - starting ... 12:46:16.597 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 12:46:17.773 [main] DEBUG shadow.cljs.devtools.api - starting runtime instance [:app] Compiling ... ExecutionException: java.lang.NoClassDefFoundError: com/google/common/collect/Streams java.util.concurrent.FutureTask.report (FutureTask.java:122) java.util.concurrent.FutureTask.get (FutureTask.java:192) clojure.core/deref-future (core.clj:2292) clojure.core/future-call/reify--8097 (core.clj:6894) clojure.core/deref (core.clj:2312) clojure.core/deref (core.clj:2298) clojure.core/map/fn--5587 (core.clj:2745) clojure.lang.LazySeq.sval (LazySeq.java:40) Caused by:
[com.google.guava/guava "22.0"] is requiredclj->js.:node-library built with shadow and I try to require them in node:
> var h1 = require ("./init-store")
...a bunch of SHADOW load...
> var h2 = require ("./query-events")
SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs.spec.alpha.js
Error: No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object]
at SHADOW_IMPORT_PATH (/home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:5:26)
at /home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:3033:1
at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:65:44)
at /home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/spec/alpha.cljs:1334:1
at Object.cljs$spec$alpha$def_impl [as def_impl] (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/spec/alpha.cljs:297:3)
at Function.cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4 (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:4470:7)
at Function.cljs.core._swap_BANG_.cljs$core$IFn$_invoke$arity$4 (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:854:1)
at Object.cljs$core$missing_protocol [as missing_protocol] (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:312:3)
>
:node-library per node process (during development). if you need 2 use :npm-module:azure-fn.../public/css/main.css? (I’m not using the bundled server)
:builds {:client {:output-to "../public/js/main.js"
:output-dir "../public/js"
:target :browser
:asset-path "/js"
:modules {:main {:entries [landing-page.client.core]}}
:devtools {:watch-dir "../public"
:after-load landing-page.client.core/run}}}}
/css/main.css in your html yescss/main.css no[stylesheet "/css/main.css"]firebase serve.[stylesheet ..] emit?(defn stylesheet
"Particle for defining a stylesheet."
[href]
[:link {:href href
:rel "stylesheet"}])
<link href="/css/main.css" rel="stylesheet">../ shouldn’t make a difference, should it?../ indeed was the problem. fixed in 2.4.2../ is because I had to put src in a weird place to not make firebase-functions have a huge hissy fit.{:type :asset-watch, :updates ["/css\\foo.css"]}import ReactTooltip from 'react-tooltip' <ReactTooltip />in cljs (using shadow-cljs):
(:require ...
["react-tooltip" :default ReactTooltip])
[:> ReactTooltip>
However, ReactTooltip is undefined (when do (js/console.log ReactTooltip)). Why would ReactTooltip be undefined?:as ReactTooltip. sometimes the code is packaged as commonjs which doesn't have default exports.:repositories config in project.clj the config is identical to that:repositories {"thing" {:url ... :username #shadow/env "AWS_ACCESS_KEY"}}#shadow/env looks up the env variable and uses that in the configre-frame-10x doesn't work after moving to lein. Is that a known problem? The required namespace "day8.re-frame-10x.preload" is not available.import 'draft-js-static-toolbar-plugin/lib/plugin.css' import 'draft-js/dist/Draft.css'If I
require both in cljs, the css doesn't seem to be added. Is this the normal behaviour? If so, the best way would be, I assume, to add the css file to index.html?npm-libraries, which was pretty much a mess).css stuff is currently not supported but might come at a later date. until then you need another way to bundle your css. unfortunately some JS libs are designed with the expectation of webpack being used and adding all the weird conventions that entails is a bit time consumingindex.html will dolein or boot use. it is done via a standalone uberjar via shadow-cljs-jar launched before the actual JVM. its is basically only a very tiny wrapper using pomegranate, see https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.cljindex.html probably won't have access to node_modules/draft-js/dist/Draft.css so probably need to copy it manuallynpmsnpms and you use http://blob.tomerweller.com/reagent-import-react-components-from-npm , it won't work to add 10x. The reason being: you'll take out reactjs to webpack, and 10x will not find react on startup (or someting like that). In shadow-cljs, it's no issue, since shadow-cljs inverts the logic (compile cljs to js and add it to a normal npm project - lein and boot try to embed js in their own compilation, which makes the google closure compiler cry for many npm packages). That's, at least, how I think it is 😛.:source-paths and :dependencies move to project.clj basically. that is it.:lein true to shadow-cljs 😛:repository. That way I can fetch the dependency using lein and run using only shadow. Adding a :plugins seems to make no difference.lein for now~/.m2 first so if all the deps are there there is no need to ever talk to s3. so yeah this works but using the lein interop is probably best since you otherwise need to manually sync the deps in shadow-cljs.edn and project.clj:repositories key it doesn't work even with the dependency cached on ~/.m2 It complains that cannot find metadata.re-frame-10x does not make sense. it should still work if your dependencies are identicallein literally just constructs your classpath, nothing more.fs, which is node specificjs/require seems to work for the same package, i thought shadow would be smart to use an appropriate import depending on the targetjs/require is just a regular function call and not indexed by shadow-cljs. fs is a node only package, you will get a shim if you (:require ["fs" :as fs]) in a browser build but that does not support using fs.readFileSyncfs.readFileSync cannot possibly work in the browserjs/require is never processed no but webpack doesfs.readFileSync doesn't work in either case{:cache-key [1528920986368],
:output-name "index.js",
:resource-id
[:shadow.build.targets.azure-fn/fn-index "query-events$index.js"],
:resource-name "query-events$index.js",
:type :js,
:source "module.exports = blax",
:last-modified 1528920986368,
:requires #{ep-cloud.query-events},
:provides #{}}
fn-name/index.js:source there and though I could paste my own JS 😄var FileSaver = require('file-saver');(:require ["file-saver" :as FileSaver]) should do it:azure-fn or course):fn map as is to :exports so probably what you say is still supported?:node-library target at the moment - maybe not the right one):modules better:azure-fn doesn't really fit anymore when using multiple fns:azure-fns or :azure-app or something else maybe better?azure-app feels bettermaster has the updated version. your stuff went kind of the wrong direction making things more compilcated then neededapp-dir ?.
├── cljs
│ └── shared.js
├── host.json
├── local.settings.json
└── simple
├── function.json
└── index.js(defn do-flush [{::keys [fn-map] :as state}]
(reduce-kv flush-fn-file state fn-map)):azure/* metadata and fails if missingfunc host by today though so thanks for you helpfunc host doesn't exist in my versionfunc run simple works for the thing I built:azure-app target into a library. no reason for it to be in shadow-cljs itself:target stuff is completely undocumented so I don't expect anyone to write targets just yet[:workspaces] Build failure: FileNotFoundException: resources/public/js/workspaces/main.js (No such file or directory) java.io.FileOutputStream.open0 (FileOutputStream.java:-2) java.io.FileOutputStream.open (FileOutputStream.java:270) java.io.FileOutputStream.<init> (FileOutputStream.java:213) (io.clj:230) (io.clj:230) (io.clj:69) (io.clj:166) (io.clj:166)
(io/make-parents ...) call:browser:modules output can be written before the sources are flushed. only sources create the parent dirs, the modules did not2.4.3 which should fix the issue (async sure is fun, brought way more issues with it than I would have expected)scriptFile:azure-app while compiling with :simple
> var x = require("./query-events")
TypeError: $s$$.substring is not a function
at Function.cljs.core.subs.cljs$core$IFn$_invoke$arity$2 (/home/arichiardi/git/laputa/lambda-cqrs/cljs/shared.js:9564:15)
:closure js provider for one npm package, but :shadow everywhere else?clipboard, which causes shadow to throw:
> failed to resolve: ./clipboard-action from [redacted]/node_modules/clipboard/dist/clipboard.js
> {:relative-to #object[java.io.File 0x624eb05d "[redacted]/node_modules/clipboard/dist/clipboard.js"], :entry "./clipboard-action"}
> ExceptionInfo: failed to resolve: ./clipboard-action from [redacted]/node_modules/clipboard/dist/clipboard.js
Here's the offending line: https://github.com/zenorocha/clipboard.js/blob/master/dist/clipboard.js#L506/dist directory doesn't contain clipboard-action.js, only /src does. But the /src dir isn't packaged into the module. Does this imply a bug in clipboards packaging: making relative reference to a file which doesn't exist?"clipboard/dist/clipboard.min.js" instead of just "clipboard" seems to workumd helper exports the names unmungedumd starts munging or we use my fix with the array, or if you have any other approach I can work on it:node-library probably already use :exports {:someVar some.ns/some-var} or :exports {:some_var some.ns/some-var} so its probably okrequire("./the-lib")["some-var"]:http-port 3000 in my shadow config but when running shadow-cljs watch app it prints shadow-cljs - HTTP server for :app available at . Why does this happen? It appears the content is available at ports 3000 and 3001.[2:1]~cljs.user=> (require '[moment :as m]) nil [2:1]~cljs.user=> (m) ReferenceError: module$node_modules$moment$moment is not defined
$ shadow-cljs browser-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.4.4 node: v9.4.0 shadow-cljs - connected to server [:browser-repl] Configuring build. [:browser-repl] Compiling ... [:browser-repl] Build completed. (136 files, 35 compiled, 0 warnings, 6.93s) [10:1]~cljs.user=> JS runtime connected. [10:1]~cljs.user=> (require '["moment" :as m]) nil [10:1]~cljs.user=> m #object[g] [10:1]~cljs.user=> (m) #object[oa Fri Jun 15 2018 08:16:14 GMT+0200]
(require '["moment" :as m]) works but (require '[moment :as m]) doesn't. https://github.com/thheller/shadow-cljs/issues/318 (fixed in 2.4.5)outline: none[com.google.javascript/closure-compiler-unshaded "v20180610"]lein deps, only the newest closure is there[org.clojure/clojurescript "1.10.312"]
[com.google.javascript/closure-compiler-unshaded "v20180610"]1.10.238?lein clean?.shadow-cljs, but still getting the same problemproject.cljshadow-cljs - config: /Users/wilkerlucio/Development/nubank/shuffle/shadow-cljs.edn cli version: 2.4.5 node: v8.11.2 shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm run shadow.cljs.build-report app output.html SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See for further details. Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 3964606]) at [Source: (FileInputStream); line: 1, column: 3969231] Failed reading cache for shuffle.chat.views.message: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 256687]) at [Source: (FileInputStream); line: 1, column: 257415] Failed reading cache for cljs.spec.gen.alpha: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 118722]) at [Source: (FileInputStream); line: 1, column: 138937] Failed reading cache for shuffle.chargeback.commons.purchases-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 180112]) at [Source: (FileInputStream); line: 1, column: 184263] Failed reading cache for cljs.stacktrace: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 74864]) at [Source: (FileInputStream); line: 1, column: 126007] Failed reading cache for shuffle.widgets.chargeback.ready.details: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 56211]) at [Source: (FileInputStream); line: 1, column: 56715] Failed reading cache for shuffle.chargeback.commons.chargebacks-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 42573]) at [Source: (FileInputStream); line: 1, column: 45439] Failed reading cache for fulcro.logging: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 41860]) at [Source: (FileInputStream); line: 1, column: 43739]
:azure-app ❓import "../node_modules/[NAME_OF_YOUR_LIBRARY]/lib/styles.css";(defn copy-files
{:shadow.build/stage :flush}
[build-state & {:keys [dest files]}]
(doseq [f files]
(let [input (io/file f)
input-name (.getName input)
output (io/file dest input-name)]
(io/make-parents dest input-name)
(println (format "Copying %s to %s" input output))
(io/copy input output)))
build-state)
clj. I'm liking it a lot.1.10.312clojure.test.check.generators is not loaded, but it islein basically only constructs the classpath. are you sure there aren't any classpath issues?alpha.cljs:70 Uncaught Error: Var clojure.test.check.generators/return does not exist, clojure.test.check.generators never required
at alpha.cljs:70
at cljs.spec.gen.alpha.LazyVar.cljs$core$IDeref$_deref$arity$1 (alpha.cljs:22)
at Object.cljs$core$_deref [as _deref] (core.cljs:673)
at Object.cljs$core$deref [as deref] (core.cljs:1449)
at Function.cljs$core$IFn$_invoke$arity$variadic (alpha.cljs:70)
at alpha.cljs:91
at cljs.core.Delay.cljs$core$IDeref$_deref$arity$1 (core.cljs:10369)
at Object.cljs$core$_deref [as _deref] (core.cljs:673)
at Object.cljs$core$deref [as deref] (core.cljs:1449)
at Object.cljs$spec$gen$alpha$gen_for_pred [as gen_for_pred] (alpha.cljs:148):lein true with: :source-paths ["src"]
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.312"]
[org.clojure/test.check "0.9.0"]
[thheller/shadow-cljs "2.4.5"]]clojure.test.check.generators.return$ exists so there is some renaming going onorg.clojure/clojurescript into shadow-cljs.ednreturn?1.10.312. just didn't make a new release yetlein install to use itreturn is a reserved word so it should be munged to return$cljs.main business{:paths ["src"]
:deps {org.clojure/clojurescript {:mvn/version "1.10.312"}
org.clojure/test.check {:mvn/version "0.9.0"}}}cljs.main -c my-app.coreclojure.test.check.generators.return$if((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.quick_check !== 'undefined')))){((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) is tested twiceif((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.generators !== 'undefined') && (typeof clojure.test.check.generators["return"] !== 'undefined')))){clojure.test.check.generators["return"] this failsnever required error and went from thereexists? thing is definitely weird and messes with how shadow-cljs handles js/stuffcljs.spec.gen.alpha/dynaload macro does the work that the new exists? macro does. thats why the check is done twice(and exists??clojure.test.check.generators/return gets turned into clojure.test.check.generators.return$ but js/clojure.test.check.generators.return is turned into clojure.test.check.generators["return"]exists? macro turns all vars into js/js/ has special treatment in shadow-cljs because of the JS interop it does.return or so but the CLJS compiler does when you try to access it(exists? this.ns.does.not.exist) would fail previouslyjs/ is added(core/defmacro exists?
"Return true if argument exists, analogous to usage of typeof operator
in JavaScript."
[x]
(if (core/symbol? x)
(core/let [x (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
(= "js" (namespace x)) name)
segs (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
n (count segs)
syms (map
#(vary-meta (symbol "js" (string/join "." %))
assoc :cljs.analyzer/no-resolve true)
(reverse (take n (iterate butlast segs))))
js (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
(bool-expr (concat (core/list 'js* js) syms)))
`(some? ~x)))(core/defmacro exists?
"Return true if argument exists, analogous to usage of typeof operator
in JavaScript."
[x]
(if (core/symbol? x)
(core/let [x (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
(= "js" (namespace x)) name)
segs (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
n (count segs)
syms (map
#(vary-meta (symbol (string/join "." %))
assoc :cljs.analyzer/no-resolve true)
(reverse (take n (iterate butlast segs))))
js (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
(bool-expr (concat (core/list 'js* js) syms)))
`(some? ~x)))"js" in the symbol calljs/ will also cause shadow to generate externs and I think CLJS as wellcljs.main. someone should verify that the exists? calls not actually generate externs via externs inference. I think they might."js" is there now(exists? cljs.core/return) "(typeof cljs.user.cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.return$ !== 'undefined')"cljs.analyzer/no-resolve is ignored for some reason and js/ is just an easy way to force it to not resolveFileNotFoundException: .shadow-cljs/builds/server/release/externs.shadow.js (No such file or directory)?:bootstrap buildcljs.js/eval isn't any different but the way the system is initialized is:load-on-init to get the :entries to load.lein install for example) instead of fetching it from clojars, etc.? I know I can override individual files, but in this case I'm testing changes to the library's dependencies so it'd be easier to use the JAR that I've locally built.lein install it:source-paths ["../../path/to-lib/src" "src"]lein installd. thank you, it's very easy with shadow-cljs, as always.lein or tools.deps as wellnpx shadow-cljs watch app and after a while shadow is not compiling new changes anymore. @timovanderkamp ran into the same issue today. If it occurs again and when I have more info I will keep you updatedrequire('dotenv').load() in a shadow :require statement?(:require ["dotenv" :as dotenv]) then outside ns (dotenv/load)(devcards.core/start-devcard-ui!)?(devcards.core/start-devcard-ui!).start-devcard-ui! there, yet it uses cards.fulcro-template? that was the old one that we usually clonefulcro-template. Never have looked at fulcro-lein-template as cloning has always been good enough for me. Didn't realise that fulcro-template had become old. That should give me enough to fix the issue. Thanks @wilkerlucio simple_smilerm -rf .shadow-cljs/builds/<id>/devshadow-cljs compile <id> --verboseschema pretty heavily. i wonder if it is the macro expansion.shadow-cljsconfig.edn(defn foo [a b]) to (defn foo [a b c]) the others need to be recompiled to get the warnings$ this is a really neat trick (unfortunately the code format in Cursive always breaks it apart 😞(compile-hiccup ... over and over when you break out for some actual Clojure codehx/compile all the time sux too:div.page-title and just calling (page-title ..) looks better anyways 😉:simple yescljs.spec.alpha/fspec : the code always throw error Error: Var clojure.test.check.generators/return does not exist, clojure.test.check.generators never required even though I have already required clojure.test.check.generators. I reproduced the issue in 1.10.312 currently has a problemclj --main cljs.main --repl, the code works fine1.10.238 in combination with shadow-cljsexists? macro generates1.10.238 for now$, but this also is a problem... it generates syntax, I might be a purist here, but I dislike it in same way I dislike => on midje, it seems cool until you want to apply paredit things, then the beatly of simplicity falls apart, I really got used to om.next style of having functions, they are easier to separated from vectors while reading, are faster (since there is pre-processing, they already return the elements). for $ I would hater you just have a function that does it: $ [:div "bla"] vs ($ :div "bla")$ as a sort of progressive enhancementhx.react/compile macro so it might be a good way to add it as an optional transformhx lib… I do want to explore how I can enable transforms like that to be added easily, thoughhx thoughUncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at evshadow-cljs.edn file
:dependencies [[cider/cider-nrepl "0.17.0-SNAPSHOT"]
[refactor-nrepl "2.4.0-SNAPSHOT"]]
but trying to connect cider to the nrepl port results in
WARNING: CIDER's version (0.17.0-snapshot) does not match cider-nrepl's version (nil). Things will break!
More information.
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0-SNAPSHOT (package: 20180420.223) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
shadow-cljs.edn file
:lein {:profile "cljs"}
adding the dependencies to the cljs profile in project.clj made the warning go away for cider-nrepl, which is good enough for now,clj-refactor? i still get
WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.4.0-SNAPSHOT (package: 20180420.223) and n/a, respectively.
{...
:nrepl {:port 9000
:middleware ['refactor-nrepl.middleware/wrap-refactor]}
...}'b! Here’s a simple example
(defn stats-modal []
[:> sem/Modal {:trigger (reagent/as-element (stats-button))}
[:> sem/Modal.Content
[:p "example content"]]
])
Debugging it, I get different versions of this:
> Warning: Failed prop type: Invalid prop trigger supplied to b, expected a ReactNode.
> in b (created by permits.views.home.header.stats_modal)
> in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar)
> in div (created by permits.views.home.header.header_bar)
> warning.js:34 Warning: Failed prop type: Invalid prop trigger supplied to b, expected a ReactNode.
> in b (created by permits.views.home.header.stats_modal)
> in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar)
> in div (created by permits.views.home.header.header_bar)
> in div (created by permits.views.home.header.header_bar)
> The above error occurred in the <b> component:
> in b (created by b)
> in b (created by b)
This sometimes narrows it down to the React component, but for bigger components I have no idea where the problem is. That leads me to very small refactors where I check for errors in the rendering. But with slow reload times it feels impossible to be productive. Is there a source map option to get non-minimized errors? Or does that slow it down more?
Here is my shadow-cljs.edn files:
{:source-paths ["src"]
:dependencies [[reagent "0.7.0"]
[re-frame "0.10.5"]
[binaryage/devtools "0.9.10"]
[day8.re-frame/re-frame-10x "0.3.2-react16"]
[bidi "2.1.3"]
[kibu/pushy "0.3.8"]
[cider/cider-nrepl "0.17.0"]
[soda-ash "0.81.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [permits.core]}}
:compiler-options {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
;; start a development http server
:devtools {:after-load permits.core/render
:http-root "public"
:http-port 8020
:preloads [devtools.preload day8.re-frame-10x.preload]}
:release {:output-dir "dist/js"}}}}
npx shadow-cljs server then npx shadow-cljs watch app:> operator is setting the name of the component from the function name and the function name appears as though it is getting minified. that seems weird though, because i’m pretty sure thomas only runs node modules through simple minificationsnode_modules only run through :simple yes but :simple does include variable renaming by default wherever it can. :property-renaming however is usually only used in :advanced.graphql:dev {:js-options {:variable-renaming :off}} and/or :property-renaming :off--verbose to get a bit more timing information. would be useful to know where the time is spent.:lein then :dependencies in shadow-cljs.edn are ignored. everything must be in project.clj. no idea about emacs stuff.2.4.6. btw if your CLJS namespace with the macro self requires (ns abc.cljs-embed (:require-macros [abc.cljs-embed])), you scan skip the :include-macros true everywhere elsecljss with shadow-cljs? Did you solved cache busting, i.e. do your styles hot-reload?shadow/release.shadow.server/start! and shadow.server/stop!release for productioninit fn is called from HTMLstarter.browser.init({endpoint:"http://..."}) thereinit fn store that somewhere useful and make your app use itinit that problem goes awayinit(the_config) method works just fine toocljs function?<script type="shadow/run" data-fn="my_app.feature1" data-ref="self">
{config: true,
data: big_json_blob_from_server}
</script>1.10.312 ...spec/return issue should be fixed in 2.4.61.10.312 ...spec/return issue should be fixed in 2.4.6(not (-> sym meta ::no-resolve))test.check itself, just some test code I wroteshadow-cljs command has a built-in server modelein or clj directly they won't know about that server and start a new JVMshadow-cljs run your.tool/css-inline ... instead of clj -m your.tool ...clj tool it will automatically work with shadow-cljs run as well:variable-renaming :off and :property-renaming :off but still getting these obscured errors. So here’s an example error
warning.js:34 Warning: Failed prop type: Invalid prop `trigger` supplied to `b`, expected a ReactNode.
in b (created by permits.views.home.header.stats_modal)
in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar)
in div (created by permits.views.home.header.header_bar)
For this code:
(defn stats-modal []
[:> sem/Modal {:trigger (reagent/as-element stats-button)
:basic true}
[:> sem/Modal.Content
[:p "example content"]]
])
Here’s my config:
{:source-paths ["src"]
:dependencies [[reagent "0.7.0"]
[re-frame "0.10.5"]
[binaryage/devtools "0.9.10"]
[day8.re-frame/re-frame-10x "0.3.2-react16"]
[bidi "2.1.3"]
[kibu/pushy "0.3.8"]
[cider/cider-nrepl "0.17.0"]
[soda-ash "0.81.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [permits.core]}}
:compiler-options {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:dev {:js-options {:variable-renaming :off
:property-renaming :off}}
;; start a development http server
:devtools {:after-load permits.core/render
:http-root "public"
:http-port 8020
:preloads [devtools.preload day8.re-frame-10x.preload]}
:release {:output-dir "dist/js"}}}}
stats-button. It should be (reagent/as-element (stats-button))sem is from ["semantic-ui-react" :as sem]Warning: Failed prop type: Invalid prop `trigger` supplied to `Modal`, expected a ReactNode in Modal
:variable-renaming :off(react/createElement sem/Modal #js {:trigger (fn [])})(reagent/as-element [stats-button])[:> sem/Modal {:trigger (reagent/as-element [stats-button]). No errors but the button doesn’t trigger the modal. Nothing happens. The only thing that works is [:> sem/Modal {:trigger (reagent/as-element (stats-button)). Someone else said it’s maybe because of a hacky way react-semantic-ui set up those triggers that made it require a ()react-virtualized imported like so [react-virtualized :refer [AutoSizer InfiniteLoader List]] and running the following in the repl: (react/createElement AutoSizer #js {} (js-obj)) you get the Warning: Failed prop type: Invalid prop children` of type object supplied to b, expected function.
in b`:variable-renaming :off?b component again ^:dev {:js-options {:variable-renaming :off
:property-renaming :off}}
[:> sem/Modal {:trigger (reagent/as-element [:div [stats-button]]). My issue wasn’t so much getting it to work, because I eventually got it to work through trial and error. I am just trying to make future debugging easier:variable-renaming :off might be a safer default.name property of the componentbwindow.module$node_modules$react_virtualized$dist$commonjs$index.AutoSizer.name "AutoSizer"
:simple definitely has that turned on[:> sem/Modal {:trigger (reagent/as-element [stats-button])}] doesn't workexports.Foo = function Foo() {}exports.Foo is unchanged, function Foo() {} will be:variable-naming to :off during devgraphql so maybe its the better default:trigger (reagent/as-element [:div [stats-button]])
babel-shadow-cljs-transform to your build tool chain!” no problem!The required namespace "firebase.app" is not available, it was required by "com/degel/re_frame_firebase/core.cljs". In the firebase cljsjs library it seems to export firebase.app like this:
{:file "cljsjs/development/firebase-app.inc.js" :provides ["firebase.app"]}
I’ve installed firebase app and firebase through npm but it is not picking it up. How would shadow-cljs know to point firebase-app to firebase.app?
Just wondering how I would begin to fix this[firebase :as firebase] to your (require...) vector[firebase.app :as firebase-app]firebase.app namespace with the :provides option in the deps.cljs(ns firebase.app (:require ["firebase" :as firebase])) (js/goog.exportSymbol "firebase" firebase))(config/load-cljs-edn), it would be easier to integrate with other libraries (like Component/Integrant).manifest.edn, it would be very useful information for adding caching list in serviceworker.manifest.ednrsync the compiled output to the production server^js and :compiler-options {:infer-externs :auto} in my project, the warnings are gone.(.use app "/" (.static ^js express dir) (serve-index dir (clj->js {:icons true})))
=>> client=local node server.js
Using default schema.
/Users/chen/repo/cirru/calcit-editor/dist/server.js:731
function Kv(){var a=ek.a(Hv),b=Bv(),c=mv.join(__dirname,"app");a=100+a;b.use("/",Bv.Yd(c),function(){var a=Ni(new u(null,1,[yj,!0],null));return Cv(c,a)}());b.listen(a);return Gi(P([["Serving local editor at ",x.a(Yq.blue(["",x.a(a)].join("")))].join("")]))}
^
TypeError: Bv.Yd is not a function
at Kv (/Users/chen/repo/cirru/calcit-editor/dist/server.js:731:85)
at Function.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:733:377)
at $e (/Users/chen/repo/cirru/calcit-editor/dist/server.js:152:111)
at /Users/chen/repo/cirru/calcit-editor/dist/server.js:733:270
at Object.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:734:3)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
shadow-cljs release server --pseudo-names to confirm that it is actually that part of the code.shadow-cljs/builds/server/release/externs.shadow.js file contains the .static propertystatic is one of those reserved "special" properties that the CLJS compiler will munge.static express when express is a ns :as alias. try express/static instead. that has protection against the built-in munging from the CLJS compilerstatic gets renamed to static$ by the cljs compiler and your code isn't used in dev so you only notice it on release?:compiler-options {:language-out :ecmascript5} maybe2.4.8. it was in my externs generation code which munged reserved properties when it shouldn't have.express/static. Thanks.=>> cat externs.shadow.js
/** @constructor */
function ShadowJS() {};
ShadowJS.prototype.NEGATIVE_INFINITY;
ShadowJS.prototype.NaN;
ShadowJS.prototype.POSITIVE_INFINITY;
ShadowJS.prototype.Server;
ShadowJS.prototype.ceilingEntry;
ShadowJS.prototype.cleanup;
ShadowJS.prototype.client;
ShadowJS.prototype.createConnection;
ShadowJS.prototype.createServer;
ShadowJS.prototype.dirname;
ShadowJS.prototype.env;
ShadowJS.prototype.execSync;
ShadowJS.prototype.existsSync;
ShadowJS.prototype.exit;
ShadowJS.prototype.floorEntry;
ShadowJS.prototype.fromCharCode;
ShadowJS.prototype.generate;
ShadowJS.prototype.gray;
ShadowJS.prototype.join;
ShadowJS.prototype.listen;
ShadowJS.prototype.on;
ShadowJS.prototype.readFileSync;
ShadowJS.prototype.static$;
ShadowJS.prototype.unbounded_unshift;
ShadowJS.prototype.writeFileSync;
ShadowJS.prototype.yellow;=>>
static if I use (.static express). found $static2.4.7 now.1 | (ns calva.fmt.formatter -------^------------------------------------------------------------------------ Invalid :refer, var ysera.test/is= does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [ysera.test :refer [is= is is-not]] 4 | [cljfmt.core :as cljfmt]))It is a
cljc file and seems to work fine in the clj-repl. I’m trying to use Ysera 1.2.0: https://github.com/tomas81508/ysera/blob/master/src/ysera/test.cljcis= is a macro and the file does not have :require-macros so you need to [ysera.test :include-macros true :refer [is= is is-not]](defmacro deftest [name & body]
`(if-cljs
(println "Not implemented.")
(clojure.test/deftest ~name node-test build:
========= Running Tests =======================
Error: ENOENT: no such file or directory, open '/home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/goog.debug.error.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:46:15)
at /home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:3005:1
at Object.<anonymous> (/home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:3146:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
===============================================
[:test] Build completed. (141 files, 81 compiled, 0 warnings, 16.27s)
========= Running Tests ======================= SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/ep_cloud.commit_event.js
========= Running Tests ======================= SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/ep_cloud.commit_event.js =============================================== [:test] Build completed. (141 files, 9 compiled, 0 warnings, 6.17s)
nodenode .cljs-tests/tests.js SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.shadow-cljs/builds/test/dev/out/cljs-runtime/ep_cloud.commit_event.js
node --inspect-brk .cljs-tests/tests.js and open with chrome debugger via shadow.repl? thats an old thing which isn't really relevant anymoreconsole.error("SHADOW import error", filePath);// the comment is for source-map-support which unfortunately shows the wrong piece of code but the stack is correct
try {
/* ignore this, look at stacktrace */ fn.call(global, require, module, __filename, __dirname);
} catch (e) {
console.error("SHADOW import error", filePath);
console.error(e);
throw e;
}
throw e ends up? or the console.error(e)?throw is top level...there a couple of FFE on the topconsole.error(e), I added itfailed to parse websocket message {:type :build-failure, :build-config {:target :browser, :output-dir "resources/public/js/workspaces", :asset-path "/js/workspaces", :compiler-options {:closure-output-charset "US-ASCII"}, :dev {:closure-defines {common-cljs.config/dev? true}}, :devtools {:preloads [devtools.preload fulcro.inspect.preload], :before-load nubank.cljs.workspaces.core/before-load, :after-load nubank.cljs.workspaces.core/after-load}, :modules {:main {:entries [nubank.shuffle.workspaces]}}, :build-id :workspaces}, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs:9:40\n--------------------------------------------------------------------------------\n 6 | (ws/deftest test-capitalize-words\n 7 | (assertions\n 8 | (misc/capitalize-words \"hello world\") => \"Hello World\"\n 9 | (misc/capitalize-words \"\") => \"\")))\n----------------------------------------------^---------------------------------\nnubank/shuffle/common/logic/misc_ws.cljs [line 9, col 40] Unmatched delimiter ).\n\n--------------------------------------------------------------------------------\n 10 | \n 11 | (ws/deftest test-index-of\n 12 | (assertions\n 13 | (misc/index-of #{:b} [:a :b :c]) => 1\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"] {:ex-kind :reader-error, :source-excerpt {:start-idx 5, :before ["(ws/deftest test-capitalize-words" " (assertions" " (misc/capitalize-words \"hello world\") => \"Hello World\""], :line " (misc/capitalize-words \"\") => \"\")))", :after ["" "(ws/deftest test-index-of" " (assertions" " (misc/index-of #{:b} [:a :b :c]) => 1"]}, :file #object[java.io.File 0x6178a54c "/Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs"], :resource-id [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"], :ex-type :reader-exception, :column 40, :line 9, :url #object[java.net.URL 0x6fbf5713 "file:/Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs"], :source-id [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"], :tag :shadow.build.compiler/compile-cljs}} #error {:message "Invalid symbol: cloj … lang.ExceptionInfo:.", :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:150
(anonymous) @ browser.cljs:318
:file and :url #object literals2.5.7server running, and I do watch :test in another terminal, is it expected that I see the console logs in the server terminal?node-test? It is even more important to have them in shadow because of the different classpath approach
-n, --namespace SYMBOL Symbol indicating a specific namespace to test. -r, --namespace-regex REGEX .*\-test$ Regex for namespaces to test. Only namespaces ending in '-test' are evaluated by default. -v, --var SYMBOL Symbol indicating the fully qualified name of a specific test. -i, --include SYMBOL Run only tests that have this metadata keyword. -e, --exclude SYMBOL Exclude tests with this metadata keyword.
:ns-regexp is only inclusivereturn (
<button
className={classes}
ref={initRipple}
{...otherProps}
>
{icon ? this.renderIcon() : null}
{children}
</button>
);ExceptionInfo: module without entry or suffix: @material/buttonclj-runexamples/babel project does the jsx stuff, but it may be broken. I get errors about the default on the export default MyDefaultComponentnode_modules since that is treated differently:node-script and then zip everything up (`node_modules` included)shadow-cljs release client server that doesn't happen with shadow-cljs release client && shadow-cljs release server. Am I missing something totally obvious? Would you like this in a ticket?
Bad build: https://circleci.com/gh/theasp/lapidary/42
Good build: https://circleci.com/gh/theasp/lapidary/43[:client] Build completed. (637 files, 525 compiled, 0 warnings, 95.07s) FileNotFoundException: .shadow-cljs/builds/server/release/externs.shadow.js (No such file or directory) java.io.FileOutputStream.open0 (FileOutputStream.java:-2) java.io.FileOutputStream.open (FileOutputStream.java:270) java.io.FileOutputStream.<init> (FileOutputStream.java:213) (io.clj:230) (io.clj:230) (io.clj:69) (io.clj:166) (io.clj:166) The command '/bin/sh -c npm install --save-dev shadow-cljs && shadow-cljs release client server' returned a non-zero code: 1
firebase/app used to be an alias for @firebase/app so maybe the alias is just gone?@firebase/app still exists when I npm install firebase "firebase": "^5.1.0"Uncaught ReferenceError: firebase is not defined when trying to load firebase/firebase-firestore so it seems like you are not meant to use those files directly when using a build tool<script src=...> inclusion["@firebase/app" :default fb]
["@firebase/firestore"]shadow-cljs release dev it doesn't anymore. One of the node_modules deps is an empty object when importing.:infer-externs :auto turned on?:dev build is a browser build?cljsc2.cljs.core imports a bunch of chrome specific apisshadow-cljs watch dev works?shadow-cljs watch dev seems to work. but with externs on I do get some warnings:
Cannot infer target type in expression (. (gdom/getElement "notebook-container") prepend el):optimizations :simple anyways so its probably not externs:as vs :default?["@firebase/app" :default fb]
["@firebase/firestore"](.initializeApp fb ...)parinfer-codemirror a string. But that didn't change it.{:forceBalance true} looks wrong. probably should be #js {:forceBalance true}?js/console.log parinfer-codemirror it seems to be an empty object, so init is not defined.parinfer-codemirror and the object is not emptynode_modules/parinfer-codemirror/parinfer-codemirror.js is the actual file you want?node_modules.define?window.define = undefined after the jupyter notebook js?(:require ["definedeleter.js"] in the file, does the trick!:entries [..] :prepend "window.define = undefined;" in your :modules config:prepend "window.defineOriginal = window.define; window.define = undefined;" :append "window.define = window.defineOriginal;"define branch is never taken in amd wrapped filesshadow-cljs resolve rules that prevented firebase/app from working properly. fixed in 2.4.9.FileNotFoundException: .../stest/node_modules/apollo-upload-client/lib/main (Is a directory)
java.io.FileInputStream.open0 (FileInputStream.java:-2)
java.io.FileInputStream.open (FileInputStream.java:195)
java.io.FileInputStream.<init> (FileInputStream.java:138)
I tried adding this option:
:js-options {:resolve {"apollo-upload-client" {:target :npm
:require "apollo-upload-client/lib/main/index.js"}}}
where apollo-upload-client/lib/main/index.js is definitely a file, and then I still get:
ExceptionInfo: :resolve override for "apollo-upload-client" to "apollo-upload-client/lib/main/index.js" which does not existthe file I am trying to compile:
(ns example.core (:require ["apollo-upload-client"]))
"main": "lib/main", "module": "lib/module",
lib/main/index.js instead 😛{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adb7adb2b3"}, :content ("[email protected]")}npx shadow-cljs release build1 build2 is taking about ~360s.shadow-cljs/builds directoryclj-run or run(defn build-all [] (shadow/release :build1) (shadow/release :build2)) then shadow-cljs run that.ns/build-all:jvm-opts ["-Xmx2G"] or so in shadow-cljs.edndeps.edn + :deps true:dependencies [[cider/cider-nrepl "0.16.0-SNAPSHOT"] [binaryage/devtools "0.9.7"] [devcards "0.2.5"] [re-frame "0.10.5" :exclusions [reagent "0.7.0"]]]
shadow-cljs - dependency update failed - java.lang.Character cannot be cast to clojure.lang.Named
(ns my-ns (:require [azure-storage :as az-storage]))but I receive
conflict on "az-storage" by "azure-storage" used by "shadow.js.shim.module$azure_storage"
{:tag :shadow.build.ns-form/require-conflict, :ns-info {:rename-macros nil, :renames {}, :meta {:source "ep-cloud.azure", :file "repl-input.cljs", :line 1, :column 5, :end-line 1, :end-column 19}, :ns-aliases {clojure.spec.alpha cljs.spec.alpha, lodash.upperfirst shadow.js.shim.module$lodash_upperfirst, fs shadow.js.shim.module$fs, bunyan shadow.js.shim.module$bunyan, pg shadow.js.shim.module$pg, process shadow.js.shim.module$process, util shadow.js.shim.module$util, clojure.pprint cljs.pprint, dotenv shadow.js.shim.module$dotenv, lodash.camelcase shadow.js.shim.module$lodash_camelcase, lodash.kebabcase shadow.js.shim.module$lodash_kebabcase, ajv shadow.js.shim.module$ajv, aws-sdk shadow.js.shim.module$aws_sdk}, :use-macros nil, :excludes #{}, :name ep-cloud.azure, :js-aliases {"azure-storage" shadow.js.shim.module$azure_storage}, :imports nil, :requires {node-util util, ep-cloud.define ep-cloud.define, shadow.js.shim.module$azure_storage shadow.js.shim.module$azure_storage, cljs.core cljs.core, gobj goog.object, goog goog, goog.object goog.object, util util, az-storage shadow.js.shim.module$azure_storage, azure-storage azure-storage, shadow.js.shim.module$util shadow.js.shim.module$util, def ep-cloud.define}, :seen #{:require}, :uses nil, :require-macros {cljs.core cljs.core}, :flags {:require #{}}, :js-deps {"azure-storage" {:as az-storage}}, :deps [goog cljs.core ep-cloud.define goog.object shadow.js.shim.module$util shadow.js.shim.module$azure_storage util azure-storage]}, :merge-key :requires, :sym az-storage, :ns azure-storage}
ExceptionInfo: conflict on "az-storage" by "azure-storage" used by "shadow.js.shim.module$azure_storage"
clojure.core/ex-info (core.clj:4754)
clojure.core/ex-info (core.clj:4754)
shadow.build.ns-form/merge-require (ns_form.clj:245)
shadow.build.ns-form/merge-require (ns_form.clj:238)
shadow.build.ns-form/process-symbol-require (ns_form.clj:292)
shadow.build.ns-form/process-symbol-require (ns_form.clj:281)
shadow.build.ns-form/process-require (ns_form.clj:323)
shadow.build.ns-form/process-require (ns_form.clj:320)
storage seems to solve itThe required namespace "pages.handlers" is not available, it was required by "shadow/umd_helper.cljs".:source-paths are the same?:source-paths now?<source-path>/pages/handlers.cljs:node-test discovers files so you may just have a typo in your namespacepage.handlers or pages.handler :source-paths ["src"]pages.handlerssrc/pages/handlers.cljs?src/pages/handlers.cljshadow-cljs browser-repl then (require '[pages.handlers :as x]) give you? without lein?:source-paths is only at the top level. it is not per build.:js-options {:js-provider :shadow} ; include deps in single resource this doesn't work for nodewatch* - https://github.com/thheller/shadow-cljs/pull/326 - it is currently throwing away the config map it is passed, re-reading the config from its build-id.masterclj-run (map #(spit (str % ".txt") "test") ["one" "two"])clj-run is for calling fully qualified functions, ie. your.thing/foomap is lazy and doesnt do anything unless consumed (wrap in doallor use doseq):node-test target be made to generate tests from the :test functions inside function attribute maps?cljs.test/deftest but since cljs.test doesn't look for anything besides that the change would really need to be in cljs.testcljs.test already…deftest? having lots of metadata on defns makes them sort of unreadable no?cljs.test for the is assertions? it is generally best practice to have separate your.thing and your.thing-test namespacesdeftest as well as the defn for me?(defn- split
"Splits text at idx"
{:test (fn []
(is= [" " " "]
(split " " 1))
(is= ["(foo\n " "\n bar)"]
(split "(foo\n \n bar)" 6)))}
[text idx]
[(subs text 0 idx) (subs text idx)])
watch?:autorun true:autorun true, The watcher recompiles the test target and I can run it using node, but it is not automatically run, AFACS.:server-tests {:target :node-test
:output-to "target/test/tests.js"
:ns-regexp ".test."
:autorun "true"}shadow-cljs both locally and globally?shadow-cljs - command completed without status #js { .. giant js object }?{:status nil, :signal "SIGKILL", :output #js [nil nil nil], :pid 546, :stdout nil, :stderr nil … not super helpful 😞node_modules/date-fns has 201 elements. I suspect this is because the date-fns library contains several sub-folders—one for each function—so that the user can cherry-pick the individual fns she wants to use.Error: ENOENT: no such file or directory, open '/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js'Is there a way I can avoid that? Am I still going about it the wrong way?
SIGKILL looks indeed like the process is getting killed by maybe the OOM killer. you can configure the max memory by setting :jvm-opts ["-Xmx2G"] in shadow-cljs.edn.:default (eg. :default whatever). the name is completely up to you.:node-test. fixed in master, will make a release laterlein clean thing. Sorry for the noise!lein clean should NEVER be required ever. If it is its a bug I want to fix. please let me know if you run into this again#error {:message "The map literal starting with \"node_modules/date-fn...\" contains 201 form(s). Map literals must contain an even number of forms.", :data {:type :reader-exception, :ex-kind :reader-error}}
generate from the replnode_modules/date-fn?... in there?clojure.java.shell/sh4360, ...}... gets there. its supposed to be using the safeguard for that so emacs settings *print-length* doesn't mess it upgenerate*print-length* for the REPL(binding [*print-length* nil] (generate ...))*print-length* is really really bad for shadow-cljs 😛htmlparser2 looks okay to me... https://github.com/fb55/htmlparser2/blob/master/lib/Tokenizer.js#L3 (unlike the issue with clipboard I ran into last week, the required file does actually exist this time!)2.4.11. thanks for the report.:dev/after-load callback(app-routes) probably uses goog.History which must only ever be created oncediv#wrapper element does not existgoog.History will reset the dom when it is constructed when the page finished loadinggoog.History is sort of ancient and should probably not be used anymorereset! the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it.
Is there a way to persist that value in the repl so that it survives a re-compilation?(shadow/nrepl-select :app)defonce instead of def. that’s what you’ll want to with your application statereset! the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it.(shadow/nrepl-select :app) you are actually running code on the browserdbg atom in cljs.user. and I can refer to those globally by fully qualifying the namespace 🙂Stack: Error: ENOENT: no such file or directory, open 'D:\home\arichiardi\git\laputa\lambda-cqrs\.shadow-cljs\builds\az\dev\out\cljs-runtime\goog.debug.error.js'what am I missing?
.shadow-cljs. This is shadow-cljs compile and I though I could still deploy that even if "unoptimized" without .shadow-cljs. Probably not - meaning compile is not self containedshadow-cljs release your-thing. not compile.compile is a dev build only meant to run on the machine it was compiled onelein install. option b) add <clone>/src/main to you :source-paths. option c) use lein + checkouts. option d) use deps.edn :local/rootfspec and seems the related issue has been fixed, thanks thheller!node-sass in my work project directly from the CLI, didnt' try any of the JVM related sass tools.run-p. pretty handy for simple build script stuff------ WARNING #1 -------------------------------------------------------------- File: clojure/math/combinatorics.cljc:278:26 -------------------------------------------------------------------------------- 275 | indices (apply concat 276 | (for [i (range (count v))] 277 | (repeat (f (v i)) i)))] 278 | (map (partial map v) (lex-permutations indices)))) --------------------------------^----------------------------------------------- clojure.math.combinatorics/lex-permutations is deprecated -------------------------------------------------------------------------------- 279 | 280 | (defn permutations 281 | "All the distinct permutations of items, lexicographic by index 282 | (special handling for duplicate items)." -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: clojure/math/combinatorics.cljc:285:29 -------------------------------------------------------------------------------- 282 | (special handling for duplicate items)." 283 | [items] 284 | (cond 285 | (sorted-numbers? items) (lex-permutations items), -----------------------------------^-------------------------------------------- clojure.math.combinatorics/lex-permutations is deprecated -------------------------------------------------------------------------------- 286 | 287 | (all-different? items) 288 | (let [v (vec items)] 289 | (map #(map v %) (lex-permutations (range (count v))))) -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: clojure/math/combinatorics.cljc:289:23 -------------------------------------------------------------------------------- 286 | 287 | (all-different? items) 288 | (let [v (vec items)] 289 | (map #(map v %) (lex-permutations (range (count v))))) -----------------------------^-------------------------------------------------- clojure.math.combinatorics/lex-permutations is deprecated -------------------------------------------------------------------------------- 290 | 291 | :else 292 | (multi-perm items))) 293 | --------------------------------------------------------------------------------
org.clojure/math.combinatoricsException in thread "async-dispatch-8" java.lang.OutOfMemoryError
at java.base/java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:188)
at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:180)
at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:147)
at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:512)
at java.base/java.lang.StringBuffer.append(StringBuffer.java:275)
at java.base/java.io.StringWriter.write(StringWriter.java:106):build-complete message never makes it to the client since it fails printing{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c1b2a9a0a5aeb6eca2adabb281f3eff5eff0f2"}, :content ("[email protected]")}querystring is very much installed my node_modules
shadow-cljs - config: /Users/ericholiphant/projects/fm-ui/shadow-cljs.edn cli version: 2.4.13 node: v10.5.0 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app Jul 01, 2018 5:00:34 PM org.xnio.Xnio clinit INFO: XNIO version 3.3.8.Final Jul 01, 2018 5:00:34 PM org.xnio.nio.NioXnio clinit INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :app available at shadow-cljs - server version: 2.4.12 shadow-cljs - server running at shadow-cljs - socket REPL running on port 56649 shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build failure: The required JS dependency "querystring" is not available, it was required by "node_modules/url/url.js". Searched in:/Users/ericholiphant/projects/fm-ui/node_modules You probably need to run: npm install querystring
shadow-cljs as a dep in your project?npm install shadow-cljsquerystring is actually installed it should probably just be using thatFROM urbanslug/shadow-cljs RUN install aws-cliIn my case I was using it for a CD pipeline
:shadow.build/mode :release is being called when I run npx shadow-cljs watch app{:app {:target :browser
:build-hooks [(util.task/hook) (util.task/css-inline-hook)]...}
(defn css-inline-hook
{:shadow.build/mode :release
:shadow.build/stage :flush}
[build-state & args]
(do
(println "Inlining css")
(css-inline)
build-state))`{:shadow.build/keys [mode] :as build-state} and then test it via (when (= mode :dev) ...)The build-state has some important entries which might be useful for your hooks: :shadow.build/build-id - the id of the current build (eg. :app) :shadow.build/mode - :dev or :release
:ssl {} go in my config?shadow-cljs watch npm in one tabshadow-cljs node-repl npm in anothernode-repl is completely standalone and does not take a build argument. you probably want shadow-cljs cljs-repl npm. if you want REPL history and stuff use rlwrap shadow-cljs cljs-repl npm. didn't have time to add that yet.No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.:npm used and load your JS:npm target is :npm-module than REPL is a lot harder to do:browser is generally the easiest since you get easy access to browser devtools:node-script if you need node stuffnode-repl doesn't do live reload since thats not usually how you work with a REPLtools.namespace or manually calling (require 'foo.bar :reload) or load-filequickstart-browser repo just run npx shadow-cljs watch app and open rlwrap npx shadow-cljs cljs-repl appshadow-cljs watch ci. The karma error is a bit obscure, but I can trace it down to this line: https://github.com/thheller/shadow-cljs/blob/5df9969639030128586afd2968db2ea5f704b4b0/src/main/shadow/test/karma.cljs#L17
Error message:
{
"message": "Uncaught TypeError: s.replace is not a function\nat ci.js:138901:1\n\nTypeError: s.replace is not a function\n at Object.clojure$string$replace_all [as replace_all] (ci.js:53046:10)\n at Object.clojure$string$replace [as replace] (ci.js:53105:23)\n at Object.shadow$test$karma$indent [as indent] (ci.js:358372:23)\n at shadow$test$karma$format_log (ci.js:358467:304)\n at ci.js:32847:89\n at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32848:3)\n at cljs.core.LazySeq.sval (ci.js:26691:109)\n at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (ci.js:26842:10)\n at Object.cljs$core$seq [as seq] (ci.js:19645:13)\n at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32821:36)",
"str": "Uncaught TypeError: s.replace is not a function\nat ci.js:138901:1\n\nTypeError: s.replace is not a function\n at Object.clojure$string$replace_all [as replace_all] (ci.js:53046:10)\n at Object.clojure$string$replace [as replace] (ci.js:53105:23)\n at Object.shadow$test$karma$indent [as indent] (ci.js:358372:23)\n at shadow$test$karma$format_log (ci.js:358467:304)\n at ci.js:32847:89\n at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32848:3)\n at cljs.core.LazySeq.sval (ci.js:26691:109)\n at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (ci.js:26842:10)\n at Object.cljs$core$seq [as seq] (ci.js:19645:13)\n at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32821:36)"
}
s. I'd be surprised if that was the problem though!is, which is invoked when the test fails. Is the correct fix to just call str on a s? https://github.com/thheller/shadow-cljs/blob/5df9969639030128586afd2968db2ea5f704b4b0/src/main/shadow/test/karma.cljs#L15isnpx babel node_modules/that-module should be enough2.4.15 that now automatically deals with the global use of Buffer which previously required an ugly hack. Anyone using such a Buffer hack please try it without in 2.4.15.Buffer and webpack and others just rewrite itweb3 notoriously uses the Buffer object almost everywhere which should just work now without any hacksObject doesn't support property or method 'includes', do I have to manually somehow include a polyfill to resolve this?shadow-cljs release?shadow-cljs release app when compilingshadow$provide.module$node_modules$$atlaskit$analytics_next$dist$cjs$withAnalyticsEvents = function(a, k, b, f, c) { ["@atlaskit/analytics-next" :as as] does not cause the errorthis.mapCreateEventsToProps = function(c, d)(.includes #js [1 2 3] 3)node_modules file polyfills get lost(:require ["thing" :default foo]). not official yet but works in shadow-cljs. https://dev.clojure.org/jira/browse/CLJS-2376:npm-module and include the file directly via import or require@import "~../../node_modules/slick-carousel/slick/slick.css"; this could just pack it into my css output.ns require. I do however have plans to add something similar via some macrosjs/require is horrible IMHOBuffer support that works in node and the browser thanks to webpack onlybrowserify too. If they had just decided to not support it people would be using require("buffer") properly instead todayObject.assign polyfills------ WARNING #7 -------------------------------------------------------------- File: /Users/calebmacdonaldblack/Projects/medial/test/cljs/medial_web/components/util_test.cljs:1:5 Invalid Filename, got cljs/medial_web/components/util_test.cljs but expected medial_web/components/util_test.cljs (or .cljc) --------------------------------------------------------------------------------
:source-paths ["src/cljs" "medial-common/src" "src/clj"] :test-paths ["test/cljs" "test/clj"]
:lein true and those options are in project.clj"test" to the classpath"test" to the classpath?lein classpath and check if /Users/calebmacdonaldblack/Projects/medial/test is on theretest -> test/cljs but I though I was still getting the warning. Maybe I forgot to restart or something but I’ve definitely no longer getting any warnings. Thanks for the help anywayERROR in ./js.reagent.core.js Module not found: Error: Can't resolve './shadow.js.shim.module$react.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs' @ ./js.reagent.core.js 24:0-43 @ ./visitor.main.js @ /home/hlolli/Documents/visitor/index.js @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js ERROR in ./js.reagent.dom.js Module not found: Error: Can't resolve './shadow.js.shim.module$react_dom.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs' @ ./js.reagent.dom.js 22:0-47 @ ./js.reagent.core.js @ ./visitor.main.js @ /home/hlolli/Documents/visitor/index.js @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.jsso I require it explicitly in one of my cljs source file
(:require ["react"]
["react-dom"])
but that wont fly far
symbol shadow.js.shim.module$react already provided by [:shadow.build.classpath/resource "js/shadow.js.shim.module$react.js"], conflict with [:shadow.build.js-support/require "react"]in general
shadow.js.shim.module$react_dom.js and shadow.js.shim.module$react.js are just one of hundreds of requires that webpack complains about being missing. I tried https://www.npmjs.com/package/closure-loader if this was a goog.provide issue, didn't make a difference. I guess these files are reachable for shadow-cljs, but are not spit to files. Maybe this is configureable, or :npm-modules for webpack isn't the right build../js.reagent.core.jsjs. in front?node_modules/shadow-cljsnode_modules/shadow-cljs/reagent.core.js for examplenode_modules/shadow-cljsnode_modules/shadow-cljs/cljs.core.jsjs. in front should not be there:public {:target :npm-module
:output-dir "node_modules/shadow-cljs"
:asset-path "/"
;; :source-map true
:module-loader true
:js-options {:resolve
{"scroll" {:target :file
:file "overrides/scroll_index.js"}}
:js-provider :shadow}
:modules {:main {:entries [visitor.main]}}
:compiler-options {;; :source-map true
:source-map true
:infer-externs :auto
;; :optimizations :none
}
;; :devtools {:http-root "public"
;; :http-port 8088
;; :after-load visitor.main/init}
:open-file-command
["emacsclient" "-n" ["+%s:%s" :line :column] :file]}
{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [visitor.main]
:compiler-options {:infer-externs :auto
:source-map true}}:open-file-command is not valid in a build config btw. it should be at the top leveljs. in frontjs. in front is coming from. I just tested locally and everything is fine.js. but okERROR in /home/hlolli/Documents/visitor/index.js Module not found: Error: Can't resolve 'shadow-cljs/visitor.main' in '/home/hlolli/Documents/visitor' @ /home/hlolli/Documents/visitor/index.js 1:0-35 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.jsbasically my webpack config
/home/hlolli/Documents/visitor/node_modules/shadow-cljs/visitor.main.js exists?node require("shadow-cljs/visitor.main")Error: Cannot find module 'shadow-cljs/visitor.main'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
__dirname?> require("shadow-cljs/visitor.main")
ReferenceError: window is not defined
at Object.<anonymous> (/home/hlolli/Documents/visitor/node_modules/shadow-cljs/ajax.xml_http_request.js:46:6)
at Module._compile (internal/modules/cjs/loader.js:654:30)
webpack screwing with me I assumeERROR in ./ajax.xml_http_request.js Module not found: Error: Can't resolve 'xmlhttprequest' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs' @ ./ajax.xml_http_request.js 42:160-185 @ ./ajax.core.js @ ./visitor.main.js @ /home/hlolli/Documents/visitor/index.js @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.jsbut it could be anything at this point, will report if Im still stuck
npm install xmlhttprequestERROR in ../xmlhttprequest/lib/XMLHttpRequest.js Module not found: Error: Can't resolve 'child_process' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib' @ ../xmlhttprequest/lib/XMLHttpRequest.js 15:12-36 @ ./ajax.xml_http_request.js @ ./ajax.core.js @ ./visitor.main.js @ /home/hlolli/Documents/visitor/index.js @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js ERROR in ../xmlhttprequest/lib/XMLHttpRequest.js Module not found: Error: Can't resolve 'fs' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib' @ ../xmlhttprequest/lib/XMLHttpRequest.js 16:9-22 @ ./ajax.xml_http_request.js @ ./ajax.core.js @ ./visitor.main.js @ /home/hlolli/Documents/visitor/index.js @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
:runtime :browser in the build configcljs.core/*target*{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [visitor.main]
:runtime :browser
:compiler-options {:infer-externs :auto
:source-map true}}
like this?.shadow-cljs/builds/public. not sure if changing that nukes the cache:compiler-options {:closure-defines {cljs.core/*target* "browser"}} in the build config(def xmlhttprequest
(if (= cljs.core/*target* "nodejs")
(let [xmlhttprequest (.-XMLHttpRequest (js/require "xmlhttprequest"))]
(goog.object/set js/global "XMLHttpRequest" xmlhttprequest)
xmlhttprequest)
(.-XMLHttpRequest js/window)))(def xmlhttprequest (.-XMLHttpRequest js/window))js/require call so it wouldn't failWarning: It looks like you're using a minified copy of the development build of React.node_modules/raven-js/src/utils.js exists in my test project, but in prod it's missing (all neighbouring source files are there). This might be a red herring but I can't see any other differences worthy of note.module\$node_modules\$raven_js\$src\$utils.js is served up in both projects, along with the .map file.lein?shadow-cljs watch app from one terminal window, and boot to serve assets out of target/public.<output-dir>/cljs-runtime/module\$node_modules\$raven_js\$src\$utils.js file is corrupted or so1,3c1,3
< shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,new Request(""),
< new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports,shadow$shims){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,
> new Request(""),new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
.shadow-cljs/builds directory just to rule out a cache issue,shadow$shims which was added recently3c3
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1"))
replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):js-options?${param} and replaces them with a hashed version, or in the case of development skips over them. It looks like the regex is being incorrect replaced by the task. 😞${img/foo.png} in bar.html becomes img/foo-af28b.png in the html file, plus a new file is written to the file path..shadow-cljs/builds/ folder shaved off about a minute or so--verbose? cache should be way more than that:karma build: -> build target: :karma stage: :configure NullPointerException: shadow.build.targets.karma/configure (karma.clj:21) shadow.build.targets.karma/configure (karma.clj:16) shadow.build.targets.karma/process (karma.clj:112) shadow.build.targets.karma/process (karma.clj:108) clojure.lang.Var.invoke (Var.java:381) shadow.build/process-stage/fn--15189 (build.clj:120) shadow.build/process-stage (build.clj:117) shadow.build/process-stage (build.clj:109)
:output-to, need to add specs for the config stilloutput-dird on socket wpx59euvS82blWCjAAAA with id 10464947
HeadlessChrome 0.0.0 (Mac OS X 10.13.5) ERROR
{
"message": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at ",
"str": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at "
}shadow.test.karma.init fn maybe and doesnt find it?{:target :karma
:ns-regexp ".devcards$"
:output-to "target/karma/tests.js"}module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
// The directory where the output file lives
basePath: 'target/karma/',
// The file itself
files: ['target/karma/tests.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
})
};
files is relational to basePath(:require ["react-d3-speedometer" :default d3-speedometer)
and use it like [:> d3-speedometer](:require ["react-d3-speedometer" :as s]) (defn x [] [:> ...how to call default export of s?]
(react/createElement "h1" nil #js["hello world"] ) seems to return nil at the repl, but when i js/console.log it I get a react element value?aws-sdk package and it is bundling the node.js version:
(ns my-ns.aws (:require ["aws-sdk/lib/util" :as util])) (prn [(util/isNode) (util/isBrowser)]) ;; => [true false]in the aws-sdk
package.json there are some "browser" settings which maybe aren’t being read?
"browser": {
"lib/aws.js": "./lib/browser.js",
"fs": false,
"./global.js": "./browser.js",
"./lib/node_loader.js": "./lib/browser_loader.js"
},
"browserify": {
"transform": "./dist-tools/transform.js"
},
:browser?isBrowser: function isBrowser() { return process && process.browser; },
isNode: function isNode() { return !util.isBrowser(); },:closure-defines {shadow.js.process.browser true}:browser target by default but for some reason isn'tbrowser field in package.json is fully supported. its just that checked that failedshadow-re-frame repo the current recommended starting point for a project of that type?lein for that though. as far as comsuming that goes there is nothing special regarding shadow-cljs and it works just like any other cljs lib.:browser target?cljsjs route if there isn't a package for apollo-client already?devcards.core/start-devcard-ui!println) get removed tho 😞(defn ^:export dont-kill-me [])wrap-reload and (clojure.tools.namespace.repl/refresh) but I can't seem to get anything to work.Does not redirect HTTP traffic to HTTPS
2. Does not use HTTP/2 for all of its resources
Is there a simple way to set this up?srcset on an img tag. For some reason using this attribute triggers a network request for the same image every time I change the browser size. When hosted on Netlify this does not happen.^:export doesn't actually preserve the "namespace". there are no namespaces in :advanced compilation. it just basically sets your.app.foo = xW; after the fact. so what once was your.app.foo became xW and is then reassigned later.npm directly, so you npm install it and start using itreact-avatar-editor. you can substitute that with material-ui or any other of the material design wrappers(:require
["material-ui/styles" :as styles]
["material-ui/AppBar" :as AppBar]
["material-ui/styles/MuiThemeProvider" :as Theme]
)
(def muiTheme
(styles/createMuiTheme
#js {:palette #js {:primary #js {:main "#7796a8" ;; "#3f50b5"
:dark "#848F92" ;; "#BCCACD"
:light "#e0e7eb" ;;"#002884"
:contrastText "#fff"}
:secondary #js {:light "#7796a8" ;; "#3f50b5"
:main "#e0e0e0" ;;"#757ce8"
:dark "#e0e7eb" ;;"#002884"
:contrastText "#000"}
:stepper #js {:iconColor "green"}}}))
..later...
[:> Theme/default {:theme muiTheme} .... rest of app]
Theme/default. If your require is instead ["material-ui/styles/MuiThemeProvider" :default Theme] then you can just say Theme.:require statements in shadow-cljs. I've been using it for a while so feel free to direct questions my way.DEBUG logs from shadow-cljs in my console. Is there a way to configure shadow-cljs logging?18-07-10 15:23:32 Kenny-Compute-Software-Macbook.local DEBUG [shadow.cljs.devtools.server.worker.impl:286] - :shadow.cljs.devtools.server.worker.impl/runtime-msg 7b6011fe-e547-4b81-8ee2-fba61e36daf8 :ping
deps.edn.shadow-cljs npm thing sets up logging. deps.edn does not.handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler .level=INFO java.util.logging.FileHandler.limit=5000000 java.util.logging.FileHandler.count=3 java.util.logging.FileHandler.append=true java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter java.util.logging.FileHandler.level=INFO java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter java.util.logging.ConsoleHandler.level=WARNING java.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS - %4$s] %5$s%6$s%n java.util.logging.FileHandler.pattern=.shadow-cljs/shadow-cljs.log
shadow-cljs to run stuff-Djava.util.logging.config.file=logging.properties to your jvm args:jvm-opts ["-Djava.util.logging.config.file=logging.properties"] in deps.edndeps.edn integrationlein so sometimes has unexpected resultslein or tools.deps instead of just using the built-in dependencies support?lein-cooper plugin to start shadow-cljs and node-sass via a single command (i.e. lein dev).clj-run] in your example here: https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d6bdb3b8b8af969db3b8b8affb95b9bba6a3a2b3fb85b9b0a2a1b7a4b3fb9bb7b5b4b9b9bd"}, :content ("[email protected]")}
The issue was I copy and pasted the code from the example and forgot to update the build id to the build id for my project.sh that did not complete because it is node-sass's watch command. So I'm guessing the call to shadow/watch did not occur until after I ^C'ed.
(defn start-dev
{:shadow/requires-server true}
[& args]
(prn (shell/sh "npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"))
(shadow/watch :app))
shell/sh never exits so watch is never called(let [cmd ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]]
(future
(-> (ProcessBuilder. cmd)
(.inheritIO)
(.start)
(.waitFor))))lein-cooper handle the output? are they all just dumping to stdout?clojure -m shadow.cljs.devtools.cli compile app is identical to shadow-cljs compile appshadow-cljs with clojure -m shadow.cljs.devtools.cli for any command the only thing you miss out of is the server support. see https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html(ns dev.build
(:require
[join-process.core :as join-proc]))
(defn start-dev
[& args]
(join-proc/join-process [{:name "cljs"
:cmds ["shadow-cljs" "watch" "app"]}
{:name "sass"
:cmds ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]}]))
(defn -main
[& args]
(apply start-dev args))
Running this command clj -A:dev:start-dev with these deps.edn :aliases:
{:dev {:extra-paths ["env" "devcards-src"]
:extra-deps {compute/join-process {:git/url ""
:sha "3068d554275575f499c0bd999ea3e17fc41eabad"}}}
:start-dev {:main-opts ["-m" "dev.build"]}}
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2e454b4040576e654b404057036d41435e5b5a4b037d41485a594f5c4b03634f4d4c414145"}, :content ("[email protected]")}
However, nothing was printed to the console.shadow-cljs - connected to server. a server instance is already runningclj directly since clj-run assumes you will be running shadow-cljs code and loads all the namespacesclj directlynew webpack.DefinePlugin({
'DEVELOPMENT': JSON.stringify(process.env.NODE_ENV === 'development'),
}),
then I can see if I'm in development mode
(def dev? js/DEVELOPMENT)some plugin like this may exists with other means.
:closure-defines is a good option, you can also use https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading or combine both<- Cache write: seekeasy/upload.cljs (4825 ms) does that mean it is taking 4.8 seconds just to write a single file to disk or does that include some kind of wait time for other writes too?.shadow-cljs/builds/<your-build>/dev/ana/seekeasy/upload.cljs.cache.transit.json is?"^2I","^2D","^43","^44","^5W","^6R":dependencies [[org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.10.238"] [com.bhauman/spell-spec "0.1.1"] [expound "0.7.1"] [metosin/spec-tools "0.7.1"] [gnl/ghostwheel "0.2.2"] [org.clojure/test.check "0.9.0"] [reagent "0.7.0"] [secretary "1.2.3"] [venantius/accountant "0.2.3" :exclusions [org.clojure/tools.reader]] [funcool/promesa "1.9.0"] [cljs-ajax "0.7.3"] [com.rpl/specter "1.1.0"]]
module$node_modules$react_dom$lib$reactProdInvariant module$node_modules$react_dom$lib$ReactPropTypesSecret module$node_modules$prop_types$factory module$node_modules$react$lib$React module$node_modules$fbjs$lib$invariant module$node_modules$fbjs$lib$warning shadow.js module$node_modules$react_dom$lib$reactProdInvariant module$node_modules$react_dom$lib$ReactPropTypesSecret module$node_modules$prop_types$factory module$node_modules$react$lib$React module$node_modules$fbjs$lib$invariant module$node_modules$fbjs$lib$warning
lein new shadow-cljs 8bs-vision-survey +reagenttemplate. according to the readme it has the following commands:
yarn install, yarn watch, yarn clean, yarn releasethe shadow-cljs.edn file looks like this
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies [[binaryage/devtools "0.9.7"]
[reagent "0.8.0-alpha2"]
[org.clojure/core.async "0.4.474"]
[com.pupeno/free-form "0.6.0"]
[cljs-http "0.1.45"]
[com.cemerick/url "0.1.1"]]
;; set an nrepl port for connection to a REPL.
:nrepl {:port 8777}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:main
{:entries [vision-survey-8bs.core]}}
:devtools
;; before live-reloading any code call this function
{:before-load vision-survey-8bs.core/stop
;; after live-reloading finishes call this function
:after-load vision-survey-8bs.core/start
;; serve the public directory over http at port 8700
:http-root "public"
:http-port 8700
:preloads [devtools.preload]}
}}}
got it working while developing and decided to deploy the app. i ran yarn releaseand deployed the public folder to a server. the app runs but only displays the placeholder page with "Shadow-cljs rocks!" - text. any pointers how to fix it?
watch running for very long times (days) or do you restart frequently?upload.cljs, just that file and its dependencies get bigger2.4.20. pretty obvious bug when looking at it. to the degree that I can't figure out how caching works at all. that should really have invalidated the cache all the time.<script>vision-survey-8bs.core.init();</script>at the end of the index document. so no numbers allowed in function names?
- is actually minus. must "munge" the name to use _ instead. <script>vision_survey_8bs.core.init();</script>1. That can't happen. 2. That doesn't happen on my machine. 3. That shouldn't happen. 4. Why does that happen? 5. Oh, I see. 6. How did that ever work?
init function._ you just might be missing the important ^:export bit on the (defn ^:export init [] ...).h files: they sure did make compilation fasterghostwheel/core.cljc has to be recompiled when I change file A, which includes file B, which uses ghostwheel, even though B and ghostwheel don’t changeghostweel.core recompiled?ghostweel.core if you touch a namespace that requires it though2.4.20? I can totally see this happening with the older versions0.2.3-SNAPSHOT^:dev/always set on the tracing namespace (leftover from development) and ghostwheel.reporting+ghostwheel.core depend on it, so there's a whole lot of unnecessary work being done.shadow-cljs.edn, it kicked off a recompile, but it didn’t actually download new artifacts. is that intended?:dependencies should not trigger it. downloading new artifacts is only done of startup since doing that at runtime is way too complicated["/js/audio/wavesurfer.cursor-time" :default wavesurfer-cursor-time-plugin]The js file looks like:
class CursorTimePlugin {
static create(params) { ... }
}
...
export default CursorTimePlugin;
The runtime error I get when I compile a release build is:
Uncaught TypeError: $module$js$audio$wavesurfer_cursor_time$$.default.create is not a function(.create ^js wavesurfer-cursor-time-plugin (clj->js (:cursor-time options)))
I've experimented with all sorts of defs in my externs file, but none make the problem go away! For example, the following doesn't work:
var $module$js$audio$wavesurfer_cursor_time$$ = {};
$module$js$audio$wavesurfer_cursor_time$$.default = {};
$module$js$audio$wavesurfer_cursor_time$$.default.create = function(params) { };
g432 is not a function:pseudo-names true. If I turn it off then I do indeed get wpa.default.create is not a function.(def thing #js{:getSomething (fn [] :a)})
=> #'cljs.user/thing
(goog.object/get thing "getSomething")
=> #object[getSomething]
((goog.object/get thing "getSomething"))
=> :agoog.object/get to grab the create function off of the imported object and then invoke that valuecreate symbol somehow not being there at all/js/... to import the file it will be imported by the closure compiler and passed through :advanced. meaning it needs to externs./ has a different meaning in shadow-cljs and means importing from the classpath root. https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_jsstatic create method is getting removed by closure. which I believe is documented somewhere. let me see if I can find itclass SomeClass {
/** @nocollapse */
static create(params) {
return ["SomeClass.create",1,2,params];
}
}The required JS dependency "jquery" is not available, it was required by "cljsjs/jquery.cljs". How can I figure out which dependency needs that so I can assess whether I want it or not?npm i jquery --savenode_modules directory, so you need to install the js modules directlylein deps :tree type command in the shadow repl but i don’t know what it iswhich)lein though. https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningennode_modules never use the full DCE and only run through :simple (in shadow-cljs):advanced working for node_modules is highly experimental and has never worked reliably for meecho "" >> main.js?:modules {:main {:entries [...] :append "\n"}} though.shadow-cljs compile npmnpm watch testJul 15, 2018 6:13:41 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :test available at shadow-cljs - server version: 2.4.5 shadow-cljs - server running at shadow-cljs - socket REPL running on port 57924 shadow-cljs - nREPL server running on port 57926 shadow-cljs - watching build :test [:test] Configuring build. [:test] Compiling ... [:test] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/home/viebel/.m2/repository/thheller/shadow-cljs/2.4.5/shadow-cljs-2.4.5.jar!/shadow/cljs/devtool s/client/hud.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.cljs.devtools.client.hud -------^------------------------------------------------------------------------ Invalid :refer, var cljs.core.async/go does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [shadow.dom :as dom] 4 | [shadow.xhr :as xhr] 5 | [shadow.animate :as anim] --------------------------------------------------------------------------------
npm compile test works fineshadow-cljs.edn{:lein true
:builds {:npm
{:target :npm-module
:output-dir "."}
:test
{:target :browser-test
:test-dir "resources/public/js/test"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}}}}
shadow-cljs server from cmd-line, it says:
shadow-cljs - Using IP "192.168.1.43" from Interface "en0"Can I get it to listen on 0.0.0.0 or localhost instead? Currently I have to restart the server every time my ip changes.
:http-handler(:require ["node-sass" :as sass])
(sass/render {:file 'path-to-file'})
errors with Invalid symbol: 'path-to-file'core.async version0.0.0.0 unless otherwise specified. the fixed IP is also gone for a couple of releases now.'path-to-file' thats a symbol in CLJS, must use "path-to-file". ie. double quotesclj->js or #js {:file ...} as node-sass expects a JS object not a CLJS map' is quote in CLJSdefaultBinaryDir = path.join(__dirname, '..', 'vendor'):browser build?node-sass in node builds just fine. just not in the browser.{...
scripts: {
sass: "node-sass ...",
dev: "shadow-cljs watch app;",
repl: "shadow-cljs cljs-repl app;"
}}
so for dev I run all 3 in different split screens<link rel="stylesheet" href="/absolute/path.css">import {foo} from 'goog:demo.foo';
it doesn’t work. I tried this example from documentation either:
import cljs, { keyword } from "goog:demo.foo";
cljs.array_map(keyword("foo"), "hello world");
In both cases javascript loader says:
Module not found: Can’t resolve ‘goog:demo.foo’ in ‘/Users/den/git/test/mhello-cljs/src’:foreign-libs. I'm curious if you tried shadow-cljs and if you chose not to use it why?run-server with whatever you have specified as :ring-handler in figwheel:browser target{:target :browser
:output-dir "resources/public/js/browser"
:devtools {:http-port 8025
:http-root "resources/public/js/browser"}
:modules {:main {:entries [audyx.app.init]}}}
index.html in resources/public/js/browser with the following content:
<script src="main.js"></script>
localhost:8025/index.htmlNot found
:asset-path "/" in your config, it defaults to "/js"resources/public as :http-root though? typically you should avoid putting anything other than generated output into :output-dir/js/browser yes shadow-cljs cljs-repl browser:ignore-warnings true but it didn't help:after-load hook properly set?:on-jsload I think:devtools {:after-load your.app/start} in the config:browser
{:target :browser
:output-dir "resources/public/js/browser"
:asset-path "/js/browser/"
:ignore-warnings true
:devtools {:http-port 8025
:http-root "resources/public/"
:before-load audyx.app.init/before-load
:after-load audyx.app.init/start}
:modules {:main {:entries [audyx.app.init]}}}
shadow-cljs: WebSocket connected! browser.cljs:27 shadow-cljs: REPL init successful browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/calibration.cljs at [77:3] Wrong number of args (1) passed to audyx.audio.ambiences.calibration/create-noise-node shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318 browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/transducer_calibration.cljs at [32:3] Wrong number of args (3) passed to cljs.core/replace shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318 browser.cljs:121 BUILD-WARNING in audyx/audio/input.cljs at [35:13] Use of undeclared Var audyx.audio.input/-Infinity shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318 browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/volume.cljs at [29:1] Bad method signature in protocol implementation, ILoop initial-index does not declare arity 3 shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318 browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/single.cljs at [10:1] ->Single already refers to: audyx.test.records.loop.single/->Single being replaced by: audyx.test.records.loop.single/->Single shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318 browser.cljs:121 BUILD-WARNING in audyx/graphs/vocalsnr_graph.cljs at [13:1] Bad method signature in protocol implementation, Graph graph-definition does not declare arity 3 shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258 shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148 (anonymous) @ browser.cljs:318
:devtools[cider/cider-nrepl "0.17.0"]
according to my cider version: 0.18.0-SNAPSHOT
Maybe you can add a comment about that here: https://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies_2M-x cider-create-sibling-cljs-repl is now: M-x cider-connect-sibling-cljspom.xml via shadow-cljs pomfile -> new -> from existing sources and then select the pom.xmlshadow-cljs pom again and let cursive update itproject.clj with lein of course. cursive has a bit better integration with that.pom.xml(shadow.cljs.devtools.api/repl :browser) to switch it to CLJSshadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch browser
Compiling ClojureScript...
Compiling ["public/clojurescript/dev/2ffae5ec-aa76-40ed-aadc-d3878fce327a.js"] from ["src/cljs/audyx" "resources"]...
module.js:549
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at [eval]:3:13
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:652:30)
at evalScript (bootstrap_node.js:463:27)
browser key (e.g https://github.com/aws/aws-sdk-js/blob/master/package.json)
According to https://docs.npmjs.com/files/package.json#browser :
If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. window)
shadow-cljs behave like this when browser key is present on a npm module imported?browser keyclojure.walk/postwalk function. In according to ClojureScript documentation https://www.clojurescript.org/about/differences clojure.walk namespace is included to ClojureScript. It works fine with lein and figwheel, but looks like there is no such namespace when I compile it in shadow-cljs. Any thoughts how to fix this?[clojure.walk :as walk] and then use it inside my code (even like clojure.walk/postwalk), it works. But if I use it without requiring in this particular namespace, and just use clojure.walk/postwalk it fails. In general case I would just require it, but it’s library code, not minebrowser key is fully supported and I tested including aws-sdk and it worked fine. what error do you get?clojure.walk before including the library. shadow-cljs is a bit stricter about requires due to the parallel compilationCompiling ClojureScript...
Compiling ["public/clojurescript/main.js"] from ["src/cljs/audyx"]...
events.js:183
throw er; // Unhandled 'error' event
^
Error: module not found: "fs" from file /mnt/c/Users/USER/prj/audyx-deps/node_modules/aws-sdk/lib/util.js
at onresolve (/mnt/c/Users/USER/prj/audyx-deps/node_modules/@cljs-oss/module-deps/index.js:181:30)
at onResolve (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:70:11)
at innerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:143:22)
at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)
at next (/mnt/c/Users/USER/prj/audyx-deps/node_modules/tapable/lib/Tapable.js:249:35)
at innerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:143:22)
at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)
at next (/mnt/c/Users/USER/prj/audyx-deps/node_modules/tapable/lib/Tapable.js:249:35)
at resolver.doResolve.createInnerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:41:24)
at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)
lein-cljsbuild again?@cljs-oss/module-deps shadow-cljs never ever uses that(ns differ.core (:require [datascript.core :as datascript] [expound.alpha :as expound] [orchestra-cljs.spec.test :as st] [cljs.spec.alpha :as s] [clojure.walk :as walk] ;; <- here [re-posh.core :as re-posh])) ;; <- this library using it
clojure.walk requireposh library though:npm-module and use it from javascript as in your example project. When it starts it throws an error:
Uncaught ReferenceError: SHADOW_ENV is not definedSHADOW_ENV=development shadow-cljs watch app{:source-paths
["cljs-src" "cljs-test"]
:nrepl {:port 8450}
:dependencies
[[org.clojure/clojurescript "1.10.339"]
[org.clojure/clojure "1.9.0"]
[reagent "0.8.1"]
[datascript "0.16.6"]
[orchestra "2017.11.12-1"]
[expound "0.7.1"]
[re-posh "0.3.0"]]
:builds
{:app {:target :npm-module
:output-dir "dist/cljs"
:runtime :browser
:entries [differ.core differ.chat.views]}
:test {:target :node-test
:output-to "dist/cljs/test"}}}
node_modules but just a folder inside my project:target :browser instead? do you need anything from CRA?:runtime :browser might be causing some confusion. I just tested with node which works fine.dist/cljs/cljs_env.js exists and has a var SHADOW_ENV ... line$ lein run -m shadow.cljs.devtools.cli help Unknown action.What might I be doing wrong?
browser.cljs:39 Uncaught ReferenceError: SHADOW_ENV is not defined
at Object.shadow$cljs$devtools$client$browser$goog_is_loaded_QMARK_ [as goog_is_loaded_QMARK_] (browser.cljs:39)
at shadow$cljs$devtools$client$browser$src_is_loaded_QMARK_ (browser.cljs:48)
at Function.G__24616__1 [as cljs$core$IFn$_invoke$arity$1] (core.cljs:4222)
at cljs.core.filter.cljs$core$IFn$_invoke$arity$2 (core.cljs:5124)
at cljs.core.LazySeq.sval (core.cljs:3394)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (core.cljs:3452)
at Object.cljs$core$seq [as seq] (core.cljs:1210)
at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2445)
at cljs.core.LazySeq.cljs$core$IReduce$_reduce$arity$3 (core.cljs:3458)
at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2517)
shadow-cljs help 😉help command is more or less useless regardless but currently its implremented only on the CLJS side so its just missing2.4.21(server/start!) doesn’t return, as in the example at https://shadow-cljs.github.io/docs/UsersGuide.html#embedded. It just hangs with no output.boot repl, but not under a clj (deps.edn) repl… Any ideas to get it started under clj?(server/start!)% clj
Clojure 1.9.0
user=> (require '[shadow.cljs.devtools.server :as server])
nil
user=> (server/start!)
Jul 17, 2018 7:03:33 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Jul 17, 2018 7:03:33 PM clojure.tools.logging$eval8756$fn__8759 invoke
WARNING: HTTP startup failed
java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found
at org.xnio.Xnio.doGetInstance(Xnio.java:270)
at org.xnio.Xnio.getInstance(Xnio.java:187)
at io.undertow.Undertow.start(Undertow.java:116)
at shadow.undertow$start.invokeStatic(undertow.clj:194)
at shadow.undertow$start.invoke(undertow.clj:158)
at shadow.cljs.devtools.server$start_http$fn__22410.invoke(server.clj:136)
at shadow.cljs.devtools.server$start_http.invokeStatic(server.clj:135)
at shadow.cljs.devtools.server$start_http.invoke(server.clj:131)
at shadow.cljs.devtools.server$start_system.invokeStatic(server.clj:180)
at shadow.cljs.devtools.server$start_system.invoke(server.clj:154)
at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:349)
at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:283)
at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:286)
at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:283)
at user$eval22617.invokeStatic(NO_SOURCE_FILE:3)
at user$eval22617.invoke(NO_SOURCE_FILE:3)
at clojure.lang.Compiler.eval(Compiler.java:7062)
at clojure.lang.Compiler.eval(Compiler.java:7025)
at clojure.core$eval.invokeStatic(core.clj:3206)
:scope "runtime" which the xnio stuff uses.vals issue you ran into earlier was actually a bug in shadow-cljs which should be fixed in 2.4.22clj (with a deps.edn only containing the dep on shadow 2.4.20), the :source-paths in shadow-cljs.edn seems to be totally ignored. Can I convince the embedded shadow to use the source paths in shadow-cljs.edn instead? I tried :deps false without success. (I can setup an alias in deps.edn, but I’d rather have the cljs stuff in the shadow config and the clj stuff in deps.edn)➜ shadow-cljs-app git:(master) ✗ shadow-cljs watch browser shadow-cljs - config: /Users/viebel/prj/shadow-cljs-app/shadow-cljs.edn cli version: 2.4.5 node: v10.6.0 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - starting ... [2018-07-18 17:02:28 - WARNING] TCP Port 9630 in use. [2018-07-18 17:02:34 - WARNING] failed to start :browser dev-http:8025 reason: java.net.BindException: Address already in use shadow-cljs - HTTP server for :browser available at shadow-cljs - server version: 2.4.5 shadow-cljs - server running at shadow-cljs - socket REPL running on port 49168 shadow-cljs - nREPL server running on port 49170 shadow-cljs - watching build :browser [:browser] Configuring build. [:browser] Compiling ... [:browser] Build failure: The required JS dependency "util" is not available, it was required by "node_modules/aws-sdk/lib/event_listeners.js". Searched in:/Users/viebel/prj/shadow-cljs-app/node_modules You probably need to run: npm install util See:
shadow-cljs itself as a npm dep. npm install --save-dev shadow-cljs that will install the missing util polyfill:advanced release builds. beyond that gzip + http2 can help reduce load times in devshadow-cljs completely relies on the JVM classpath so whatever you use to manage that is responsible for including the source paths. shadow-cljs can't add any paths after startup.env.cljs:174 error when calling lifecycle function conduit.core/main Error: Target container is not a DOM element.
at module.exports (invariant.js:43)
at legacyRenderSubtreeIntoContainer (react-dom.development.js:17239)
at Object.render (react-dom.development.js:17318)
at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:20)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs:44)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs:39)
at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs:74)
at conduit$core$main (core.cljs:75)
at shadow.cljs.devtools.client.env.make_task_fn (env.cljs:171)
at shadow$cljs$devtools$client$env$do_js_reload_STAR_ (env.cljs:180)
shadow.cljs.devtools.client.env.make_task_fn @ env.cljs:174
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:180
(anonymous) @ env.cljs:180
(anonymous) @ env.cljs:209
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:180
shadow.cljs.devtools.client.env.do_js_reload.cljs$core$IFn$_invoke$arity$4 @ env.cljs:216
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:66
(anonymous) @ browser.cljs:151
(anonymous) @ browser.cljs:100
goog.events.EventTarget.fireListeners @ goog.events.eventtarget.js:284
goog.events.EventTarget.dispatchEventInternal_ @ goog.events.eventtarget.js:381
goog.events.EventTarget.dispatchEvent @ goog.events.eventtarget.js:196
goog.net.XhrIo.onReadyStateChangeHelper_ @ goog.net.xhrio.js:867
goog.net.XhrIo.onReadyStateChangeEntryPoint_ @ goog.net.xhrio.js:813
goog.net.XhrIo.onReadyStateChange_ @ goog.net.xhrio.js:797
XMLHttpRequest.send (async)
goog.net.XhrIo.send @ goog.net.xhrio.js:627
goog.net.XhrIo.send @ goog.net.xhrio.js:352
shadow$cljs$devtools$client$browser$load_sources @ browser.cljs:92
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:151
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:267
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:327
goog.History for some routing purposes and reloading the file that initializes it. the conduit code has that issue. the hook-browser-navigation! should only be called once.:deps :aliases on a per build basis?clj -A:xyz -m shadow.cljs.devtools.cli compile foo instead of shadow-cljs compile foo:target for this cljs lib? Should it be :npm-module?deps.cljs at the root with {:npm-deps {"js-yaml" "the-version"}}package.json won't be used at all.jar filescljs-yaml lib I won't need to manually install js-yaml. Right?js-yaml will be installed automatically if deps.cljs specifies it➜ shadow-cljs-app git:(master) ✗ shadow-cljs compile browser shadow-cljs - config: /mnt/c/Users/USER/prj/shadow-cljs-app/shadow-cljs.edn cli version: 2.4.22 node: v8.10.0 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - starting ... [:browser] Compiling ... The required JS dependency "js-yaml" is not available, it was required by "cljs_yaml/core.cljs". Searched in:/mnt/c/Users/USER/prj/shadow-cljs-app/node_modules You probably need to run: npm install js-yaml See:
cljs-yaml.jar?deps.cljs?yarn does that by default. if you remove something from package.json it is uninstalledpackage.json + npm as its meant to be by npmshadow-cljs to "emulate" it will just sucknpm to resolve them anywaysnpm too but thats the way it works in the JS world. can't do anything to change that.package.json in your project. deps.cljs for libs(:require ["thing" :as t]) all accesses to t/foo are automatically added to externs^js typehints https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externsexports.foo = ... it will add foo to externs just in case you call it(fn [^js downshiftProps] ...)(.-nativeEvent.-preventDownshiftDefault event) thats not valid though(.. event -nativeEvent -preventDownshiftDefault):compiler-options {:infer-externs :auto} in your build config:all since that will complain about files you don't control:refer only in really old code - now all examples use vectors.Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
WARNING: provide conflict for #{cljs_time.format cljs-time.format} provided by cljs_test/generated_test_suite.out/cljs_time/format.js and {"/cljs_time/format.cljs" #{cljs-time.format}}
Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
WARNING: provide conflict for #{cljs_time.predicates cljs-time.predicates} provided by cljs_test/generated_test_suite.out/cljs_time/predicates.js and {"/cljs_time/predicates.cljs" #{cljs-time.predicates}}
Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
INFO: filename violation for ns cljs.nodejs, got: cljs_test/generated_test_suite.out/cljs/nodejs.cljs expected: cljs/nodejs.cljs (or .cljc)
I've no idea what that generated_test_suite is, and I'm not using cljs-test myself. I tried googling and seems to point at boot-cljs-test... which is really odd. Any idea what's going on?cljs_test.generated_test_suite.out.cljs.core.constants.js and cljs_test.generated_test_suite.out.cljs_time.internal.core.js2.4.7 to 2.4.22 and now it breaks on release with: ["scroll-into-view-if-needed" :default scroll-into-view-if-needed] it creates P4a["default"] but P4a contains:
ƒ (a,b){if(b===Object(b)&&0!==Object.keys(b).length&&
"function"===typeof b.behavior)return b.behavior((0,e.default)(a,b));b=!1===b?{block:"end",inline:"nearest"}:b===Object(b)&&0!==Object.keys(b).leng…
npm install --no-package-lock but that did not only not create a new package-lock.json but it would also ignore it... Now we updated node and changed the command to npm ci and life is great again ^^:refer. personal preference I guess. CLJ(S) don't care, both are equally validshadow-cljs clj-repl and then ( "cljs_test/generated_test_suite.out/cljs_time/format.js")index.js files that just re-export(:require ["@material-ui/icons/Add" ...]) instead of @material-ui/icons and then icons/Add-main with target :node-scriptwatch and then launch node my-script:node-script without a :main though? wouldn't the generic node-repl work then?26 | #?(:cljs (deficon postilaatikko "0 0 46 54")) ----------------^--------------------------------------------------------------- Use of undeclared Var reititin.icons/SvgIcon
~'SvgIcon otherwise the unquote willl qualify the symbolSvgIconjs/MaterialUI...?macroexpand will leave it alone. if its without symbol the unquote will try to qualify itmui?require("./thing.css") is easy enough as they are already filtered outpackage.json is equally easy to extractscss or @import "./another-file.scss"watch is a bit more complicated thoughnpmnpm or webpack have been far from smooth. quite the opposite actually.style field in package.json for exampleleaflet doing something like that(ns demo.hooks
(:require [shadow.build.data :as data]
[shadow.build.npm :as npm]))
(defn dummy
{:shadow.build/stage :flush}
[{:keys [npm] :as state} & args]
(let [used-npm-modules
(->> (data/get-build-sources state)
(map :package-name)
(remove nil?)
(into #{}))
styles
(->> used-npm-modules
(map #(npm/find-package npm %))
(map :package-json)
(filter #(get % "style"))
(into []))]
(prn [:styles styles])
(prn [::flush args used-npm-modules]))
state):build-hooks [(demo.hooks/dummy 1 2 3)]
npm packages that were used in the build and give you the package.json data to work withstyle and post-process it however you wantinject? inject where? and what?:build-modules instead of :build-sources. :build-modules is a vector of maps. each will have a :sources key which lists all the sources included in that module.css file. so for :modules {:main {:entries ...}} which creates a main.js I would create a main.css and include that statically via the HTML when including the main.js.html file is equally trivialnode-sass setup which has been good enough for me for years["aws-sdk" :refer [AWS]] or ["aws-sdk" :default AWS] are resulting in a null AWSgoog.nodeGlobalRequire=function(path){return false};goog.provide("goog.debug.Error");goog.debug.Error=function(opt_msg){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var stack=(new Error).stack;if(stack)this.stack=stack}if(opt_msg)this.message=String(opt_msg);this.reportErrorToServer=true};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.provide("goog.dom.NodeType");goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.provide("goog.string");goog.provide("goog.string.Unicode");goog.define("goog.string.DETECT_DOUBLE_ESCAPING",false);goog.define("goog.string.FORCE_NON_DOM_HTML_UNESCAPING",false);goog.string.Unicode={NBSP:" "};goog.string.startsWith=function(str,prefix){return str.lastIndexOf(prefix,0)==0};goog.string.ends
TypeError: Cannot set property 'Error' of undefined
at /home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:69:102
at Object.<anonymous> (/home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:3038:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
:node-script:whitespace not being compatible with node.shadow-cljs browser-repl and then calling (require '["aws-sdk" :as x]) (js/console.dir x)AWS property you want :refer. if it has a .default property you want :default. if it has no properties at all and is just a function you want :asreact-select. I’m using the code from here, which works fine with cljsjs. https://gist.github.com/pesterhazy/6c517653945f84a39c1ae3cc8b20c552. Shadow however, serves me up this error. Uncaught Error: Assert failed: Expected React component in: [:> nil {:value nil, :options #js [#js {:value "a", :label "alpha"} #js {:value "b", :label "beta"} #js {:value "c", :label "gamma"}], :onChange #object[Function]}] Any ideas?js/window.Select is not defined. Most likely, importing of cljsjs.react-select creates a global Select object but shadow-cljs does not. Instead of js/window.Select you want to use the stuff that you explicitly import.reagent.core/adapt-react-class. But maybe I'm wrong here.:> handles that.:require ["react-select" :refer [Select]] Now on-click of the select item gives Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development. See for more information.
?:require ["react-select" :refer [Select]]:require ["react-select" :default Select]:refer [Select] shouldn't have worked at all:refer [Select] is absolutely not valid and shouldn't even render anything(ns app.views
(:require
[app.state :refer [app-state]]
[app.events :refer [increment decrement]]
["react-select" :default Select]))
(defn header
[]
[:div
[:h1 "A template for reagent apps"]
[:> Select {:onChange (fn [e]
(js/console.log "onChange" e))
:options
[{:value 1 :label "1"}
{:value 2 :label "2"}]}]])(ns app.views
(:require [app.state :refer [app-state]]
[app.events :refer [increment decrement]]
[reagent.core :as r :refer [atom]]
["react-select" :default Select]
["prop-types" :refer [PropTypes]]))
(defonce value (r/atom nil))
(defn header
[]
[:div
[:h1 "A template for reagent apps"]])
(defn counter
[]
[:div
[:button.btn {:on-click #(decrement %)} "-"]
[:button {:disabled true} (get @app-state :count)]
[:button.btn {:on-click #(increment %)} "+"]])
(defn select-ui []
[:> js/window.Select {:value @value
:options #js [#js {:value "a" :label "alpha"}
#js {:value "b" :label "beta"}
#js {:value "c" :label "gamma"}]
:onChange #(reset! value (aget % "value"))}])
(defn root-ui []
[:div {:style {:width 400}}
[:h3 "Select test"]
[select-ui]])js/window.Select is not what you get from shadow-cljs. thats something else entirely. don't know where tthat is from[:> Select ...]js/ is for accessing global variables which is very common in cljsjs packages but never required in shadow-cljsns like any other CLJS namespace/referimport { AgGridReact } from 'ag-grid-react'; becomes (:require ["ag-grid-react" :refer (AgGridReact)])(:require ["@feathersjs/client" :as feathers]) this is returning nil, any idea why?feathers is nil?shadow-cljs browser-repl and (require '["@feathersjs/client" :as x]) (prn x) I get #object[createApplication]x in this case is a functionnpm install @feathersjs/clientIllegalStateException: ASSIGN 2 [length: 45] [source_file: feathers/app.cljs] is not the parent of GETPROP 2 [length: 21] [originalname: feathers] [source_file: feathers/app.cljs]cljsjs/antd added to my shadow-cljs.edn but I’m getting the error ’cljsjs.antd` is not available.src/cljsjs/antd.cljs with (ns cljsjs.antd (:require ["antd" :as antd])) (js/goog.exportSymbol "antd" antd)
feathers/app.cljs? maybe you are doing something you are not supposed to. never seen that error before though.(def feathers feathers) or something similar? ie. assigning a variable to its own name?var x = x; so it ends up undefinedroot.cljc:28 Uncaught TypeError: Cannot read property 'create_react_factory_STAR_' of undefined
at eval (root.cljc:28)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:2188)
at Object.env.evalLoad (shared.js:3042)
at issue-linking-panel.js:1
main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
at eval (main.cljs:28)
at eval (main.cljs:50)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:2188)
at Object.env.evalLoad (shared.js:3042)
at page-linking-panel.js:3
But I have to say those two cannot connect to the shadow-cljs websocket because that runs on localhost, could that be related?eval in main.cljs or root.cljc? can you share whats happening in the reported lines?(def spinner (utils/create-react-factory "spinner/default"))
which is a macro which does:
(defn create-react-factory* [clazz]
#?(:clj (constantly nil)
:cljs (createFactory clazz)))
(ssr/get-SSR-initial-state)which is from fulcro which reads transit from a script tag, so I can imagine it might be using eval
ssr namespace?browser.cljs:321 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
browser.cljs:321 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
at Object.shadow$cljs$devtools$client$browser$ws_connect [as ws_connect] (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:982:15)
at eval (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:1064:37)
at eval (<anonymous>)
at Object.goog.globalEval ()
at Object.env.evalLoad ()
at
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
at eval (main.cljs:28)
at eval (main.cljs:50)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:2188)
at Object.env.evalLoad (shared.js:3042)
at page-linking-panel.js:3
(anonymous) @ main.cljs:28
(anonymous) @ main.cljs:50
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ page-linking-panel.js:3
:devtools {:enabled false}2.4.24 which should handle this more gracefully:optimizations :none compilation mode but all in one unique file, concatenated. I have a requirement to leave things readable from a JS dev standpoint but I feel checking in :cache-root is not a clean approach.:simple build with :compiler-options {:variable-renaming :off :property-renaming :off :pretty-print true} that should be as close to readable as possible.jar files are basically zip files and yes those are supported but you said "node code" so I'm assuming .js files? what kind of code are you talking about? https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpathbuild/the-js-files/ as a src path. after some playing around I found a way to get everything up and running. the only wonky piece was the npm integration. if i have a parent dir /proj which contains /proj/the-node-code, compiling the node code and adding it to the proj/shadow-cljs.edn’s source files config works. however, it looks like the node_modules resolving can’t find the node code’s libraries unless I add them explicitly to /proj/node_modules. i’ve tried adding the proj/the-node-code/node_modules also to the source files, but the compiler still cant manage to resolve some import foo from 'some-lib' dependency in the node code.src/js/some-folder/converted-from-ts.js and put src/js on the :source-paths you can require it via (:require ["/some-folder/converted-from-ts" :as x])import foo from 'some-lib' as usual assuming that some-lib is in node_modules?"/foo/bar" or "./foo" or "../foo") are assumed to be on the classpathnode_modules is checked["/build/my-file/file" :as x]. the file can be found, because it doesn’t complain about resolving /build/my-file/file, but it does throw an error such as cannot import module 'momentjs' from /build/my-file/file./src/build/my-file/file:source-paths:source-paths ["src/cljs" "src/js"] I'd suggestsrc/js/some-unique-enough-name/my-file/file.js(:require ["/some-unique-enough-name/my-file/file.js" :as x])cannot import module 'momentjs' from /build/my-file/file who produces this error? its not a shadow-cljs error? is this a node build?moment? not momentjs?shadow-cljs -A (for instance, only load a preload or set a compiler option if a specific alias is passed)? If not, can you extend an existing build configuration?re_frame.trace.trace_enabled_QMARK_ closure-define flag if an alias is passed to the dev buildclj-run and build a function that uses shadow.cljs.devtools.api to do (shadow/get-build-config :foo) update that config map and then call (shadow/compile* modified-config {}):node-test returns 0 even when tests are failing:autorun. instead use compile and run node the-output.js. that will preserve the proper exit codeshadow-cljs compile the-test && node out/the-test.js:autorun from the command line (it would be super handy)shadow-cljs node-test --ns-regexp foo--autorun or --compile-only depending on which makes more sense:autorun false in shadow-cljs.edn but be able to run tests in watch mode:release {:autorun false} and then use shadow-cljs release the-tests. that way they wouldn't autorunyarn shadow-cljs release :test && node .cljs-tests/cd-tests.js but I still have a zero exit codeyarn&& is after thatnode?0:target :node-test?Ran 3 tests containing 7 assertions. 2 failures, 1 errors.
{:target :node-test
:main cd.test-runner/-main
:autorun true
:release {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:source-map true
:autorun false}
:output-to ".cljs-tests/cd-tests.js"}
:autorun true:compiler-options for anything but :autorun{:target :node-test
:main cd.test-runner/-main
;; :autorun true
:release {:compiler-options {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:source-map true}
:autorun false}
:output-to ".cljs-tests/cd-tests.js"}
:main?:ns-regexp "that.ns":main makes it work:main is allowed in case you want to use other test frameworks and such:cache-root is a global config option and cannot be set per build#shadow/env "THE_THING"shadow-cljs clj-repl uses the socket REPL. then (shadow/browser-repl) switches it to a CLJS browser repl. or (shadow/node-repl) or (shadow/repl :your-build)(require '[shadow.cljs.devtools.api :as shadow]) then (shadow/repl :build-id) works and I get the cljs repl.api namespaceclj-repl starts out in shadow.user(ns shadow.user
(:require
[clojure.repl :refer (source apropos dir pst doc find-doc)]
[clojure.java.javadoc :refer (javadoc)]
[clojure.pprint :refer (pp pprint)]
[shadow.cljs.devtools.api :as shadow :refer (help)]))(in-ns 'shadow.user) and (shadow/repl :build-id) does the trick with unraveldetestshadow-cljs pom and then in cursive file -> new -> project from existing sources and select the pom.xmlproject from existing sources not module from existing sources?pom.xml so I can look at it? just tested it on a dummy project and it worked fine.shadow-cljs pom and then in cursive file -> new -> project from existing sources and select the pom.xml
I was selecting pom.xml file.
As I see right way is to choose directory contain pom.xml file, not select file directly.pom.xml every time never the directorypom.xml for cursive or another one? 🙂deftest isn't indented correctly?pom.xml. It doesn’t work for me as I mentioned before.pom.xml. The same issue.new -> project -> project from existing sources then select the actual generated pom.xml file. accept a couple times and nothing elsetest/boilerplate/example_test.cljsmaven integration was just missing?maven integration, restart Intellij and it worksdeps.edn to manage dependencies, Cursive is supporting those already in the latest versionspom.xml is the most stable and well supported option and we really only need to tell cursive about the deps and source pathsUncaught TypeError: P.l is not a function
at main.js:1246:dashboard
{:target :browser
;; :module-loader true
:modules
{:main {:entries [cambia.web.experience.dashboard.client.core]}
:icon-row {:entries [cambia.web.experience.dashboard.components.icon-row.client]
:depends-on #{:main}}
}
:compiler-options {:infer-externs :auto}
:output-dir "public/dashboard/assets/app/js"
:asset-path "assets/app/js/"
:devtools
{:after-load cambia.web.experience.dashboard.client.core/start-dev}}:icon-row module gets rid of the error:compiler-options {:infer-externs :auto}[:dashboard] Compiling ... ------ WARNING #1 -------------------------------------------------------------- File: cambia/web/experience/dashboard/components/hsa/client.cljs:3:10 variable $ is undeclared -------------------------------------------------------------------------------- nil
shadow-cljs release dashboard --pseudo-names and do whatever to trigger the error--pseudo-names thats most likely the issue:compiler-options {:output-wrapper true} or find out how the global P is defined and what it is:output-wrapper isn't great when using modules so you should rather find out where that clashing global is coming fromP in the browser console and see if the object provides any clues:output-wrapper did fix it. what are the concerns with modules?> P
ƒ Promise() { [native code] }
🤔 not very illuminatingshadow-cljs release dashboard --source-mapsP variable and points you to the location where it created itnpm deps forcefully create some globals and can cause these issuesleaflet always creates window.L:output-wrapper guards you against such things but makes the build larger by 5% or soP so the simple fix is to create externs/dashboard.txt with one line global:P and done:output-wrapper is generally safer. you can always optimize that away later.REPL with shadow-cljs with cursive? https://github.com/thheller/shadow-cljs/wiki/Cursive#connecting-to-a-shadow-repl ?:nrepl {:port <number>}watch and nrepl-select described in the guide:node-test and I see that you are disabling :devtools explicitly?:node-script target with a REPL but I don't know if the tests are compiled thereshadow-cljs watch app
(shadow/watch :app) => :already-watching (shadow/nrepl-select :app) To quit, type: :cljs/quit => [:selected :app] (js/alert "foo") No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.I have opened website in Chrome. What I miss?
shadow-cljs: WebSocket connected!shadow-cljs browser-repl and then (shadow/repl :browser-repl) in the REPL to select itshadow.cljs.devtools.api/find-resources-using-ns wow you are always surprising merebel-readline in the various REPLs that shadow-cljs provides?readline support doesn't do anything for me and thats why I haven't worked on anything related yet.cljs.repl APIs which wouldn't work with shadow-cljs while shadow-cljs is runningprintln output in the repl in addition to having it in the devtools console - helps me use devtools less and stay nearer my editor(ns boilerplate.example-test
(:require [cljs.test :refer [deftest is testing use-fixtures]]
["web3"]))
(println (pr-str (js/Web3.)))
How to do:
var Web3 = require('web3');
var web3 = new Web3();
I was trying a few ways, but always ReferenceError: Web3 is not definedjs/web3, lower-case.require - I didn't notice. Wait a sec.npm i web3 did this:
"web3": "^1.0.0-beta.35"
I didn’t notice it(:require ["web3" :as web3]) in your ns definition.(ns boilerplate.example-test
(:require [cljs.test :refer [deftest is testing use-fixtures]]
["web3" :as web3]))
(println (pr-str (js/web3.)))
js/.web3.web3. with .?#object[Web3 [object Object]]console.log(web3); // {eth: .., shh: ...} // it's here!
Can I print it without webrowser?#object[Web3 [object Object]][object Object], and you're using CLI, not a browser console?shadow-cljs watch node-test <- at that moment i am running tests, so it is not in web browserconsole.log(web3) to print it(println …) in cljs print #object(js/console.log web3). If that doesn't change anything, there should be other members of js/console, like dir. But I have no idea whether they're supported during the test run.cljs.core/find-ns-obj, but it's in the section titled "Bootstrap helpers - incompatible with advanced compilation". I have no idea how exactly they're incompatible though - they appear to use munge, so at least symbol names should be correct.munge has nothing to do with the advanced compilation...adapt-react-class is right function then? It sounds like you want use it with other purpose, than it was created.adapt-react-class. And it also accepts only a pure React class, so I have to use reactify-component.(:require ["web3" :as web3]) and then use web3 without js/.(set! reagent.core/adapt-react-class (fn [c] ...)) work?
Wait, what do you mean? Either I don't understand something, or your statement contradicts with what you already said.set! won't update the compiler/analyzer data so it may emit code that isn't compatible(ns boilerplate.example-test
(:require [cljs.test :refer [deftest is testing use-fixtures]]
["web3" :as Web3]))
(def web3 (Web3.))(html/h1 "hello world") looks just as nice as [:h1 "hello world] but doesn't require vectors->reactelement translation(div "foo")clojure.walk algorithm with some clever binding. with pure React it would involve calling the render function or calling a special getData method (which dan_abramov admonished the community for)The required JS dependency "node-releases/data/processed/envs.json" is not available, it was required by "node_modules/browserslist/index.js" . my dependency postcss has a dep on browserslist, which has a dep on node-releases (which exposes the envs.json file). a double transient dependency resolution 😞node_modules/node-releases/... directory?[1:1]~cljs.user=> (require '["browserslist" :as x]) nil [1:1]~cljs.user=> x #object[browserslist]
browserslist version doesn't load the envs.json:npm-deps compare to shadow-cljs?<script src=...> ), without risk to conflict with another bundle?cljs.core version which would not be compatible with each othershadow-cljs only compiles npm dependencies with :simple optimizations. :npm-deps tries to do :advanced. If that works its better but it rarely works so shadow-cljs sacrifices that for more compatibility.:npm-deps but it should work, at least for simpler cases. Why does it rarely work?script src='...' with one function. But I dont know anything about the other scripts that this site will use.npm. they don't follow the closure JS standards at all and sometimes to some dynamic stuff which the closure compiler doesn't understand. also the commonjs support is a bit lacking in places and some idioms the JS folks use are not supported at all.:modules no, that must be unique.:modules:dashboard
{:target :browser
:modules {:main {...}
:onboarding {...}}}
:other-page
{:target :browser
:modules {:main {...}
:onboarding {...}}}:output-wrapper solves that. CLJS also supports that though.:output-dir values:app {:target :browser :modules {:common {...} :dashboard {:depends-on #{:common} ...} :other-page {....}} instead:modules just right is tough. always consider how the user moves though.:admin stuff and then one per page and so on:admin and some of the stuff in there made the base modules larger:admin build and keeping that out of normal user stuff:dashboard and :other-page are both used by the user (in the same session)(defn ^:export your-fn [...]) to have your function accessible from HTML via <script>your.ns.your_fn();</script>(defn your-fn [...]) (js/goog.exportSymbol "yourFn" your-fn) to have it accessible as <script>yourFn();</script>your variable in the example aboveimport "perfect-scrollbar/css/perfect-scrollbar.css"; import withStyles from "@material-ui/core/styles/withStyles"; import Header from "components/Header/Header.jsx"; import Footer from "components/Footer/Footer.jsx"; import Sidebar from "components/Sidebar/Sidebar.jsx"; import dashboardRoutes from "routes/dashboard.jsx"; import appStyle from "assets/jss/material-dashboard-pro-react/layouts/dashboardStyle.jsx"; import image from "assets/img/sidebar-2.jpg"; import logo from "assets/img/logo-white.svg";So I get that after running babel I should be able to do something like
(require ["components/Header/Header" :default Header]) but does this also work for the css, images and what have you? like (require [ "perfect-scrollbar/css/perfect-scrollbar.css"])index.html, I just have a <link rel="stylesheet" href="/css/site.css"> in my <head> tag@importing library css into my main scss, but now it is deprecated. https://github.com/sass/libsass/issues/2611 The only clear solution is ‘use webpack’ (?) loljss isimport {
drawerWidth,
drawerMiniWidth,
transition,
containerFluid
} from "assets/jss/material-dashboard-pro-react.jsx";
const appStyle = theme => ({
wrapper: {
position: "relative",
top: "0",
height: "100vh",
"&:after": {
display: "table",
clear: "both",
content: '" "'
}
},
mainPanel: {
transitionProperty: "top, bottom, width",
transitionDuration: ".2s, .2s, .35s",
transitionTimingFunction: "linear, linear, ease",
[theme.breakpoints.up("md")]: {
width: `calc(100% - ${drawerWidth}px)`
},
overflow: "auto",
position: "relative",
float: "right",
...transition,
maxHeight: "100%",
width: "100%",
overflowScrolling: "touch"
},
content: {
marginTop: "70px",
padding: "30px 15px",
minHeight: "calc(100vh - 123px)"
},
container: { ...containerFluid },
map: {
marginTop: "70px"
},
mainPanelSidebarMini: {
[theme.breakpoints.up("md")]: {
width: `calc(100% - ${drawerMiniWidth}px)`
}
},
mainPanelWithPerfectScrollbar: {
overflow: "hidden !important"
}
});
import "thing.css" is webpack. the jsx needs a babel transform"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build": "npm run build-css && react-scripts build",
react-scripts command does bunch of that stuff, delegates out to webpack etcreact-scripts is the meat of create-react-appnpm run-script build:target :npm-module and continue using the existing build system to create the final bundle.sol files in project, which are files in different language to compile. I would like to do shadow-cljs watch tests and re-run tests if this file will change. At that moment shadow-cljs doesn’t detect this change.
1) How to re-run tests when .sol files change?
2) How to compile .sol files if they change. I have to run code (probably the best lein command) each time when files in /src/contracts change.
It could be done in 2 separated steps.
1) shadow-cljs watch app to watch changes including change of compiled files .abi in some directory,
2) watcher to track /src/contracts to compile them when source changed..sol files used in the project?.sol are compiled to .abi and .bin files. These files are used by module in javascript later.make contract or something?lein solc once && touch test/your_ns/*-test.cljstouch will cause the compiler to trigger a recompile, which will then trigger re-running the tests.lein solc auto.abi files actually consumed via some macro or such or are they just loaded via the node fs package?project.clj here, so I am not sure about lein solc. I am trying to move solution into shadow-cljs from standard lein cljs compilerlein solc just seems to shell out to solc so you don't seem to gain much from it.sol files?shadow-cljs compile tests once (no watch). update the .sol files and compile thosenode out/the-tests.js without recompiling the CLJS.sol fileschokidar. disable :autorun in the shadow-cljs build config. then let chokidar watch the :output-to file and in addition to that the .sol files..sol files anywaysshadow-cljs watch ...?watch.jsshadow-cljs to watch the directory and make it do all of it BUT that is not documented at all and a little more complex than just using chokidarnode process that you can kill at any timechokdiar. It will detect changes in files and run commands for me. But how to tell shadow-cljs watch tests to re-run? by touch?:target :node-test?:node-test I would recommend simply dropping :autorun true from your build config and letting your chokidar thing run the tests whenever either the .sol files change or the :output-to changesshadow-cljs watch tests just watches and compiles the .cljs files but does not run the testsnode out/the-tests.js to run themshadow-cljs watch tests, use only chokidarshadow-cljs watch tests just watches and compiles the .cljs files but does not run the testschokidar thing running independentlylein?1.10.339 and no manual closure-compiler-unshaded depdencencylein deps :tree it'll probably show a conflict somewherecore.async is another one to watch out forshadow/repl :app my repl process expects input and hangs until i give inputlein repl and then using the api to setup my builds and CLJS replshadow/nrepl-select :build i get Can't change/establish root binding of: *nrepl-cljs* with set:js-options
{:resolve {"d3" {:target :npm
:require "d3/build/d3.js"}}}
And the code I posted was perhaps a bad example it’s from a sample page, I’m mainly after the components, thought they certainly also have the style imports.. Here’s an example from their custom button
import React from "react"; // nodejs library that concatenates classes import classNames from "classnames"; // nodejs library to set properties for components import PropTypes from "prop-types"; // material-ui components import withStyles from "@material-ui/core/styles/withStyles"; import Button from "@material-ui/core/Button"; import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";So to your point, I’d build this to say
my-mui-lib.js Then do something like the following? But isn’t the :require going to look in node_modules?
:js-options
{:resolve {"my-mui-lib" {:target :npm
:require "my-mui-lib.js"}}}
:resolve is not the option you are looking for :target :npm-module you mentioned in the guidenpm?function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import React from "react";
// nodejs library that concatenates classes
import classNames from "classnames";
// nodejs library to set properties for components
import PropTypes from "prop-types";
// material-ui components
import withStyles from "@material-ui/core/styles/withStyles";
import Button from "@material-ui/core/Button";
import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";
npm install takes several minutes to complete ...Done in 166.89s.// creates a beautiful scrollbar import PerfectScrollbar from "perfect-scrollbar"; import "perfect-scrollbar/css/perfect-scrollbar.css"; // @material-ui/core components import withStyles from "@material-ui/core/styles/withStyles"; // core components import Header from "components/Header/Header.jsx"; import Footer from "components/Footer/Footer.jsx"; import Sidebar from "components/Sidebar/Sidebar.jsx"; import dashboardRoutes from "routes/dashboard.jsx"; import appStyle from "assets/jss/material-dashboard-pro-react/layouts/dashboardStyle.jsx"; import image from "assets/img/sidebar-2.jpg"; import logo from "assets/img/logo-white.svg";
import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";/ or ./ in front will resolve to node_modules(require ["components/CustomButton/Button" :default Button]) if this was working normallynpm is such a shit show sometimesvar _cardStyle = require("../../assets/jss/material-dashboard-react/components/cardStyle"); for menpx babel src -d ../src/gen/material-dashboard-react<project>/some-dir running the babel in some-dir(:require ["/material-dashboard-react/components/whatever/andSoOn" :as x])npm dependenciesimport image from "assets/img/sidebar-2.jpg";:npm-module I guessshadow-cljs relaease your-build --source-maps or :compiler-options {:source-map true}source-map packagenode -r source-map your-script.js might do itnode -r source-map-support/register compiled.js:node-script TypeError: (intermediate value)(intermediate value)(intermediate value).Dg is not a function
at a8 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1694:329)
at lh (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1710:27)
at jh (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:249:291)
at Function.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1712:156)
at Function.y.b (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:212:112)
at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:1711:103
at Object.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1713:3)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3:advanced the default and the above error is most likely externs:infer-externs :auto set?shadow-cljs release your-build --pseudo-names to figure out what .Dg is:compiler-options {:optimizations :simple}TypeError: (intermediate value)(intermediate value)(intermediate value).$createServer$ is not a function
at $macchiato$server$start$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:33718:362):simple gives me: Users/r627543/Code/fido/packages/web/app/target/out/server.js:22985
return $keyword_fn$$.cljs$core$IFn$_invoke$arity$1 ? $keyword_fn$$.cljs$core$IFn$_invoke$arity$1($x$$) : $keyword_fn$$.call(null, $x$$);
^
TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
at $cljs$core$thisfn$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22985:30)
at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22957:19)
at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:22974:35
at $cljs$core$thisfn$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:23003:465)
at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:23032:10)
at cljs.core.clj__GT_js (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22969:31)
at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:14078:104
at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:14079:8
at cljs.core.LazySeq.sval (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:10219:122)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:10295:8):whitespace /Users/r627543/Code/fido/packages/web/app/target/out/server.js:1016
goog.debug.Error = function(opt_msg) {
^
TypeError: Cannot set property 'Error' of undefined
at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:1016:18
at Object.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:118841:3)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3):simple is working:whitespace is not compatible with node. the :simple error was actually an :advanced build with pseudo names active:npm-module would be to compile to <project>/material-dashboard-react/src/cljs and then in the src/index.js to require("./cljs/your.main").start()(ns your.main) (defn start [] ...)(:require ["components/...."]) but the downside with this is that you can't require using relative pathswatch it starts complaining about cljs/tools/readercompile works fine[reagent.core :as r]
["material-dashboard-react/components/CustomButtons/Button" :default Button]
["material-dashboard-react/assets/jss/material-dashboard-react/components/buttonStyle" ]))
(def mui-button (r/adapt-react-class Button))
(defn render [ctx]
[:<>
[:div [mui-button {:color "info"} "Hi There"]]
[:div
[:button {:on-click #(<cmd ctx :update :dec)} "Decrement"]
select to flip over to cljs{"color" "info"} and clj-jsing it as well:> Button {:color "info"} "Hello".babelrc shipping with the material-dashboard stuff worked after all. the transform-import-paths wasn't required.lilactown.core> (shadow/watch :client) [:client] Configuring build. [:client] Compiling ... :watching lilactown.core> [:client] Build completed. (132 files, 2 compiled, 2 warnings, 1.72s) ------ WARNING #1 -------------------------------------------------------------- File: cljs/tools/reader/edn.cljs:121:36 -------------------------------------------------------------------------------- 118 | (recur (inc i) (+ d (* uc base))))))) 119 | (js/String.fromCharCode uc)))))) 120 | 121 | (def ^:private ^:const upper-limit (int \uD7ff)) ------------------------------------------^------------------------------------- cljs.core/bit-or, all arguments must be numbers, got [string number] instead -------------------------------------------------------------------------------- 122 | (def ^:private ^:const lower-limit (int \uE000)) 123 | 124 | (defn- read-char* 125 | [rdr backslash opts] -------------------------------------------------------------------------------- ------ WARNING #2 -------------------------------------------------------------- File: cljs/tools/reader/edn.cljs:122:36 -------------------------------------------------------------------------------- 119 | (js/String.fromCharCode uc)))))) 120 | 121 | (def ^:private ^:const upper-limit (int \uD7ff)) 122 | (def ^:private ^:const lower-limit (int \uE000)) ------------------------------------------^------------------------------------- cljs.core/bit-or, all arguments must be numbers, got [string number] instead -------------------------------------------------------------------------------- 123 | 124 | (defn- read-char* 125 | [rdr backslash opts] 126 | (let [ch (read-char rdr)] --------------------------------------------------------------------------------
[:client] Compiling ... [:client] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/will/.m2/repository/org/clojure/tools.reader/1.0.0-alpha4/tools.reader-1.0.0-alpha4.jar!/cljs/tools/reader/edn.cljs:121:1 -------------------------------------------------------------------------------- 118 | (recur (inc i) (+ d (* uc base))))))) 119 | (js/String.fromCharCode uc)))))) 120 | 121 | (def ^:private ^:const upper-limit (int \uD7ff)) -------^------------------------------------------------------------------------ Can't redefine a constant at line 121 cljs/tools/reader/edn.cljs -------------------------------------------------------------------------------- 122 | (def ^:private ^:const lower-limit (int \uE000)) 123 | 124 | (defn- read-char* 125 | [rdr backslash opts] --------------------------------------------------------------------------------
1.0.0-alpha4 that is defniitely the wrong version1.3.1 I think...
var _withStyles = require("@material-ui/core/styles/withStyles");
var _withStyles2 = _interopRequireDefault(_withStyles);
var _Button = require("@material-ui/core/Button");
var _Button2 = _interopRequireDefault(_Button);
var _buttonStyle = require("../../assets/jss/material-dashboard-react/components/buttonStyle");
...
1.3.0npm install and then npx babel src -d out.babelrc of the pro versionlein deps :tree I’m seeing this:
Possibly confusing dependencies found: [org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]] overrides [thheller/shadow-cljs "2.4.24"] -> [org.clojure/tools.nrepl "0.2.13"] Consider using these exclusions: [thheller/shadow-cljs "2.4.24" :exclusions [org.clojure/tools.nrepl]]
lein itself depends on nrepl.babelrc?alpha4 must come from somewhereproject.clj maybe something in there is responsible. or a plugin..babelrc and the package.json really.clojurescript and tools.reader to your deps in case you don't have thateval on server startup?{:shadow/requires-server true}Figwheel: loaded these files
15:27:21.506 utils.cljs?rel=1532803397043:71 ("../keech_proj/ui/main.js" "../keech_proj/ui.js" "../keech_proj/core.js")
and the following in shadow.
shadow-cljs: load JS keech_proj/ui/main.cljs 15:59:49.184 browser.cljs:25 shadow-cljs: load JS keech_proj/ui.cljs 15:59:49.185 browser.cljs:25 shadow-cljs: call keech-proj.core/reload
ui refs ui\main and as you can see the reload func itself is in corelein command to run the figwheel version?(defn reload []
(let [current @running-app]
(println "RESTART" (true? current))
(if current
(app-state/stop! current start-app!)
(start-app!))))start-app! is probably called once stop finishesshadow-cljs.edn config from?hud preloadcoredef app-definition in .core. that holds a reference to ui which is a map of the componentscore is never updated the re-render doesn't change(defn app-definition []
(-> {:components ui
:controllers controllers
:subscriptions subscriptions
:html-element (.getElementById js/document "app")}
(dataloader/install datasources edb-schema)
(forms/install keech-proj-forms/forms keech-proj-forms/forms-automount-fns)))
(defonce running-app (clojure.core/atom nil))
(defn start-app! []
(prn "START-APP!")
(reset! running-app (app-state/start! (app-definition))))^:dev/always you can put on the ns:after-load app.main/reload! on the home page of shadow-cljs added it to my .edn file, but when i change css property of an element in component the browser does not reflect the change, i had to refresh to get the new styling. Is there something else i am missing here.start! or reload! function usually just re-renders my application(defn reload! []
(r/render
[some-component]
(.getElementById js/document "app")))
(defn ^:export main
[]
(r/render
[some-component]
(.getElementById js/document "app")))
Can i make it better or is this good enough.main again in my reload! function so that I don’t have to change it twice 😄(shadow.cljs.devtools.api/nrepl-select :app). Then tried to get into a namespace, but the prompt remains as cljs.user=> it does not change to the new namespace.
If i try to access anything from that namespace it returns as nil. Any idea why this is happening. The UI works fine, the only issue is i cannot access anything in repl.(ns lib.data (:require [reagent.core :as r]))pasting this in repl
shadow-cljs watch in a docker container and the live reload is quite slow (around 10-15 seconds). I have my docker resources at CPUs: 7 and memory: 8.0 GiB. On my mac live reload is usually less than a second. It seems to detect the file changes pretty quickly and then takes forever to compile. Would this be down to docker not being as fast as my mac or something else maybe?fs-watch not being slow. you can try setting :fs-watch {:watcher :polling} in your shadow-cljs.edn. at the root not in the build config. should be faster at the cost of more resources used.shadow-cljs watch build --verbose to get more timing infos about where it might be slow--verbose to see where its slow(require 'lib.data) in the REPL first. otherwise (ns lib.data ...) will just set up an empty namespace which won't have any of your functions. to switch to a loaded namespace you should also use (in-ns 'lib.data) instead.2.4.20+1.10.339 as well.lein clean just in case?.shadow-cljs/builds/caleb/dev/ana/medial_web/core.cljs.cache.transit.json is just in case[:caleb] Build completed. (381 files, 2 compiled, 0 warnings, 0.35s) with no mapped volumepreloads/`compiler-options`, my app doesn't always seem to run. It runs fine in non-release mode.
{:lein true
:jvm-opts ["--add-modules" "java.xml.bind"]
:nrepl {:port 3333}
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [ui-app.core]}}
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}}
:devtools {:http-root "resources/public"
:http-port 3449
:preloads [shadow.cljs.devtools.client.hud
devtools.preload
day8.re-frame-10x.preload]}}}}
The problem most probably is the re-frame-10x-dashboard/hud. Since I'm not using devtools and dev-mode is off in release mode, there seem to be issues with that dashboard, giving a null where there shouldn't be one.
My question actually is: can you make compiler-options specific to the environment. Now, it defines some closure-defines. I'm not sure if that's the problem, switching them off when not in dev-mode, may solve the problem (I think).in-ns usage supposed to be a bit slow?Timeout while waiting for REPL result.client sent unknown msg {:type :repl/set-ns-complete, :id 9, :ns ...}shadow-cljs cljs-repl ...shadow.cljs.devtools.api nsshadow-cljs compile build is identical to calling (shadow.cljs.devtools.api/compile :build)$ shadow-cljs cljs-repl browser shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.4.22 node: v9.4.0 shadow-cljs - connected to server [1:1]~demo.browser=> (in-ns 'cljs.core) nil [1:1]~cljs.core=>
2.4.24 is current*nrepl-active* is false by default, so I don’t need to worry about itshadow-cljs command if you prefer to just use tools.deps + cljclj -m shadow.cljs.devtools.cli compile build is identical to shadow-cljs compile buildapi answers a lot of questionsin-ns issue is gone after bumping - thanks!:lien true setup with Shadow in Cursive/Idea?shadow-cljs command eliminates some of the most common problems which you have to do manually with leinproject.cljshadow-cljs pom and create a new project from the generated pom.xmlpom.xml takes care of thatshadow-cljs pom whenever you change dependenciesCannot import anything from C:/Users/Surface/Projects/clojure/cljs/census-geojson/pom.xml when trying thatmaven support plugin active. for some reason that is disabled for some people.[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'refactor-nrepl.middleware/wrap-refactor, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-apropos, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-classpath, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-complete, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-debug, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-enlighten, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-format, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-info, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-inspect, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-macroexpand, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-ns, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-out, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-content-type, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint-fn, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-profile, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-refresh, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-resource, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-spec, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-stacktrace, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-test, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-trace, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-tracker, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-undef, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-version, see nrepl.middleware/set-descriptor!
[cider/cider-nrepl "0.18.0-SNAPSHOT"]
[refactor-nrepl "2.4.0-SNAPSHOT"]
in my shadow-cljs.edn, together with :nrepl { :middleware [refactor-nrepl.middleware/wrap-refactor]}refactor-nrepl doesn't have any effect on the warnings(middleware/set-descriptor!
#'cider.piggieback/wrap-cljs-repl
{:requires #{}
:expects #{}
:handles {}})
2.4.24 for now. the .25 version only changed the nrepl support.2.4.26 if you get a chance. it now hopefully detects things correctly.2.4.26 works for me!shadow-cljs -d cider/cider-nrepl:version ...$HOME/.clojure/deps.edn:cider alias-d which is also passed along to deps if you use :depsshadow.user on startup and I could connect to CLJS REPLs 😄requireing the shadow server et. al., starting it and running a buildcannot call stringp of nil, where nil was the cider cljs connection;; deps.edn
:aliases
{:dev {:extra-deps {thheller/shadow-cljs {:mvn/version "2.4.24"}
binaryage/devtools {:mvn/version "0.9.10"}}
:extra-paths ["dev"]}}
clj -A:dev -m shadow.cljs.devtoools.cli release clientclj -A:dev -m shadow.cljs.devtoools.cli release client 2018-08-01 12:57:06.920:INFO::main: Logging initialized @11265ms Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtoools/cli__ init.class or shadow/cljs/devtoools/cli.clj on classpath.
clj -A:dev and then (require '[shadow.cljs.devtools.cli]), it requires it just fineodevtools package for the .api, .cli and .server namespaceshadow.cljs.cli would look so much better 😉:main-opts ["-m" "shadow.cljs.devtools.cli"] to the dev profileclj -A:dev release client:release alias now. just needed to sanity check my understanding of clj:deps true in my shadow-cljs.edn, and give it an alias, will it also load all of the top-level :deps in deps.edn?shadow-cljs.edn?(css/edn {:font-size "14px" :&:hover {:color "blue"}})release building of a node library target. Getting TypeError: a.Ga is not a function
extensionHostProcess.js:452
at Object.ih [as greetings_activationGreetings] (/Users/pez/.vscode/extensions/cospaia.clojure4vscode-1.3.33-TS-CLJS/out/lib/calva.js:276:520)
at activate (/Users/pez/.vscode/extensions/cospaia.clojure4vscode-1.3.33-TS-CLJS/calva/extension.ts:114:14)
I don’t get this if I build with compile. What is the most obvious thing I could have missed? I have release building working in another vscode extension project (Calva Formatter) and am trying to use the same build pipeline in Calva…:compiler-options {:optimizations :simple} although I do recommend trying :compiler-options {:infer-externs :auto} first:infer-externs does the trick. I should get less of these problems once I have factored the code better between what I do in TypeScript code and what I do in ClojureScript code.:npm-module so the TS part can import namespace separately when required:node-script at the same time, since I just want to play around with ClojureScript and Cursive's REPL integration. I've written a minimal shadow-cljs.edn, ran npx shadow-cljs pom, left a running npx shadow-cljs server in a terminal, imported pom.xml into Cursive, connected to the REPL, I am able to do (shadow/watch :the-id) and and then (shadow/nrepl-select :the-id) - Cursive recognizes it at that point as a CLJS REPL. But if I try to evaluate anything - I get "No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript":node-script isn't the best option for that kind of experimentation, do I really need to switch to :browser and keep a browser running even though I just want to play around with the language itself?(shadow/node-repl) insteadnode the-script.jsnode-repl doesn't watch yes. :node-script does.[:did-not-find myns.core](shadow/node-repl) - at that time cursive shows that it is in CLJS repl. but then setting the REPL namespace fails(in-ns 'ns.that.wasnt.loaded-yet)in-nsLoading src/myns/core.cljs... repl/require failed { Error: ENOENT: no such file or directory, open '/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/clojure.set.js'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:348:35)
at global.SHADOW_IMPORT ([stdin]:45:15)
at Object.shadow$cljs$devtools$client$node$closure_import [as closure_import] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:33:4)
at Object.shadow$cljs$devtools$client$node$repl_require [as repl_require] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:61:7)
at shadow$cljs$devtools$client$node$process_message (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:122:6)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
at WebSocket.<anonymous> (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:159:12)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (/Users/bupkis/dev/myns/node_modules/ws/lib/WebSocket.js:141:47)
errno: -2,
syscall: 'open',
code: 'ENOENT',
path:
'/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/clojure.set.js' }
done
clojure.main config and set parameters to -m shadow.cursive-repl[2:1]~cljs.user=> (require 'demo.script) nil [2:1]~cljs.user=> (in-ns 'demo.script) nil [2:1]~demo.script=>
at java.util.Formatter.checkText(Formatter.java:2579) at java.util.Formatter.parse(Formatter.java:2565) at java.util.Formatter.format(Formatter.java:2501) at java.util.Formatter.format(Formatter.java:2455) at java.lang.String.format(String.java:2940) at clojure.core$format.invokeStatic(core.clj:5684) at clojure.core$format.doInvoke(core.clj:5678) at clojure.lang.RestFn.invoke(RestFn.java:423) at shadow.cursive_repl$get_socket_port.invokeStatic(cursive_repl.clj:25) at shadow.cursive_repl$get_socket_port.invoke(cursive_repl.clj:10) at shadow.cursive_repl$repl.invokeStatic(cursive_repl.clj:31) at shadow.cursive_repl$repl.invoke(cursive_repl.clj:29) at shadow.cursive_repl$_main.invokeStatic(cursive_repl.clj:93) at shadow.cursive_repl$_main.invoke(cursive_repl.clj:87) at clojure.lang.AFn.applyToHelper(AFn.java:154) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.lang.Var.applyTo(Var.java:702) at clojure.core$apply.invokeStatic(core.clj:657) at clojure.main$main_opt.invokeStatic(main.clj:317) at clojure.main$main_opt.invoke(main.clj:313) at clojure.main$main.invokeStatic(main.clj:424) at clojure.main$main.doInvoke(main.clj:387) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:702) at clojure.main.main(main.java:37)
.shadow-cljs/socket-repl.port file which should exist when the server is running :cache-root ".shadow-cljs" in your shadow-cljs.edn:node-script the best way to do what I'm trying to - e.g. to have a live repl in Cursive that I can load files into and play. It's not a problem to run some Node process manually outside of Cursive if need be, I'm already running the server so one more won't hurt hehenode-repl is better for thatshadow-cljs compile?shadow-cljs release app takes the majority of the time spent on that tasklein repl and then (time (require 'shadow.cljs.devtools.api))time npx shadow-cljs release <builds> running on our CI and I easily see ranges from 5-10minsnpx shadow-cljs release <builds> --verbose report.shadow-cljs/builds you might want to add .shadow-cljs/jar-manifest.shadow-cljs/builds and node_modules at the moment - not sure about jar-manifest. I can’t remember if I only kept the builds folder or the whole .shadow-cljs--verbose. the output prints just about everything where any time is spentcreateWebviewPanel assuming you have a shadow-cljs server running<script src=""> or so might do it alreadyselect-nrepl support in cider 😉 feel free to try it out https://github.com/clojure-emacs/cider/pull/2397watch-all could be a good idea ...clojure.test/report handlers and stuff?preload but I remember last time we discussed about why it is not in :node-test:renderer
{:target :browser
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:init-fn app.renderer.core/start!}}
:devtools {:after-load app.renderer.core/start!}}(start!) call from the app.renderer.core ns otherwise it'll be called twice on startupWARNING: No Clojure project was detected. The refactor-nrepl middleware was not enabled. (You can mute this warning by customizing 'cljr-suppress-no-project-warning'.) Can I somehow fix it?(ns myns.core (:require ["xregexp" as xregexp])) and can use it fine, stuff like (def my-re (xregexp "some.*regex" "g")) works fine, but Cursive shows xregexp cannot be resolved:npm-module target what will my-constant be exported as for something like (def ^:export my-constant 5.662)?my_constant.$ npx shadow-cljs cljs-repl :calva shadow-cljs - config: /Users/pez/Projects/clojure4vscode/shadow-cljs.edn cli version: 2.4.26 node: v10.1.0 shadow-cljs - connected to server [3:1]~cljs.user=> 1 No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. [3:1]~cljs.user=>It seems to tell me that it is connected to the server, but then complains that it is not. This used to work, and I don’t think I have changed something that should make it stop working. Funny thing is that the nREPL client in Calva can connect and can do everything I tell it, except evaluating (which gives the same error message as trying to evaluate from the REPL prompt).
:npm-module?node_modules, if that makes any difference for this problem.:npm-module? 😃:npm-module doesn't have a clearly defined entrypoint and as such cannot properly "preload" the devtools client. you can load it manually from JS though. so assuming you do import ... from "shadow-cljs/your.ns"; somewhereimport or require?shadow-cljs/shadow.cljs.devtools.client.browser before any other CLJS import:advanced but no you can't turn that off (currently). why would you want to?var kb = this.quill.keyboard; (which has an addBinding() method, which I call via kb.addBinding(). When I run it through advanced compilation, it turns kb.addBinding() into something like b.rE(), which it can’t find (I believe b still resolves to this.quill.keyboard, but it doesn’t have an rE() function on it).shadow-cljs check your-build? you should be getting a warning for that casecheck should find the problem. since you already know the problem though you can just create the externs/your-build.txt with one line addBindingquill not imported via shadow-cljs? wonder why it doesn't respect the addBinding methodreact-quill2018-08-04T02:57:14.739Z 15b1728f-9792-11e8-bf66-b982ac270145 TypeError: this.Rd is not a function at Promise.f.promesa$protocols$IPromise$_catch$arity$2 (/var/task/handlers.js:680:71) at zz (/var/task/handlers.js:676:641) at Kz (/var/task/handlers.js:682:442) at Fo (/var/task/handlers.js:778:164)I am using deps.edn for classpath/deps. I wonder if that’s causing the problem?
:compiler-options {:infer-externs :auto} if you haven't. run shadow-cljs release your-build --pseudo-names to figure out what .Rd is.import * as shadowBrowser from '../lib/shadow.cljs.devtools.client.browser', as the first clsj import being done, but it doesn’t fix the problem. Worse, it makes the release build fail. What am I not understanding correctly?importif (process.env.NODE_ENV == "development") { require("../lib/shadow.cljs.devtools.client.browser"); }lib/cljs_env.js file pleaseCLOSURE_DEFINES in particular?CLOSURE_DEFINES: var CLOSURE_DEFINES = $CLJS.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":false,"shadow.cljs.devtools.client.env.proc_id":"2cce7108-2ff9-43b0-9469-40d5785b5f80","goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9631,"shadow.cljs.devtools.client.env.use_document_host":false,"shadow.cljs.devtools.client.env.module_format":"js","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"calva","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"localhost","goog.TRANSPILE":"never"};"shadow.cljs.devtools.client.env.enabled":trueshadow.cljs.devtools.client.browser is loaded it should defiinitely do somethingimport "./lib/...."SyntaxError: Unexpected token import when just importing. At runtime, the TS compiler seems to think it is dandy.require instead yet?window not defined here: window.addEventListener("beforeunload",(function (){ …:runtime :node in your build config...client.node instead of .browserReferenceError: SHADOW_NODE_EVAL is not defined at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/clojure4vscode/lib/shadow.cljs.devtools.client.node.js:62:14)
var result = SHADOW_NODE_EVAL(js,source_map_json);:runtime :node in the target config, was that correct?.node stuff is not currently compatible with :npm-module:node-libray or :node-script:runtime :node config for now. Do you think I can fix it in shadow-cljs and send you a PR, or is it expert level stuff?global.SHADOW_NODE_EVAL = function(js, sm) { goog.globalEval(js); } before you load the .node nsgoog. won't exist yetglobal.SHADOW_NODE_EVAL = function(js, sm) { eval(js); }global.SHADOW_NODE_EVAL = function(js, smJson) {
if (smJson) {
js += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,";
js += Buffer.from(smJson).toString('base64');
}
// console.log(js);
return VM.runInThisContext.call(global, js,
{filename: "<eval>",
lineOffset: 0,
displayErrors: true});
};:node-script and :node-libraryVM is var VM = require("vm");ReferenceError: cljs is not defined at <eval>:2:1 at <eval>:3:1078 at ContextifyScript.Script.runInThisContext (vm.js:23:33) at runInThisContext (vm.js:95:38) at global.SHADOW_NODE_EVAL (/Users/pez/Projects/clojure4vscode/out/calva/extension.js:14:32) at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/clojure4vscode/lib/shadow.cljs.devtools.client.node.js:62:14)
VM part doesn't work/out directory where the TS compiler puts it stuff. Conceptually like so:
/out/calva/*.js (generated from *.ts) /out/lib/*.js (generated from *.cljs)
load-file or (require 'that.ns :reload). Cursive has a keybind to load the current file in the REPL and thats what I use all the time. The command uses load-file but require also works.(require 'some.ns :reload), but that didn't seem to cause shadow-cljs to rebuild itcljs.user=> (require 'verktyg.styled :reload) nil
:runtime config supposed to do? (I don’t find it mentioned in the docs.):compiler-options {:externs ["bluebird/externs.js"]} and that fixed it.:node-library 😛.nrepl-port, and shadow-cljs server shows shadow-cljs - nREPL server started on port (no port shown). the shadow-cljs.edn is very simple:{:dependencies [[zprint "0.4.10"]
[funcool/cuerdas "2.0.5"]]
:source-paths ["src"]
:builds {:test2 {:target :node-script
:main fmtz2.core/main
:output-to "out/test2.js"}}}
shadow-cljs - config: /Users/bupkis/dev/test2/shadow-cljs.edn cli version: 2.4.30 node: v10.8.0 shadow-cljs - starting ... WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/bupkis/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider() WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release shadow-cljs - server version: 2.4.30 shadow-cljs - server running at shadow-cljs - socket REPL running on port 55789 shadow-cljs - nREPL server started on port
(shadow/node-repl) from Cursive - I get RuntimeException Can't resolve find-ns clojure.lang.Util.runtimeException (Util.java:221)shadow-cljs clj-repl and from that I do (shadow/node-repl) - I get to the CLJS repl no problemfind-ns problem.shadow-cljs directory and try again. the config is above - very vanillatools.logging uses *ns* all over the place which results in this find-ns callcljs.core.ICounted is not a protocol when trying to implement a record with custom counting, however my tests seem to show that it's working correctly. Am I missing something?cljs.core/ICountedfind-ns issue should hopefully be fixed in 2.4.32. I can no longer reproduce it at least.["aws-sdk" :default AWS]
["aws-sdk/clients/s3" :default S3]
["aws-sdk/lib/util" :as AWS]
["aws-sdk/clients/s3" :as S3]aws-sdk it'll bring in every single thing including the stuff you don't actually useM-x cider-connect times out with the error:
[nREPL] Establishing direct connection to localhost:55098 ... [nREPL] Direct connection to localhost:55098 established helm-M-x: Sync nREPL request timed out (op clone id 1)I’m very new to all of this ClojureScript stuff and want to try it out so any help would be appreciated. Thanks!
:dependencies [[cider/cider-nrepl "0.18.0"]]
2.4.32 should hopefully fix most issuesM-x cider-create-sibling-cljs-repl doesn’t seem to be a command. I’ll look in the cider docs to see if it got renamed to something else<< Building for release >> [:mp360] Compiling ... The required namespace "doublethedonation.integrations.app" is not available. [:ddregister] Compiling ... The required namespace "doublethedonation.register" is not available. [:ddplugin] Compiling ... The required namespace "doublethedonation.external" is not available. [:mp360partners] Compiling ... The required namespace "doublethedonation.partner-portal.app" is not available.
<< Building for release >> looks like something custom maybe?(cljs/release :builds #{:mp360 :mp360partners :ddregister :ddplugin})java.classpath dependency and its single usejava.class.path property?java.class.path(boot.pod/get-classpath)shadow.build.classpath/get-classpath fn with something that calls the boot thing?prepare-runtime fn that seems to do some stuff(in-ns 'shadow.build.classpath) (defn get-classpath [] (boot.pod/get-classpath))
shadow-cljs npm command builds the classpath and starts with JVM with it setboot.class.path could also do the trickcljs.spec.test.alpha only in :dev mode? I need this dependency not to be in release bundle.cljs.spec.test.alpha in test namespaces and not your regular onesaws-sdk/lib/config#I need to create a separate build section in shadow-cljs.edn and I need to use
.cljc files, right? Maybe can I use additional external path for :dev and :release mode.cljs.spec.test.alpha in any of your main namespaces though?shadow-cljs compile your-build --verbosenpm install d3 and setup to resolve to "d3/build/d3.js", as recommended in the book, but get the error: "ExceptionInfo: could not find module-entry: d3/build/d3.js".(:require ["d3" :as d3]).(:require ["d3-color" ...])d3.color before thats just imported via d3-color nowjs/d3 as what they start with. See https://stackoverflow.com/questions/51728357/d3-javascript-translation-to-clojurescript/51728732#51728732d3 directly too. its really just an optimization to only require the smaller packages(.interpolateWarm), but there is no context, so how do I call it?(.interpolateWarm js/d3 30) would work I think.js/d3 is incorrect in shadow-cljs(:require ["d3" :as d3]) means that you pull d3 into the local scope. js/d3 is the global scope, just use d3 instead(.interpolateWarm d3 30)(d3/interpolateWarm 30)(:require ["d3-interpolate" :refer (interpolateWarm)]) and then (interpolateWarm 30)interpolateWarm fn?(:require ["d3" :as d3]) should work just fine today. they were in a weird state packaging-wise for a while but all of that was sorted out.d3 directly and never js/d3. is fine if you want(d3/thing) is the same as (.thing d3) just looks nicerimport {interpolateWarm} from 'd3-scale-chromatic'; is (:require ["d3-scale-chromatic" :refer (interpolateWarm)]) and then just (interpolateWorm ...)["d3-scale-chromatic" :refer (interpolateWarm)]d3 example from the book. its not relevant anymore.(:require ["d3" :as d3]) should work, and I do need it right? But not working for me at the moment.ExceptionInfo: could not find module-entry: d3/build/d3.js:resolve config example you need to remove thatd3 related configured in your config?js/d3 again?lein and I want non-lein options. One option I'm properly abandoning is npx create-cljs-project. I was just messing with a couple ideas for UI but it doesn't actually create anything yet. it already bugs me that its way too slow though$ npx create-cljs-project foo
npx: installed 35 in 18.384s
? Name of your project? test
? Which target? Browser
? Would you like some demo content? re-frame - A Reagent Framework For Writing SPAs, in ClojureScript.
#js {:project-name "test", :target :browser, :template :re-frame}18.3s just to run the damn thing is pretty much a non-starter for me~/Code npx create-react-app foo npx: installed 67 in 4.526shuh
(ns shadow.cljs.create.cli
(:require
[goog.object :as gobj]
["inquirer" :as inq]
["mustache" :as mst]
["fs" :as fs]))npm install shadow-cljs already takes way too longnpm doesn't take forever installing all the shitty depsnpm is so horribly slow in WSL its absolutely no fun to work withnpm thats slow however since it deals with soooooo many files@material-ui/icons like so:
["@material-ui/icons" :refer [PlayArrow Pause Stop]]it slows down incremental compilation significantly, 3-4 seconds on my machine. And now something worse is happening: my browser stops loading with a
failed to load resource: net::ERR_INSUFFICIENT_RESOURCES. It seems to load a ton of node_modules.(:require ["@material-ui/icons/PlayArrow" :default PlayArrow])"@material-ui/icons" requires every single icon and there are a lot of them:refer gotta do it manually@material-ui/iconsException in thread "main" java.lang.NoSuchMethodError: com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
[nubank/workspaces "1.0.0-preview6"] triggers the errorshadow handles npm transitive deps? Core has deps.cljs I wonder whether I can rely on it in shadow cuerdas uses xregexp, if I want to use it I need to install it manually? :npm-deps in deps.cljs in your jarnpm installdeps.cljs is for I guessgit status 😄cuerdas and fix it if not. Thank you! deps.cljs works BUT in case of the shadow-cljsjs compatibility packages no deps.cljs is provided. that is because there is no way to selectively install :npm-deps. Since this package contains a lot of cljsjs.* shims adding a deps.cljs would always install too many packages. https://github.com/thheller/shadow-cljsjscuerdas is one of those cljsjs/foreign-libs compat thingsxregexp dep is not installeddeps.cljs and :npm-deps is about their interaction with the compiler. using them to declare actual npm dependencies is fine by me:target :browser?<script>starter.browser.init({url:""});</script>:closure-defines https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines:closure-defines {some.app/var #shadow/env "MY_VAR"} if you are deadset on using environment variables:closure-definesinit fn(my.app.env) (defonce config (atom {:the "defaults"})) also worksMY_ENV=foo shadow-cljs release your-buildshadow-cljs release your-build && generate-prod-index.shclj-run option(defn release [] (shadow/release :my-build) (generate-prod-index))
shadow-cljs run my.build/releaseshadow/release call into calling (shadow/get-config :my-build) updating that config (its just a map) and then calling shadow/release* with itThis code cannot be converted from ES6. extending native class: Arrayclass Foo extends Array {
...
}
which Google Closure cannot convert to ES5npm install pts if you want to test itnode_modules usually gets transpiled by babel for reasons such as yours:language-out :ecmascript6 still transpiles most of the stuff out[:workspaces] Compiling ... Closure compilation failed with 1 errors --- node_modules/pts/dist/pts.js:288 This code cannot be converted from ES6. extending native class: Array
npx babel --presets env node_modules/pts/dist/pts.js -o node_modules/pts/foo.js(:require ["pts/foo" ...]) instead of just ptsTypeError: Constructor Float32Array requires 'new'
at Pt.Float32Array (<anonymous>):js-options {:language-out :ecmascript6}:compiler-options:js-options:compiler-options is only for the final :advanced optimization<script>starter.browser.init({url:""});</script>js->clj it fine or just normal js interopnode out/your-thing.js on the pi:node-script currently has some hard coded absolute paths(-> @app-state :config :url) however it's there when I console log the (:config @app-state)(swap! app-state merge {:config (js->clj config)})(:config @app-state) but not when (-> @app-state :config :url)?(:url :config @app-state)(get-in @app-state [:config :url]) doesn't work?(:config @app-state) probably shows {"url" "..."} right?(get-in @app-state [:config "url"]) or (js->clj config :keywordize-keys true) when doing the initial swap!:builds should be a map of :builds {:foo {...}}shadow-cljs init will create a basic config for youshadow-cljs new ... soonshadow-cljs watch app --verbose-> Cache read: ui_app/panels/booking_detail/location.cljs <- Cache read: ui_app/panels/booking_detail/contact_details.cljs (56 ms) -> Cache read: ui_app/panels/booking_detail/contact_detail.cljs <- Cache read: ui_app/panels/booking_detail/location.cljs (19 ms) <- Cache read: ui_app/panels/booking_detail/contact_detail.cljs (47 ms)
-> means it started doing something, <- means it finished that something with x time-> line that doesn't have a <--> Cache read: cljs/core/match.cljs
2.4.28 already.shadow-cljs/builds/app/dev/ana/cljs/core/match*2.4.20->?-> thoughTypeError: Uncaught TypeError: Cannot instantiate an arrow function. Anyone can help me?lein deps tree would help too, or the project.clj. no need to switch everything.graphql-builder and queries or syntax or so. At least, I can compile again if I remove some graphql-queries 😛. Thx!@absinthe/socket package is probably the weirdest code I have ever seen. no idea whats happening though..bind(void 0)
, getHandlerName = function(e) {
return _newArrowCheck(this, _this$4),
"on" + String(e)
}
.bind(void 0)
, notify = function(e, n, i) {
return _newArrowCheck(this, _this$4),
e.observers.forEach(getNotifier(getHandlerName(n), i))
}
.bind(void 0)
, _this$6 = void 0
, findIndex = function(e, n, i) {
return _newArrowCheck(this, _this$6),
e.findIndex(utilsComposite.hasIn([n], i))
}
.bind(void 0)
, _this$5 = void 0
, remove$1 = function(e) {
return _newArrowCheck(this, _this$5),
function(n) {
return _newArrowCheck(this, _this$5),
utilsArray.remove(findIndex(n, "request", e.request), 1, n)
}
.bind(this)
}Uncaught TypeError: Cannot instantiate an arrow function
at exports.default (newArrowCheck.js:8)
at index.js:2
at Object.kitasato$events$create_absinthe_socket [as create_absinthe_socket] (events.cljs:250)
at events.cljs:260
at events.cljs:260
this method:
["@absinthe/socket" :as absinthe] ;; .... line 250: (.create absinthe phoenix-socket)
["@absinthe/socket/compat/umd/index" :as absinthe] to use that directly ["@absinthe/socket" :as absinthe] and calling (absinthe/create nil) is enough to trigger the problem thoughimport simplify from 'simplify-js'; then after npm install simplify-js working fine I ought to be able to require: ["simplify-js" :refer (simplify)] and look at simplify and it should not be undefined. Is that correct?import simplify .. is a default export. so it would be ["simplify-js" :default simplify].["simplify-js" :refer (simplify)] is equiv to import { simplify } from 'simplify-js';. note the extra {}. ES6 imports are weird.shadow-cljs watch appshadow-cljs - config: /Users/yqrashawn/workspace/HOME/right-site/shadow-cljs.edn cli version: 2.4.33 node: v9.8.0
shadow-cljs - starting ...
Aug 12, 2018 9:54:04 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 12, 2018 9:54:04 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
Exception in thread "main" java.lang.AssertionError: Assert failed: (qualified-symbol? sym)
at shadow.cljs.devtools.server.nrepl04$middleware_load.invokeStatic(nrepl04.clj:269)
at shadow.cljs.devtools.server.nrepl04$middleware_load.invoke(nrepl04.clj:269)
at clojure.core$map$fn__5587.invoke(core.clj:2745)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:528)
at clojure.core$seq__5124.invokeStatic(core.clj:137)
at clojure.core$filter$fn__5614.invoke(core.clj:2801)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:528)
at clojure.core$seq__5124.invokeStatic(core.clj:137)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
at clojure.core.protocols$fn__7835.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__7835.invoke(protocols.clj:75)
at clojure.core.protocols$fn__7781$G__7776__7794.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6748)
at clojure.core$into.invokeStatic(core.clj:6815)
at clojure.core$into.invoke(core.clj:6807)
{:nrepl {:port 9898
:middleware [[cider/piggieback "0.3.5"]]}
:http {:port 3333
:host "0.0.0.0"}
:source-paths ["src/clj" "src/cljs"]
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.10.238"]
[reagent "0.7.0"]
[re-frame "0.10.5"]
;; [secretary "1.2.3"]
[garden "1.3.5"]
[ns-tracker "0.3.1"]
[compojure "1.5.0"]
[bidi "2.1.3"]
[yogthos/config "0.8"]
[ring "1.4.0"]
[re-pressed "0.2.2"]
[re-frisk "0.5.3"]
[binaryage/devtools "0.9.10"]
[day8.re-frame/re-frame-10x "0.3.3"]]
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "js/compiled/out"
:modules {:main {:entries [right-site.core]}}
:devtools {:http-root "resources/public"
:http-port 3000
:http-host "0.0.0.0"
:open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]
:autoload true}}}}
src
├── clj
│ └── right_site
│ ├── core.clj
│ ├── css.clj
│ ├── handler.clj
│ └── server.clj
└── cljs
└── right_site
├── config.cljs
├── core.cljs
├── db.cljs
├── events.cljs
├── home-page
│ ├── home_page_data.cljs
│ └── home_page_views.cljs
├── login-page
│ ├── login_page_data.cljs
│ └── login_page_views.cljs
├── routes.cljs
├── subs.cljs
└── views.cljs
piggieback middleware in the future.error in process sentinel: Could not start nREPL server: shadow-cljs - config: .../shadow-cljs.edn cli version: 2.4.11 node: v10.8.0 shadow-cljs - connected to server server already running
shadow-cljs stop should stop it(defonce app-state ..) or (def app-state ..)?(defonce app-state (r/atom default-app-state))where default-app-state is an object
init once? its not a hook or anything?init once. I will investigateproxychains4 wget ....jar worked.shadow-cljs-jar dependency~/.shadow-cljs/shadow-cljs-launcher-2.0.0.jar manuallyhttps packageshadow-cljs-jar package but not depend on itnpm works right?install it manually means download and put it in ~/.shadow-cljs/?npm install shadow-cljs shadow-cljs-jarshadow-cljs just depended on shadow-cljs-jar but I want to get rid of that extra npm download since it mostly wastedshadow-cljs-standalone package which downloads shadow-cljs and the launcher (via npm):npm-script is in 2.5.0 so it should be now possible to do the raspberry pi development we talked about.:output-to "out/script.js" :output-dir "out/something". by default :output-dir is set to something that might not be reachable on the pipi and mounted the raspberry pi’s filesystem on it:output-dir "pi/nodetest/ucv_tcs"
:output-to "pi/nodetest/main.js"
Error: ENOENT: no such file or directory, open '/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime/goog.debug.error.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at global.SHADOW_IMPORT (/home/pi/nodetest/main.js:46:15)
at /home/pi/nodetest/main.js:3005:1
at Object.<anonymous> (/home/pi/nodetest/main.js:3200:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
var SHADOW_IMPORT_PATH = "/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime";
REPL client error { Error: connect ECONNREFUSED 127.0.0.1:9630
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9630 }
REPL client disconnected
var SHADOW_IMPORT_PATH = __dirname +:devtools {:devtools-url "http://<ip-of-your-machine>:9630"}lein clean? are you using lein?shadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn cli version: 2.5.0 node: v10.4.1 shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch tcs
project.clj?project.clj had it too=>> yarn watch yarn run v1.9.4 $ shadow-cljs watch client shadow-cljs - config: /Users/chen/repo/mvc-works/calcit-workflow/shadow-cljs.edn cli version: 2.5.0 node: v10.8.0 shadow-cljs - starting 2.5.0 with launcher 2.0.0 ... Downloading: thheller/shadow-cljs/2.5.0/shadow-cljs-2.5.0-aot.jar from Downloading: org/clojure/clojurescript/1.10.339/clojurescript-1.10.339-slim.jar from Downloading: com/google/javascript/closure-compiler-externs/v20180805/closure-compiler-externs-v20180805.jar from Downloading: com/google/javascript/closure-compiler-unshaded/v20180805/closure-compiler-unshaded-v20180805.jar from Downloading: com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar from Aug 13, 2018 2:34:44 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Aug 13, 2018 2:34:44 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :client available at shadow-cljs - server version: 2.5.0 shadow-cljs - server running at shadow-cljs - socket REPL running on port 53885 shadow-cljs - nREPL server started on port 53887 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... [:client] Build completed. (198 files, 98 compiled, 0 warnings, 32.43s)
{:source-paths ["src" "cli"]
:mirrors {"central" {:name "central"
:url ""}}
:mirrors works anymorealiyuntools.deps actually supports that:sources [:shadow.build.npm/resource "libcsound/libcsound.js"] :source)libcsound/libcsound_browser.js and then in package.json use a "browser":{"libcsound/libcsound.js": "libcsound/libcsound_browser.js"} overridelibcsound/libcsound_browser.js when building for the browser:sources a new source string, possible?(defn wasm2datauri
{:shadow.build/stage :compile-finish}
[build-state & args]
(let [resrc [:shadow.build.npm/resource "libcsound/libcsound.js"]
src (get-in build-state [:sources resrc :source])
wasm (string/trim (:out (sh "node" "libcsound/datauri.js")))
new-src (string/replace src "libcsound.wasm" wasm)]
(assoc-in build-state [:sources resrc :source] new-src)))
:compile-finish though"browser" is exactly for cases such as yours?node create-that-browser-file.js && shadow-cljs ....libcsound-browser or whatever:resolve settingsuser.clj that loads figwheel on startuplein deps :treecljsjs/create-react-class from your deps for that one(ns cljsjs.material-ui (:require ["material-ui" :as mui])) (js/goog.exportSymbol "MaterialUI" mui)
@material-ui/core/Buttonantd vs individual antd components-rw-rw-rw- 1 thheller thheller 1007K Feb 27 17:59 material-ui.min.inc.js -rw-rw-rw- 1 thheller thheller 1.4M Feb 27 17:59 material-ui-svg-icons.min.inc.js
qlkit-material-ui.core is super small. you could probably rewrite it to only include what you need(ql/regsiter-component ..) call https://github.com/forward-blockchain/qlkit-material-ui/blob/master/src/qlkit_material_ui/core.cljs#L51(:require ["@material-ui/core/Button" :default Button]) and (ql/register-component :button Button) may just work?register-component is called before qlkit/mountdashboard/livehelp
homepage/livehelp
I can simply use dashes instead of slashes, it’s not a huge deal. just aesthetically it would be nice to be able to namespace them:configure, where I could modify :closure-defines?:shadow.build/config, but those settings have already been locked-in elsewhere, so I can instead update-in build-state [:compiler-options :closure-defines]:compile-prepare:npm-module will work but is sort of limited regarding repl/live-reloadmetro details:npm-module though:npm-module you can just use the built-in RN reloading stuffes or commonjs yeses versionscommonjs. "react-virtualized/dist/commonjs/AutoSizer"es version "react-virtualized/dist/es/AutoSizer":infer-externs :auto turned on and changing to simple (instead of advanced) solved the issuetransit-cljs, not a big deal, just wanted to report them:
------ WARNING #2 -------------------------------------------------------------- File: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: com/cognitect/transit/types.js:384:70 variable Buffer is undeclared
shadow.build.warnings/*color* bindingshadow-cljs release app, the first time I will get an error compiling my code but subsequent runs the error is not printed. This behavior does not make sense to me.------ ERROR ------------------------------------------------------------------- File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/core.cljs:41:3 -------------------------------------------------------------------------------- 38 | [] 39 | (s/check-asserts true) 40 | (set! s/*explain-out* expound/printer) 41 | (st/instrument) ---------^---------------------------------------------------------------------- Unable to resolve var: def-command-spec in this context at line 41 compute/ui_frontend/core.cljs --------------------------------------------------------------------------------
st/instrument is never going to work in :advanced?def-command-spec is a macro BTW.(defn init-dev-tools [] (s/check-asserts true) (set! s/*explain-out* expound/printer) (st/instrument) nil)which is called like this:
(when ^boolean goog.DEBUG (init-dev-tools))
ns and use :preloadsst and expound requires otherwiseinstrument is a funky macrost ns doesdef-command-spec is a Spec'ed macro.def-command-spec in the same ns it is defined in.st/instrument is a side effecting macrorelease build. even when its supposed to be DCE'd(ns ^:dev/always your.preloads)st/instrument code won't actually instrument anything since your code isn't loaded yetshadow-cljs deps-tree is newreagent is an explicit dependency but re-frame depends on reagent/reagent. guess tools.deps doesn't de-dupe thoseclj alone2.5.1:preloads is for dev-only code. the ns included via :preloads must however not the required by anything else:preloads entirely since it will be included anywaysshadow.user> (shadow/reload-deps! '{specs {:local/root "../spec-cljs"}})
:shadow.cljs.devtools.api/standalone-only
shadow.user>
lein ubjerjar i get this
[2018-08-15 02:23:56.368 - INFO] duplicate resource cljs/compiler.cljc on classpath, using jar:file:/home/ec2-user/.m2/repository/org/clojure/clojurescript/1.10.339/clojurescript-1.10.339-slim.jar!/cljs/compiler.cljc over jar:file:/home/ec2-user/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/compiler.cljcbut i made sure both
package.json and project.clj have the same version of shadow-cljs, 2.5.1project.clj dependencies?project.clj deps:uberjar :preptasks i have
:prep-tasks ["clean" ["clean"]
"compile" ["with-profile" "cljs" "run" "-m" "shadow.cljs.devtools.cli" "release"
"main" "pos" "signon"]]}
lein deps :treeand see if there’s duplicate CLJS being pulled in somewhere?reload-deps! still doesnt quite work. need to find a better strategy for dealing with conflicts and actually making the added sources available to compilation. right now they are just added to the classpath and would require reloading the server first. I'll write an official introduction once I sorted out the kinks.shadow release main instead of via uberjar prep taskpackage.json and project.cljlein deps :tree on the working vs non-working @currentoororg.clojure/clojurescript "1.10.339" :classifier "slim" since the default release includes AOT classes which where clashing with shadow-cljs AOT classestools.deps does the thing I expected but lein does not which l leads to the duplicated deplein, see if the latest version has this problem:http-root and such10:14:27.602 [main] DEBUG io.undertow - JDK9 ALPN not supported java.lang.NoSuchMethodException: javax.net.ssl.SSLParameters.setApplicationProtocols([Ljava.lang.String;) at java.lang.Class.getMethod(Class.java:1786) at io.undertow.protocols.alpn.JDK9AlpnProvider$1.run(JDK9AlpnProvider.java:47) at io.undertow.protocols.alpn.JDK9AlpnProvider$1.run(JDK9AlpnProvider.java:43) at java.security.AccessController.doPrivileged(Native Method)is this expected? i’m thinking it could do with dependency mismatches
Circular dependency detected: testing.cljs.spec -> testing.cljs.spec (require 'testing.cljs.spec :reload)when I do
(require 'testing.cljs.spec :reload)Circular dependency detected: testing.cljs.spec -> testing.cljs.spec ClassCastException:
testing.cljs.spec?ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative clojure.lang.RT.assoc (RT.java:820) clojure.core/assoc--5218 (core.clj:191) clojure.core/assoc--5218 (core.clj:190) clojure.core/update (core.clj:6135) clojure.core/update (core.clj:6123) shadow.build.ns-form/eval10706/fn--10708 (ns_form.clj:372) clojure.lang.MultiFn.invoke (MultiFn.java:234) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6762) clojure.core/reduce (core.clj:6745) shadow.build.ns-form/parse (ns_form.clj:483) shadow.build.ns-form/parse (ns_form.clj:450) shadow.cljs.repl/make-repl-resource (repl.clj:76) shadow.cljs.repl/make-repl-resource (repl.clj:60) shadow.cljs.repl/repl-ns (repl.clj:304) shadow.cljs.repl/repl-ns (repl.clj:302) shadow.cljs.repl/process-read-result (repl.clj:415) shadow.cljs.repl/process-read-result (repl.clj:395) shadow.cljs.devtools.server.worker.impl/eval17297/fn--17300 (impl.clj:491) clojure.lang.MultiFn.invoke (MultiFn.java:234) shadow.cljs.devtools.server.util/server-thread/fn--17044/fn--17045/fn--17053 (util.clj:265) shadow.cljs.devtools.server.util/server-thread/fn--17044/fn--17045 (util.clj:264) shadow.cljs.devtools.server.util/server-thread/fn--17044 (util.clj:237) java.lang.Thread.run (Thread.java:748)now after REPL reboot
.cljc file...(defmacro a-macro
[]
(let []
`(println "test")))
ClassCastException[5:0]~shadow.user=> (shadow/browser-repl)
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (134 files, 1 compiled, 0 warnings, 0.52s)
[5:1]~cljs.user=> JS runtime connected.
[5:1]~cljs.user=> (ns foo.bar)
nil
[5:1]~foo.bar=> (require 'demo.browser :reload)
nil
[5:1]~foo.bar=> (ns foo.bar (:require demo.browser))
[:result {:type :repl/error, :ex #error {
:cause "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"
:via
[{:type java.lang.ClassCastException
:message "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"
:at [clojure.lang.RT assoc "RT.java" 820]}]
:trace
[[clojure.lang.RT assoc "RT.java" 820]
[clojure.core$assoc__5138 invokeStatic "core.clj" 191]
[clojure.core$assoc__5138 invoke "core.clj" 190]
[clojure.core$update invokeStatic "core.clj" 6120]
[clojure.core$update invoke "core.clj" 6108]
[shadow.build.ns_form$fn__13691 invokeStatic "ns_form.clj" 372]
[shadow.build.ns_form$fn__13691 invoke "ns_form.clj" 368]
[clojure.lang.MultiFn invoke "MultiFn.java" 233]
[clojure.lang.PersistentVector reduce "PersistentVector.java" 341]
[clojure.core$reduce invokeStatic "core.clj" 6747]
[clojure.core$reduce invoke "core.clj" 6730]
[shadow.build.ns_form$parse invokeStatic "ns_form.clj" 483]
[shadow.build.ns_form$parse invoke "ns_form.clj" 450]
[shadow.cljs.repl$make_repl_resource invokeStatic "repl.clj" 76]
[shadow.cljs.repl$make_repl_resource invoke "repl.clj" 60]
[shadow.cljs.repl$repl_ns invokeStatic "repl.clj" 304]
[shadow.cljs.repl$repl_ns invoke "repl.clj" 302]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 415]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 395]
[shadow.cljs.devtools.server.worker.impl$fn__19853 invokeStatic "impl.clj" 491]
[shadow.cljs.devtools.server.worker.impl$fn__19853 invoke "impl.clj" 455]
[clojure.lang.MultiFn invoke "MultiFn.java" 233]
[shadow.cljs.devtools.server.util$server_thread$fn__19628$fn__19629$fn__19637 invoke "util.clj" 265]
[shadow.cljs.devtools.server.util$server_thread$fn__19628$fn__19629 invoke "util.clj" 264]
[shadow.cljs.devtools.server.util$server_thread$fn__19628 invoke "util.clj" 237]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 844]]}}]:reload handling is completely weird. don't know how I intended that to work in the first place 😛cider so I guess nobody was really using it 😛(ns ...) after calling require :reloadns is additive in the REPL it had trouble merging the flags, thats allshadow kicking me out of the REPL (`CompilerException java.lang.RuntimeException...`) when debugging core.async code?core.async. It looks as though, when something goes wrong within a chan (e.g., an error like nil is not allowed in a channel), stuff breaksSyntaxErrors when running karma tests. the message looks like this:
{
"message": "Uncaught SyntaxError: missing ) after argument list\nat ci.js:114889:322\n\nSyntaxError: missing ) after argument list",
"str": "Uncaught SyntaxError: missing ) after argument list\nat ci.js:114889:322\n\nSyntaxError: missing ) after argument list"
}
autoWatchBatchDelay https://karma-runner.github.io/2.0/config/configuration-file.html (2000 or so should be good)chan I'm getting kicked out.(shadow.cljs.devtools.api/node-repl)shadow-cljs node server keeps running, but Cursive breaksλ shadow-cljs clj-repl shadow-cljs - config: C:\Users\Surface\Projects\clojure\cljs\census-geojson\shadow-cljs.edn cli version: 2.4.25 node: v8.11.3 shadow-cljs - starting ... shadow-cljs - server version: 2.4.25 shadow-cljs - server running at shadow-cljs - socket REPL running on port 50413 shadow-cljs - nREPL server started on port 3333 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [1:0]~shadow.user=>
node-repl session in Cursive. This only seems to happen when working with core.async so I hope to be done with that soon 😄chan seems to kick me out of the session. I'm trying to think of a better way to explain...nil into a chan, when a function that's being called in a go block errors out, when I forget to eval a defn before eval'ing a go block that contains it... yes cursive gets disconnectedshadow-cljs clj-repl session. I just have to re-eval (shadow.cljs.devtools.api/node-repl) to start the Cursive REPL again and then re-eval the namespace, functions, etc.shadow-cljs clj-repl againshadow-cljs clj-repl => REPL session starts
step 2) Error put into a chan => Error thrown in Cursive REPL (`shadow-cljs` still running, doesn't break)
step 3) (shadow.cljs.devtools.api/node-repl) => restart node-repl in Cursive
step 4) eval (ns...) and functions to get me back to debugging the core.async logic
step 5) bug in code = repeat from step 2)shadow-cljs clj-repl externally?shadow-cljs clj-repl still running, but the Cursive REPL dies on me, requiring me to re-eval (shadow.cljs.devtools.api/node-repl) in there to kick start Cursive REPL again. It feels like getting kicked outnode-repl will switch to CLJS modeCompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(null:1:1)
(in-ns 'shadow.user) after you get "kicked out"1 or whatever<script>starter.browser.init({foo: "bar"});</script> instead?init fninit is called once on startup from HTMLstartstop is called and then start after loading the codeinit never happens again:dev/after-load or :after-load in the config?init into 2 functions. one that can be called again (ie. doesn't use args) and one that puts the config somewhere safe[7:1]~cljs.user=> (require '[cljs.core.async :as a])
nil
[7:1]~cljs.user=> (a/go (throw (ex-info "foo" {})))
<eval>:1
(function (){var c__34073__auto__ = cljs.core.async.chan.call(null,(1));
^
TypeError: Cannot read property 'call' of undefined
at <eval>:1:58
at <eval>:89:3
at Script.runInThisContext (vm.js:65:33)
at runInThisContext (vm.js:199:38)
at global.SHADOW_NODE_EVAL ([stdin]:75:30)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:25:16)
at shadow.cljs.devtools.client.node/node-eval (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:48:30)
at Object.repl-expr (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:91:16)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:48:13)
at shadow.cljs.devtools.client.node/repl-invoke (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:116:6)
[7:1]~cljs.user=> (+ 1 2)
3
nREPL issue(js/process.exit 1) breaks the entire thinggoog.defineClass, it works with "watch", but when I release, I encounter
Closure compilation failed with 1 errors --- csound_wasm/browser.cljs:201 Unsupported class definition expression.makes me wonder why it works with watch to begin with...
watch the code isn't processed by closure(def CsoundWorkletNode
(goog.defineClass
js/AudioWorkletNode
#js {:constructor
(this-as that
(fn [ctx]
((.-superClass_ that) ctx "csound-processor")))}))
mocking this
class MyWorkletNode extends AudioWorkletNode {
constructor(context) {
super(context, 'my-worklet-processor');
}
}
and it worked surprisingly, luckily the superClass that's injected from closure library helped a lot.React.Component with AudioWorkletNodegoog.defineClass is totally invalid(goog/defineClass ...) or (js/goog.defineClass ...)this-as must be the first inside the fn not outside.-superClass_?Closure compilation failed with 1 errors --- csound_wasm/browser.cljs:192 The class must be defined by an object literal
super(def CsoundWorkletNode
(js/goog.defineClass
js/AudioWorkletNode
#js {:constructor
(fn [ctx]
(js/super ctx "csound-processor"))}))Closure compilation failed with 1 errors --- externs.shadow.js:11 Parse error. 'identifier' expected
super(def CsoundWorkletNode
(js/goog.defineClass
js/AudioWorkletNode
#js {:constructor
(fn [ctx]
(js* "super({}, {});" ctx "csound-processor"))}))Closure compilation failed with 1 errors --- csound_wasm/browser.cljs:193 Parse error. Semi-colon expected
js* is weird. better not use itclass with extends or else it breaksReact.Component with whatever classReflect.construct call might also work. it was necessary for web components a while backdefn:modules
{:shared {:entries [cljs.core] :depends-on #{}}
:main {:entries [demo.app] :depends-on #{:shared}}
:audio1 {:entries [demo.audio1] :depends-on #{:base} :web-worker true}}shared.js + main.jscontext.audioWorklet.addModule('/js/audio1.js')(set! (.. component-fn -prototype -constructor) my-component)is that
component-fn is its own function and not my-component?my-component instead of component-fnUncaught TypeError: Illegal invocation
at Object.goog.object.extend (goog.object.object.js:610)
at browser.cljs:212
code
(goog.object/extend CsoundWorkletNode.prototype js/AudioWorkletNode.prototype)
CsoundWorkletNode.prototype this is rarely valid CLJS code(.. CsoundWorkletNode -prototype)(defn component []
(js/AudioWorkletNode #js [] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/AudioWorkletNode)
#js {:constructor (fn [ctx])}))
Reflect callgoog.object/set instead of set!, it's easier to read and is adv compilation proof(defn component []
(js/Reflect.construct js/AudioWorkletNode #js [] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/AudioWorkletNode)
#js {:constructor (fn [ctx])}))
(def context (new js/AudioContext))
(-> (.addModule context.audioWorklet "./csound-wasm-worklet-processor.js")
(.then (fn [] (new component context))))
Uncaught (in promise) TypeError: Failed to construct 'AudioWorkletNode': 2 arguments required, but only 0 present.
at new csound_wasm$browser$component (browser.cljs:207)
#js [] in the reflect call:web-worker stuff definitely doesn't work at all(defn component [ ctx node-name ]
(js/Reflect.construct js/AudioWorkletNode #js [ ctx node-name ] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/AudioWorkletNode)
#js {:constructor (fn [ctx])}))
(def context (new js/AudioContext))
(-> (.addModule context.audioWorklet "./csound-wasm-worklet-processor.js")
(.then (fn [] (this-as that (new component context "csound-processor")))))
Uncaught (in promise) DOMException: Failed to construct 'AudioWorkletNode': AudioWorkletNode cannot be created: The node name 'csound-processor' is not defined in AudioWorkletGlobalScope.
Uncaught TypeError: Cannot use 'in' operator to search for 'StopIteration' in undefined
at csound-wasm-worklet-processor.js:187
at csound-wasm-worklet-processor.js:2133
goog.iter.StopIteration="StopIteration"in goog.globalno global in this secure environment
goog.global = this; but this is undefined in a module scopeset! on goog-define?
Closure compilation failed with 4 errors --- registry/aws_test.cljs:16 @define variable registry.PROVIDER assignment must be global
goog.define are compile time constants, so no you cannot set! them:closure-defines in the test build?:^dynamic var containing a goog-define for this...still decidingregistry.PROVIDER looks like it is actually a runtime configuration option and not a compile time constant.^:dynamic for this iteration:app {... :compiler-options {:devtools/config {:features-to-install ...}}} I believe:external-config as described in the docs is :compiler-options in shadow-cljs.edn;; shadow-cljs configuration
{:source-paths ["src"]
:dependencies [[reagent "0.8.0-alpha2"]
[cider/cider-nrepl "0.18.0-SNAPSHOT"]]
:builds {:main {:target :node-script
:output-to "resources/main.js"
:main app.main.core/main}
:renderer {:target :browser
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:init-fn app.renderer.core/start!}}
:devtools {:after-load app.renderer.core/start!
:watch-dir "resources/public"}}}}
file:// urls electron returns for document.location.hrefif (util && util.inspect && util.inspect.custom) {
module.exports.prototype[util.inspect.custom] = function () {
var obj = util.inspect({ length: this.length });
return this.constructor.name + ' ' + obj;
};
}npm install it still does not worknode_modules/readable_stream:resolve {"object.assign" {:target :npm :require "object-assign"}
"stream" {:target :npm :require "readable-stream"}}
[:ci] Compiling ...
symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
{:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object-assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object.assign/index.js"]}
ExceptionInfo: symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js". Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules You probably need to run: npm install readable-stream/writable.js
readable-stream/writable.js. but i’ve installed readable and streamrm -rf node_modulesnode_modules/readable-stream then➜ Monolith git:(shadow-cljs) ✗ shadow compile ci --debug shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Monolith/shadow-cljs.edn cli version: 2.5.1 node: v10.8.0 shadow-cljs - starting 2.5.1 with launcher 2.1.0 ... [:ci] Compiling ... The required JS dependency "readable-stream/readable.js" is not available, it was required by "node_modules/stream-browserify/index.js". Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules You probably need to run: npm install readable-stream/readable.js See: ➜ Monolith git:(shadow-cljs) ✗
node_modules/readable-stream exist? if so check its package.json pleasenode_modules and package-lock.json again:jvm-opts ["-Xmx1G"] in shadow-cljs.edn-Xmx512m[:ci] Compiling ... The required JS dependency "react-dom/test-utils" is not available, it was required by "node_modules/enzyme-adapter-react-15/build/ReactFifteenAdapter.js". Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules You probably need to run: npm install react-dom/test-utilsi’m guessing i need to add a
:resolve key for this?:resolve for this/Users/chrisetheridge/code/Cognician/Monolith/node_modules + react-dom/test-utils/Users/chrisetheridge/code/Cognician/Monolith/node_modules/react-dom/test-utils.js15.0.0init is not defined➜ Monolith git:(shadow-cljs) ✗ karma start --single-run
17 08 2018 12:38:56.254:INFO [karma]: Karma v2.0.5 server started at
17 08 2018 12:38:56.259:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
17 08 2018 12:38:56.267:INFO [launcher]: Starting browser ChromeHeadless
17 08 2018 12:38:56.619:INFO [HeadlessChrome 0.0.0 (Mac OS X 10.13.6)]: Connected on socket B0WRKA9GuQOl0l4wAAAA with id 88087934
HeadlessChrome 0.0.0 (Mac OS X 10.13.6) ERROR
{
"message": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at ",
"str": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at "
}
:runner-ns?client: {args: ["shadow.test.karma.init"][0:0]~cljs.user=> (require '["enzyme-adapter-react-16" :as Adapter])
[:result {:type :repl/error, :ex #error {
:cause "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
:data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
:via
[{:type clojure.lang.ExceptionInfo
:message "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
:data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
:at [clojure.core$ex_info invokeStatic "core.clj" 4739]}]
i get this when trying to require that npm dep? regardless of :as or :refershadow-cljs browser-repl["enzyme-adapter-react-16" :default Adapter]
:resolve setting:default :refer or :as, i get undefined each timefile: url since I didn't expect that it just assumes http semantics currently.shadow-cljs stop and then shadow-cljs server. it probably fails on startup.2.4.33.shadow-cljs/*.log{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2a424f445843416a67434743580718"}, :content ("[email protected]")}.shadow-cljs, reinstalled 2.5.1, and did a shadow-cljs start.server.stderr.log has a single Error: Unable to access jarfile null in itnode-sass for that--max-old-space-size (the max heap size) via the package.json (reference: https://stackoverflow.com/a/34358130) I'm running out of memory doing some very large batch processing with fsshadow listen for the start command in package.json?FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node_module_register 2: v8::internal::FatalProcessOutOfMemory 3: v8::internal::FatalProcessOutOfMemory 4: v8::internal::Factory::NewFillerObject 5: v8::internal::wasm::WasmOpcodes::TrapReasonMessage 6: 000002033BF843C1
node-repl or what?(shadow/node-repl {:node-args ["--whatever"]})clj-repl(shadow.cljs.devtools.api/node-repl {:node-args ["--max-old-space-size=8192"]})
To quit, type: :cljs/quit
=> [:selected :node-repl]
"start": "node --max-old-space-size=4076"
8192 in there insteadapp, devcards and tests build instead:preloads?preload in node-test once and it was not working? I will try again though because I cannot recall now:node-test though?(require '[cljs.repl :refer [doc]]) then (doc map) the output of that goes in the terminal and not in the REPL...might be a CIDER issue but do you have any hint on that?doc probably prints during compilation. so it prints wherever the compilation was started. did you start the watch or whatever per CLI and then connected the REPL?2.6.1 with :preloads support for :node-testdefmethods are confusing...I will confirm later if it really works 😄 :devtools {:preloads [testing.with-diff-reporter]}{:target :node-test
:output-to ".cljs/tests.js"
:ns-regexp ".*-test"
:autorun true
:devtools {:preloads [testing.with-diff-reporter]}
:release {:compiler-options {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:source-map true}
:autorun false}}
cljs.test multimethods, are those required before :preloads or after?:dev {:preloads [...]} currently. forgot that should be in :devtools. will fix latercljs.test options however I suggest copying https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs and adjust whatever you need and your ns via :runner-ns. its main fn will be called when running the test scriptRuntimeException java.io.EOFException com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:114) cognitect.transit/read (transit.clj:319) cognitect.transit/read (transit.clj:315) shadow.build.cache/read-cache (cache.clj:49) shadow.build.cache/read-cache (cache.clj:33) shadow.build.classpath/find-jar-resources/fn--10051 (classpath.clj:565) shadow.build.classpath/find-jar-resources (classpath.clj:564) shadow.build.classpath/find-jar-resources (classpath.clj:553) shadow.build.classpath/find-resources (classpath.clj:623) shadow.build.classpath/find-resources (classpath.clj:621) shadow.build.classpath/index-path* (classpath.clj:843) shadow.build.classpath/index-path* (classpath.clj:840) Caused by: EOFException com.cognitect.transit.impl.JsonParser.parse (JsonParser.java:44) com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:112) cognitect.transit/read (transit.clj:319) Exception in thread "main" java.lang.NoSuchMethodError: com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer; at cognitect.transit$writer.invokeStatic(transit.clj:157) at cognitect.transit$writer.invoke(transit.clj:139) at shadow.build.cache$write_stream.invokeStatic(cache.clj:9) at shadow.build.cache$write_stream.invoke(cache.clj:8)
shadow-cljs pom and mvn dependency:tree if you have maven installed(fn [^js event] ...)(defn hook-browser-navigation! []
(doto (History.)
(gevents/listen
EventType/NAVIGATE
(fn [event] (secretary/dispatch! (.-token event))))
(.setEnabled true)))
(defn setup-routing!
[]
(accountant/configure-navigation!
{:nav-handler #(hook-browser-navigation!)
:path-exists? (fn [path] (secretary/locate-route path))}))
accountant/navigate don't dispatch the routessecretary.core/defroute have funcitons transact the app state:nav-handler incorrectlyhook-... fn should only be done once on init(accountant/configure-navigation! {:nav-handler (fn [path] ...) :path-exists? (fn [path] ...)})setup-routing! in my case(fn [path] (secretary/dispatch! path))
:nav-handler you are supposed to use I guesssecretary/dispatch!(defroute root-path "/" [] (swap! app-state assoc :view :index)) (defroute map-path "/posts" [] (swap! app-state assoc :view :posts))
:on-click #(accountant/navigate! "/posts")setup-routing! to my init so that websocket stuff doesn't affect it and seejs/console.log calls never hurts 😉failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/openpgp/dist/openpgp.js"]]}npm install --save openpgp
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
INTERNAL COMPILER ERROR.
Please report this problem.
null
Node(FUNCTION ): node_modules/openpgp/dist/openpgp.js:38406:70
SymmetricallyEncrypted.prototype.encrypt = async function (algo, key) {
Parent(CALL): node_modules/openpgp/dist/openpgp.js:38406:70
SymmetricallyEncrypted.prototype.encrypt = async function (algo, key) {
INTERNAL COMPILER ERROR. message is from Closure not shadow-cljs.openpgp.js:34964: ERROR - This code cannot be converted from ES6. Undecomposable expression: Please rewrite the yield or await as a separate statement.node_modules to babel. currently its only down when the file has import/export:js-options {:language-out :ecmascript-2017} which will skip the transpilationshadow-cljs --cli-info should do it[maven] com/google/guava/guava/20.0/guava-20.0.jar[com.google.guava/guava "25.1-jre"]:dependencies? I wonder how the old guava ends up on there[2018-08-20 10:43:41.614 - INFO] :shadow.build.npm/js-invalid-requires - {:requires [{:line 37, :column 17}]}
require("./foo/" + bar) type stuff[cognician/base "336" :exclusions [com.google.guava/guava]]Cannot read property 'cwd' of undefined:loader-mode :evalpnpm ?(shadow.cljs.devtools.api/find-resources-using-ns 'cljs.pprint) but its very basicshadow-cljs clj-repl or nrepldeps.edn or project.clj if you really have to➜ Manage git:(shadow-cljs) ✗ shadow-cljs browser-repl app shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Manage/shadow-cljs.edn cli version: 2.6.2 node: v10.8.0 shadow-cljs - connected to server ClassNotFoundException shadow.cljs.devtools.cli java.net.URLClassLoader.findClass (URLClassLoader.java:381)on the new version?
.m2 files or .shadow-cljs?CompilerException java.lang.RuntimeException: No such var: s/explain-data, compiling:
with code
(defn- value->spec-msg [specs->msg spec value]
"Check value with spec.
If fail return msg error."
(-> (s/explain-data spec value)
(get-in [:cljs.spec.alpha/problems 0 :via])
(last)
specs->msg))
But I have it in :require and it works in webbrowser
(ns services.form
(:require [cljs.spec.alpha :as s]
[reagent.core :as r]
[taoensso.timbre :as l]))
How can I use REPL cljs in Cursive in friendly way?goog.reflect. You can call (gr/sinkValue next) as the first thing in the function. it doesn't actually do anything besides telling the compiler that the next should be kept and not removed.CompilerException java.lang.RuntimeException: No such var: s/explain-data, compiling: pretty sure that you get this error when in a Clojure REPL(shadow/repl :your-build):app instead :node-test REPLNo application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.Oh but I see I can’t use node-test with cljs REPL ?
:node-test isn't really meant for REPL development since its supposed to exit after running your tests(shadow/node-repl) instead(shadow/node-repl)
To quit, type: :cljs/quit
=> [:selected :node-repl]
Loading test/services/form_test.cljs... repl/require failed { Error: ENOENT: no such file or directory, open '/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.test.env.js'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:348:35)
at global.SHADOW_IMPORT ([stdin]:45:15)
at Object.shadow$cljs$devtools$client$node$closure_import [as closure_import] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:33:4)
at Object.shadow$cljs$devtools$client$node$repl_require [as repl_require] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:61:7)
at shadow$cljs$devtools$client$node$process_message (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:122:6)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
at WebSocket.<anonymous> (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:159:12)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/node_modules/ws/lib/WebSocket.js:141:47)
errno: -2,
syscall: 'open',
code: 'ENOENT',
path:
'/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.test.env.js' }
Not so easy{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d7a4bfb6b3b8a0fab4bbbda497e5f9e3f9e4e4"}, :content ("[email protected]")} ok will try to update(shadow/node-repl)
To quit, type: :cljs/quit
=> [:selected :node-repl]
Loading src/services/form.cljs... done
Loading test/services/form_test.cljs... done
(-> {:names->value {:email ""
:password ""}
:names->validations {:email [::spec-email]
:password [::spec-password test-fn]}
:specs->msg {::spec-email "Typo? It doesn't look valid."
::spec-password "Password is required."}}
(form/init-form))
(node:9656) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
<eval>:1
form.init_form(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"names->value","names->value",-1214004968),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"email","email",1415816706),"",new cljs.core.Keyword(null,"password","password",417022471),""], null),new cljs.core.Keyword(null,"names->validations","names->validations",-1835037433),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"email","email",1415816706),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("cljs.user","spec-email","cljs.user/spec-email",1595736430)], null),new cljs.core.Keyword(null,"password","password",417022471),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("cljs.user","spec-password","cljs.user/spec-password",1742175166),cljs.user.test_fn], null)], null),new cljs.core.Keyword(null,"specs->msg","specs->msg",1137057203),new cljs.core.PersistentArrayM
ReferenceError: form is not defined
at <eval>:1:1
at Script.runInThisContext (vm.js:91:20)
at runInThisContext (vm.js:298:38)
at global.SHADOW_NODE_EVAL ([stdin]:74:30)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:25:16)
at /Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:30
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:91:16)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:13)
at shadow$cljs$devtools$client$node$process_message (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:116:6)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
shift + cmd + p to run code in REPL(in-ns 'whatever) or the REPL hotkeygoog.reflect. Its a shame the removal of unused args can't be turned off in the closure compiler to preserve arity!├── shadow-cljs.edn ├── src ├── test └── yarn.lockand according to the shadow-edn has:
:source-paths ["src" "test"]
:test {:target :browser-test
:test-dir "resources/public/js/test"
:ns-regexp "-test$"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}}
test.app.core_test.cljstest/app/core_test requires cljs.test https://github.com/thheller/shadow-cljs/issues/57#issuecomment-339673404:browser-test you run by opening ?test.app.core_test.cljs would be in test/test/app/core_test.cljs right?app.core-test in` test/app/core_test.cljs`shadow-cljs compile testshadow-cljs watch testshadow-cljs release test shadow-cljs watch test``watch is finemissing namespaces and what not meanswatch didn't finish compiling? which explains why the js/test.js doesn't exist and your tests will only run once it completes(ns app.core-test
(:require-macros [cljs.test :refer-macros [deftest testing is]])
(:require [cljs.test :as t]
[app.core :as core]))
(deftest fake-test
(testing "fake description"
(is (= 1 2))))
Uncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined= definedUse of undeclared Var app.core-test/deftest
npx shadow-cljs watch test and open . runs totally fine without warningsTesting app.core-test FAIL in (fake-test) (at http:438:85) fake description expected: (= 1 2) actual: (not (= 1 2)) Ran 1 tests containing 1 assertions. 1 failures, 0 errors.
:require-macros isn't necessary.(ns app.core-test
(:require [cljs.test :as t :refer [deftest testing is]]
[app.core :as core])):node-testrequire-macrosrefer-macros:require-macros with :refer-macros:require-macros + :refer:require + :require-macros:require + :refer is just fine too:require-macros + :refer-macros:refer of macros doesn't always work as it depends on the namespace that declares the macrocljs.testnode-sass currently.========= Running Tests =======================
SHADOW import error /home/user/project/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$semantic_ui_react$dist$es$index.js
/home/user/project/node_modules/semantic-ui-react/dist/es/index.js:2
import _Confirm from './addons/Confirm';
^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
:browser-test or :karma may be better suited:karma thenargs: ["shadow.test.karma.init"], in my karma.conf.jsapp.core-testUncaught ReferenceError: app is not defined...:ns-regexpshadow.test.karma/initargsUncaught ReferenceError: shadow is not defined... basePath: 'out/demo-karma' and files match your paths├── src ├── target ├── test
:output-to "target/ci.js":output-to?basePath: 'target',
// The file itself
files: ['ci.js'],:output-to is::output-to "target/cli.js"lein test 😉resources/public...CHROME_BIN=chromium or whatever it is I wonder how nicely this will play in CIdefmulti is basically defonce. you can only change the dispatch fn if its a reference to some other fn(defmulti foo bar) works but (defmulti foo (fn [x] ...)) doesn'tdeps.edn?
shadow-cljs - starting via "clojure" Error building classpath. nil java.lang.NullPointerException
clojure issuedeps.edn fileshadow-cljs in Cursive? I have a question 😄.nrepl-port in non-lein projectsRun configuration do you select?npx shadow-cljs server in the build-in terminal and leaving that runningshadow/stop-workerstart-worker is priivatewatch starts the workerunwatch or something? even just an aliasunwatch isn't exactly clear what it meansworker is since people technically only ever see watch(shadow/watch :the-build {:autobuild false}) still a watch? 😉compile which doesn't start a worker 😉worker is just more generic term for "process responsible for managing the build compilation"shadow/watch-compile-all! for compile-on-key-press vs compile-on-file-savewatch often is a bit over eager(shadow.cljs.devtools.api/watch-compile-all!) to the REPL on keypressclojure.main REPL with -m shadow.cursive-replclojure -A:dev:tree -m shadow.cljs.devtools.cli servernrepl this is also valid clojure -A:dev:test -m nrepl.cmdline (does not end up in shadow.user though--middleware I guess, so I am not documenting that one 😄Exception starting REPL: java.lang.ArithmeticException: integer overflowclj -m shadow.cursive-repl should just work (+ whatever aliases you need of course)deps.edn support. not on EAP at the moment.repl and nrepl-select?repl delegates to nrepl-select when connected via nrepl.nrepl-select just skips the check if you are in nrepl if you know you are in nreplrepl since it also works for socket repl and just looks better 😉watch-compile-all! does not work if I am not watching?watch-compile-all! 😄(shadow/watch :the-build {:autobuild false}) for nowstart-worker make sense?watch-compile-all! is also meant for force-triggering a compilation for builds that may be stuck(shadow/watch :script {:autobuild false})(shadow/nrepl-select :app) from a different nrepl that’s running from the same app? or do you have to use the shadow nrepl to call that? can the shadow nrepl replace clojure.tools.nrepl ?nrepl-select ?:lein or :deps if you need to:deps?pack as well for the same reason and I am thinking of adding an Azure pack target for my use case: https://github.com/juxt/pack.alpha/issues/18npm deps and not something I want to introduce to CLJS. its already kind of bad that CLJS can't easily consume most npm deps like shadow-cljs but I do hope that they'll catch up eventually.:resolve hooks are really a last resort option and should be used very rarely:npm-deps you can declare in deps.cljs which shadow-cljs supports and will install on startup. CLJS will to when configured to do so.npm for use by JS is probably never going to be easy:advancednpm for hours but I'd rather not 😉:npm-deps in deps.cljs, I had no idea that was possible. That may actually be exactly what I need. Thanks for pointing that out!.default issue is a bit annoying. its the closure compiler doing that and unfortunately breaks many npm packages. and its a wontfix 😞 https://github.com/google/closure-compiler/issues/2971tools.deps isn't any different than lein when it comes to what CLJS doesvar buffer = require('buffer')
this becomes
module$buffer.defaultand I get ReferenceError: module$buffer is not defined
:npm-deps in CLJS is rather unreliable stillbuffer is also usually a built-in node package so it requires the node-libs-browser shims that webpack also uses:target :nodejs or so?:simple I "meant" that for .cljs sources(:require ["whatever" :as x]) just generates a require("whatever") callrequirerequirerequire("buffer") is turned into module$buffer at all:npm-deps confuses it:npm-deps false and see if that works:module-type for each and every dependency.:foreign-libs ever. they won't work.Caused by: clojure.lang.ExceptionInfo: No such namespace: web-audio-api, could not locate web_audio_api.cljs, web_audio_api.cljc, or JavaScript source providing "web-audio-api"
node_modules/web-audio-api exist?{:file "node_modules/web-audio-api/index.js"
:provides ["web-audio-api"]
:module-type :commonjs}
it will go awayrequire("web-audio-api"). that is all. nothing else.:npm-deps false then it compiles, just again ReferenceError: module$buffer is not defined:foreign-libs are prepended to the compiled code as-is!requirerequire and let node figure it out:language-in :es6 ?{ :source-paths ["src/clj" "src/cljc" "src/cljs"]
:dependencies [[reagent "0.8.1"]]
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [my-ns.main]}}}}}
In one of the file I'm requiring reagent like so:
(ns my-ns.main (:require [reagent.core :as r]))when I try to build this I got such message: The required namespace "reagent.core" is not available, it was required by Should I invoke some command to install it? Or maybe I should install it by lein project? Thanks in advance!
lein run -m shadow.cljs.devtools.cli compile app
lein to run the command you need to add the dependency to project.cljshadow-cljs compile app:source-paths and :dependencies in shadow-cljs.edn don't matter if you use leinlein will only use project.cljshadow-cljs.edn makes that lein deps are usedshadow-cljs command itself and not lein@cljs-oss/module-deps": "^1.1.1"Error: Cannot find module '@cljs-oss/module-deps' don't know who's asking for this
then Error: Could not locate the bindings file. Tried:... for node-speakerproject.clj and shadow-cljs.edn and run the same code using both to test itnode targets: I am trying to use :after-load but it does not seem to get triggerednode process terminal:require macros looks. Also in shadow we can write event.target.name while in lein we can not (as i know)ns form. thats it.npm support isn't standard:require code wouldn’t work with lein:require code part?(:require ["some-npm-dep" :as x]) reliably(:require [any.other.cljs.ns :as x]) will work just finedeps.edn. How to determine which CLJSJS will / wouldn’t work?lein for that part..clj files could just be macros or utility functions, those are fine for shadow-cljsdeps.edn instead of leindeps.edn for pure CLJS development though due to the extra features deps.edn offer (eg. git-deps):npm-deps as the way since the last releasenpm dependencies, does the Webpack method would work there? seems like I would still need to declare transitive :npm-deps somehow:npm-depsnode script or a browser JS - make sense, thank you!yarn devcards I get the error that the build for app isn't running and well devcards doesn't work.
Anyone have an idea about this?{:main {:entries [...]}}defcard I'm using defndefcard doesn't even create a function(ns sniff.devcards
(:require [devcards.core :refer-macros (defcard)]
[devcards.core :as dc]
[reagent.core :as r]))
(def x 10)
(defcard simple-component [x]
[:div
[:p (str "I am a component!" x) ]
[:p.someclass
"I have " [:strong "bold"]
[:span {:style {:color "red"}} " and red "] "text."]])
(defn ^:export main
[]
(dc/start-devcard-ui!))
[x] is definitely out of placeshadow-cljs: load JS <name>but he HTML on the page is not changed. When I refresh whole page I see the changes. Any tip what is going on? Or maybe where in shadow JS code I could look to debug it
source-map-support install is not required. shadow-cljs already depends on that and ensures that it is installed.npm install though am I right?npx create-cljs-project foo might be useful. skips the yarn init + yarn add callsyarn create cljs-project foo also worksnpm install?npm install shadow-cljssource-map-support, node-libs-browser, ws, etccreate-cljs-project a new thing? since which version?:after-load function you just added via the REPL(your.app/render) and bind it to a keyshadow-cljs does not have rivalsshadow-cljs the best option right now, plus the possibility to ask you a question here is also extremely niceyarn create-cljs-project cursive-shadow-cljs does not work but the npx version doesyarn does not do project resolution from npmyarn has a special create command which is kind of a gimmickyarn create cljs-project loads the create-cljs-project package and calls itnpx just calls whatever:devtools {:http-port 8080 :http-root "public" :proxy-url ""} that does not exist on the file system will be requested from the configured proxy -> :proxy-url isn't documented:devtools-url is the other proxy-related one but for the other direction. ie. a proxy in front of the shadow-cljs dev servershadow in name? 🙂1.10.339server/start! fn mentioned there.missing instance means that no server was startednode_modules ? shadow-cljs as far as I know, doesn't do anything when it comes to installing npm pacakges from npm/git/wherevernpm i does it work?git:// as far as I remembernpm publishRan 2 tests containing 6 assertions. 0 failures, 0 errors.
shadow-cljs compile buildID, I just get a Build completed in the end.compile only compiles the test and does not run them? unless you set :autorun truerelease instead of compile?release and on completion launch node out-dir/tests.js in CI so that I can get the right exit codegit dep is not from you I assume? why are you using the git version?./scripts/prepublish.shprepublish.sh scriptnpm i etcsource-paths?dist/script.jsyaoman nor lein templates.edn I actually like it better than the lein oneproxy-url has proxy-port? or i can just specify "http://localhsot:8181" as proxy-url?:nrepl port from the command line?shadow-cljs.edn.shadow-cljs/nrepl.portThe required namespace "react" is not available, it was required by "reagent/core.cljs".:deps true in my shadow-cljs.edn, and :deps {reagent {:mvn/version "0.8.1"}} in my deps.edndeps.edn doesn't cover installing npm deps at all. npm install react react-dom create-react-class is required manually since reagent doesn't declare those :npm-deps.:npm/yarn or :npm/npm to specify the resolver.package.json and npm install already cover thatyarn also uses the same npm registry so it doesn't really make sense to differentiate between yarn and npm in the dep locationnpm install?deps.cljs and :npm-depsnpm.deps.ednnpm doesn't know about deps.edn:deps {"react" {:npm/version "v16"}} and lib B declares :deps {"react" {:npm/version "v15"}}npmnode_modules/libA/package.json["react" "v16"] node_modules/libB/package.json["react" "v15"] entry ./package.json {"dependencies":{"libA" "...", "libB": ".."}node_modules/libA doesn't exist though?npm install from the directory it was called from to generate node_modules^16.0.0 doesn't match ^15.0.0deps.edn issues. ask in #tools-deps what their plans arecomponentWillReceiveProps and componentWillUpdate are going to get deprecated and renamed with UNSAFE_ prefix. React libraries are going to get "doesn't work on my computer" storm soon.(let [my-fn ...] (js/my-fn ...))?js/history.replaceState or js/history.pushState(def history ..)?(and (relative? url)
(exists? navigate-fn))
(exists? ...) call(some? ...) works(some? navigate-fn)exists? is basically only for global constants yes:app and I have two aliases :dev and :production in my deps.edn:app into two (dev and prod) specifying the alias seems to take place outside the :builds value; on the same level actually.shadow-cljs -A:production release app{:deps
{reagent {:mvn/version "0.8.0"}
re-frame {:mvn/version "0.10.5"}
day8.re-frame/http-fx {:mvn/version "0.1.6"}
secretary {:mvn/version "1.2.3"}
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
proto-repl {:mvn/version "0.3.1"}
devcards {:mvn/version "0.2.5"}
binaryage/devtools {:mvn/version "0.9.10"}
day8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}}
:aliases
{:dev
{:extra-deps
{day8.re-frame/tracing-stubs {:mvn/version "0.5.1"}}}
:prod
{:extra-deps
{day8.re-frame/tracing {:mvn/version "0.5.1"}}}}}
Error building classpath. Could not transfer artifact thheller:shadow-cljs:jar:2.6.3 from/to clojars (): Range Not Satisfiable (416)cljthheller/shadow-cljs {:mvn/version "2.6.3"} to your :depsclj-stubs packages are starting to bug me ... I really dislike the entire conceptthheller/shadow-cljs {:mvn/version "2.6.3"} to your :deps2.6.4?shadow-cljs -A:dev watch app;clj ran successfully2.6.4
same error about being unable to transfer 2.6.3deps.edn pleaseclj -A:dev -m shadow.cljs.devtools.cli watch app pleaseException in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class or shadow/cljs/devtools/cli.clj on classpath.npm package is completely independent from all the clojure stuff.m2/repository/thheller/shadow-cljsday8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}}
thheller/shadow-cljs {:mvn/version "2.6.3"}}day8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}
thheller/shadow-cljs {:mvn/version "2.6.3"}}clj ran just fine$ clj and $ clojure failed after removing my ~/.m2 I thought they called the clojure bin in my /usr/bin/clojure I'm waiting for my yarn dev to finish now. It should work.clj -Sforce since you deleted files that it that would exist:output-dir, :output-to, :test-dir for :target: :browser :node-test browser-test. I mean i see paths like public/js, resources/public/js, resources/public/js/out and I am trying to solve the puzzle why so many paths. Should best practice be to use path in resources or not etc. Maybe not super important but I am trying to do some guideline.resources but many people do.js files into uberjars. that is easier with resources/publicresources directory typically is in lein.js filespublic directory via files/out/… and app to /public?vhosts/alias.foo.com/public vhosts/other.foo.com/publicresources/public directory via nginx?.js in the uberjar at allresources at all being "bad":output-dir "public/js"
But it is running. Also I restarted server and watch app.js file in the .html?deps.edn such as in https://gitlab.com/urbanslug/sniff$ CHROME_BIN=/usr/bin/chromium y test yarn run v1.9.2 $ karma start --single-run 28 08 2018 20:01:16.832:INFO [karma]: Karma v3.0.0 server started at 28 08 2018 20:01:16.834:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency 28 08 2018 20:01:16.839:INFO [launcher]: Starting browser ChromeHeadless 28 08 2018 20:01:17.119:INFO [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Connected on socket VQ5gfyizvjWfbb8bAAAA with id 10361789 HeadlessChrome 0.0.0 (Linux 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs) error Command failed with exit code 1. info Visit for documentation about this command.
target/test.js exist?karma (which I know very little of)$ y compile-tests
deps.edn?:dependencies [[cljs-ajax "0.7.3"]
[reagent "0.8.0"]
[re-frame "0.10.5"]
[day8.re-frame/http-fx "0.1.6"]
[secretary "1.2.3"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[proto-repl "0.3.1"]
[devcards "0.2.5"]
[binaryage/devtools "0.9.10"]
[day8.re-frame/re-frame-10x "0.3.3-react16"]
[day8.re-frame/tracing "0.5.1"]
;[day8.re-frame/tracing-stubs "0.5.1"]
]
;:deps true
karma. what is the issue here?:deps true and running shadow-cljs -A:dev compile test the tests somehow behave differently?CHROME_BIN=/usr/bin/chromium y test
CHROME_BIN=/usr/bin/chromium y test
karma?$ y compile-tests
deps.edn doesn't declare any :paths ["src"]:source-paths ["src" "test"] :deps true
:source-paths in shadow-cljs.edn are not used when :deps true is used:paths in deps.edn insteadshadow-cljs.edn so I couldn't have guessed itlein, clojure or its built-in launcherdeps.edn so its rather hard to debugnpm package itself is really just for starting. it does not else.npm installnpm link <libname>, I could theoretically copy over the files, but perhaps lift it, if the file was seen to be a symlink, otherwise keep the same behaviour.
https://github.com/thheller/shadow-cljs/blob/016c0c87241ba8bb3a5d753774c052c8661ac8ba/src/main/shadow/build/npm.clj#L431-L433.. and other relative path crap npm packages do.. and stuff but NOT follow links..java.nio.file.Path
Path resolve(Path other) Resolve the given path against this path. If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path. Otherwise this method considers this path to be a directory and resolves the given path against this path. In the simplest case, the given path does not have a root component, in which case this method joins the given path to this path and returns a resulting path that ends with the given path. Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified.
Path for everything. File really isn't all that great anymore.Path API are just annoying so meh 😛[2018-08-28 21:14:35.480 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/eth-lib/lib/bytes.js", :requires [{:line 9, :column 193}]}? Is it a bug in web3js or I am doing something wrong? I think it is connected with "web3": "^1.0.0-beta.35".(:require [clj-macros :refer [slurp]]
["web3" :as web3])
cause
The required namespace "clj-macros" is not available
While I have this file /src/clj_macros.clj which is (ns clj-macros … )
Why?:require-macros instead2.6.4SHADOW import error /Users/matt/Projects/cannabit/cannabit-pharma/app/cljs-runtime/app.server.js
/Users/matt/Projects/cannabit/cannabit-pharma/app/cljs-runtime/goog.object.object.js:427
if (obj !== null && key in obj) {
^
TypeError: Cannot use 'in' operator to search for 'path' in undefined
shadow-cljs check returns warnings about cljs 1.10shadow-cljs check returns warnings about cljs 1.10------ WARNING #33 ------------------------------------------------------------- File: ~/.m2/repository/degree9/featherscript/0.4.0-SNAPSHOT/featherscript-0.4.0-SNAPSHOT.jar!/feathers/channels.cljs:8:7 Property on never defined on app --------------------------------------------------------------------------------
app is a symbol for a runtime object(defn connection [app listener] (.on app "connection" listener))
app?(defn connection [^js app listener] ...)check is also for release buildsshadow-cljs compile server which compiles without issuesgoog.object/set(defn authentication [^js app]
(let [conf (obj/get app "auth")
path (obj/get conf "path")
app (auth/configure app conf)]
(auth/service app path)))
(prn app)auth prop?shadow-cljs did you maybe upgrade all your other npm deps as well?node --inspect-brk your.js2.4.17 but not 2.6.4 so I'm putting my money on other updated npm deps which broke stuffapp really has the properties you expect it to have java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType when using shadow-cljs as a libraryapp still has all the properties you expect? I know its easy to suspect shadow-cljs doing something wrong (and it might) but its just as likely that you accidentally upgraded something else and app just isn't what it used to be anymore?[:did-not-find some.namespace] for namespaces that are part of the build?in-ns before require might do this?in-ns a ns that wasn't compiled yet(shadow/watch :browser {:autobuild false}) so that it doesn’t always recompile whenever I tab to the browser, and then evaluating blocks or running “Load file in REPL” from intelliJ:did-not-find is a placeholder. I need to check what the standard CLJS REPL does in this place.in-ns calls:autobuild false doesn't recompile on file change but the file change still invalidates the file so that it will be recompiledin-ns should be the stepsload file in REPL your namespacein-ns it should failload file in REPL, it appears to work — Loading cljs/src/spark_web/views/feedback.cljs... donein-nswatch and REPL really don't play well together sometimeswatch) to compile such that the browser will connect to the shadow server for a REPL?shadow-cljs browser-repl but that probably has the same issuewatch invalidating the files is just a bit overeagerload-file and then save the fileno source by id: [:shadow.build.classpath/resource "shadow_ex/core.cljs"]
{:id [:shadow.build.classpath/resource "shadow_ex/core.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "shadow_ex/core.cljs"]
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.data/get-source-by-id (data.clj:147)
shadow.build.data/get-source-by-id (data.clj:144)
shadow.build.compiler/remove-dead-js-deps/remove-fn--14770/fn--14771 (compiler.clj:873)
clojure.core/complement/fn--5391 (core.clj:1433)
clojure.core/filter/fn--5614 (core.clj:2809)
clojure.lang.LazySeq.sval (LazySeq.java:40)
compile usually adds in again:did-not-find ... error, a few seconds later a REPL command timed out. message shows up:did-not-find would cause the command to stop/fail immediately?:did-not-find thing is really just a placeholder because I was undecided on how to deal with the situation. wanted to check what CLJS did but somehow forgot about it.app has the properties you expect it to have? that is the first and only question you should answer.app isn't what you expect it to beCannot read property 'lib' of undefined when shadow requires it — partway into the file, a variable is undefined when it shouldn’t be. I can require the unminified version without any issues, so I guess it’s something to do with their minificationterser for minification(require '["auth0-js" :as x]) (x/???)?(shadow/compile :browser), and then opening the pageshadow/releaseshadow-cljs browser-repl and the requirecompilecreateCommonjsModule(function(module, exports) {(undefined.algo = {})) is in the transformed code but not in the sourcecore = createCommonjsModule(function(module, exports) {
var CryptoJS;
module.exports = ((CryptoJS =
CryptoJS ||
(function(Math, undefined) {
var create =
Object.create ||
(function() {
function F() {}
return function(obj) {
var subtype;
return (
(F.prototype = obj),
(subtype = new F()),
(F.prototype = null),
subtype
);
};
})();
undefined = {};
var C_lib = (undefined.lib = {}),
Base = (C_lib.Base = {
extend: function(overrides) {function(Math, undefined) {undefined is even a legal binding name but this is JS so I expect nothing less I guess:clojure-defines in a build will be used for both :dev and :release?:js-options {:variable-renaming :local}undefinedfunction(a,b) { so the undefined is gone and nothing left to get confused aboutundefined there:js-options setting works for memodule.exports = ((CryptoJS =
CryptoJS ||
(function(Math, undefined) {/**
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined) { -Sdeps '{:mvn/local-repo ".m2/repository"}':local-repo ".m2/repo..." in shadow-cljs.edndeps.edn and want it to use that? then there is no way other than calling clj -Sdeps '{:mvn/local-repo ".m2/repository"}' shadow.cljs.devtools.cli release app$HOME/.m2/repository but I want it to be ./m2/repositorycljclj can't take that path as a var imo it shoulddeps.edn anyways I'd suggest just using clj directly.shadow-cljsshadow-cljs with clj -m shadow.cljs.devtools.cliclj -m shadow.cljs.devtools.cli release appdeps.ednFile: jar:file:/Users/wilkerlucio/.m2/repository/fulcrologic/fulcro/2.6.0/fulcro-2.6.0.jar!/fulcro/client/primitives.cljc
failed to require macro-ns "fulcro.client.primitives", it was required by "fulcro.client.primitives"
{:tag :shadow.build.macros/macro-load, :macro-ns fulcro.client.primitives, :ns-info {:rename-macros nil, :renames {}, :meta {:file "fulcro/client/primitives.cljc", :line 1, :column 5, :end-line 1, :end-column 29}, :ns-aliases {clojure.core.async cljs.core.async, clojure.stacktrace cljs.stacktrace, clojure.spec.alpha cljs.spec.alpha}, :use-macros nil, :excludes #{var? key replace force}, :name fulcro.client.primitives, :op :ns, :env {:ns {:name cljs.user}, :context :statement, :locals {}, :fn-scope [], :js-globals {console {:name console}, location {:name location}, escape {:name escape}, screen {:name screen}, global {:name global}, process {:name process}, require {:name require}, alert {:name alert}, history {:name history}, window {:name window}, module {:name module}, exports {:name exports}, document {:name document}, navigator {:name navigator}, unescape {:name unescape}}, :line 1, :column 1}, :imports nil, :requires {t cognitect.transit, set clojure.set, clojure.spec.alpha cljs.spec.alpha, gstring goog.string, log fulcro.logging, targeting fulcro.client.impl.data-targeting, fulcro.transit fulcro.transit, clojure.zip clojure.zip, p fulcro.client.impl.protocols, fulcro.client.impl.parser fulcro.client.impl.parser, fulcro.logging fulcro.logging, goog.string goog.string, async cljs.core.async, cljs.core cljs.core, gobj goog.object, goog goog, goog.object goog.object, fulcro.tempid fulcro.tempid, cljsjs.react cljsjs.react, cljs.core.async cljs.core.async, fulcro-css.css-implementation fulcro-css.css-implementation, fulcro.util fulcro.util, cognitect.transit cognitect.transit, hist fulcro.history, clojure.set clojure.set, clojure.core.async cljs.core.async, util fulcro.util, s cljs.spec.alpha, parser fulcro.client.impl.parser, fulcro-css.css-protocols fulcro-css.css-protocols, transit fulcro.transit, str clojure.string, zip clojure.zip, clojure.string clojure.string, cljs.spec.alpha cljs.spec.alpha, clojure.walk clojure.walk, tempid fulcro.tempid, fulcro.client.impl.data-targeting fulcro.client.impl.data-targeting, fulcro.history fulcro.history, fulcro.client.impl.protocols fulcro.client.impl.protocols}, :seen #{:require :require-macros}, :uses {prewalk clojure.walk}, :require-macros {fulcro.client.primitives fulcro.client.primitives, cljs.core cljs.core}, :form (ns fulcro.client.primitives (:require-macros fulcro.client.primitives) (:refer-clojure :exclude [var? key replace force]) (:require [goog.string :as gstring] [cljsjs.react] [goog.object :as gobj] fulcro-css.css-protocols fulcro-css.css-implementation [clojure.core.async :as async] [clojure.set :as set] [fulcro.history :as hist] [fulcro.logging :as log] [fulcro.tempid :as tempid] [fulcro.transit :as transit] [clojure.zip :as zip] [fulcro.client.impl.data-targeting :as targeting] [fulcro.client.impl.protocols :as p] [fulcro.client.impl.parser :as parser] [fulcro.util :as util] [clojure.walk :refer [prewalk]] [clojure.string :as str] [clojure.spec.alpha :as s] [cognitect.transit :as t])), :flags {:require-macros #{}, :require #{}}, :js-deps {}, :deps [goog cljs.core goog.string cljsjs.react goog.object fulcro-css.css-protocols fulcro-css.css-implementation cljs.core.async clojure.set fulcro.history fulcro.logging fulcro.tempid fulcro.transit clojure.zip fulcro.client.impl.data-targeting fulcro.client.impl.protocols fulcro.client.impl.parser fulcro.util clojure.walk clojure.string cljs.spec.alpha cognitect.transit]}}
ExceptionInfo: failed to require macro-ns "fulcro.client.primitives", it was required by "fulcro.client.primitives".shadow-cljs, but I can't seem to figure how to get this project to compile againshadow-cljs clj-repl and then (require 'fulcro.client.primitives)Wilker-Nu:fulcro-inspect wilkerlucio$ shadow-cljs clj-repl shadow-cljs - config: /Users/wilkerlucio/Development/third-part/fulcro-inspect/shadow-cljs.edn cli version: 2.6.4 node: v8.11.2 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - starting ... Aug 31, 2018 8:22:29 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Aug 31, 2018 8:22:29 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :devcards available at shadow-cljs - HTTP server for :test-dev available at shadow-cljs - server version: 2.6.4 shadow-cljs - server running at shadow-cljs - socket REPL running on port 61362 shadow-cljs - nREPL server started on port 63104 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [1:0]~shadow.user=> (require 'fulcro.client.primitives) CompilerException java.io.FileNotFoundException: Could not locate clojure/future__init.class or clojure/future.clj on classpath., compiling:(fulcro/history.cljc:1:1)
2.6.5. should be fixed there.:source-paths for different builds? I am thinking about that in context of /checkouts to develop a library. I would like to run app with my checkouts version and with public version.deps.edn or project.clj then yes but not with shadow-cljs itself:local/root to point to a dep, this dep has some code that contains warnings and shadow is preventing code reload, shouldn't it ignore warnings outside the source paths?-A:dev some dependencies don't load[nREPL] Establishing direct connection to localhost:36749 ... [nREPL] Direct connection to localhost:36749 established error in process filter: nrepl-send-sync-request: Sync nREPL request timed out (op classpath) error in process filter: Sync nREPL request timed out (op classpath)/different port number depending on which repl type I choose though./ So I start again but this time I chose the repl-type as shadow-cljs. - [prompt] Select a clojurescipt repl type * shadow * shadow-select * custom - I go with shadow [prompt] select shadow-cljs build I choose
app
in my browser I get "shadow-cljs - Stale Client! You are not using the latest compilation output!"
When I make a change I get:
[:app] Compiling ... [:app] Build failure: The required namespace "day8.re-frame.tracing" is not available, it was required by...this was under the alias
dev in my deps.edncider-clojure-cli-global-optionsC-u M-x cider-jack-in-A:devcider-clojure-cli-global-options in my project((clojure-mode (cider-clojure-cli-global-options . "-A:server:dev")))is what I have in my
.dir-locals.el at the root of my project2.6.6. I accidentally included a dev version of the build reports JS and not the actual release version.2.6.6 release should allow you to use npm link. I didn't test it thought so please do.:hud false on a project but that didn't worked, I restarted the compilation but the HUD was still showing up:hud :all :errors-only :off?:hud #{:progress :errors}:hud true | false | #{:compiling :errors :warnings}shadow-cljs watch app and then run node target/app.js. Next, on another window, I ran shadow-cljs cljs-repl app, but I can't load the cljs namespace?shadow-cljs - connected to server [1:1]~cljs.user=> (+ 3 3) [2:1]~cljs.user=> (require '[myapp.core :as mc])
[3:1]~cljs.user=> mc nil
(+ 3 3) returned 6mc is not valid. :as does not create a local variablemc/your-thing:as works as a variable is an exception for JS namespaces only[7:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
^
TypeError: Cannot read property 'call' of undefined
lumo anyway let me start on a minimal code and send you the output(ns myapp.core) (defn test1 [] (println "test1")) (defn main! [] (println "entry"))
shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 3 3)
6
[1:1]~cljs.user=> (require '[myapp.core])
nil
[1:1]~cljs.user=> myapp.core/main)
nil
[1:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
^
TypeError: Cannot read property 'call' of undefined
main!cljs-repl and node-repl?println results appear in node-repl not in cljs-replnode-repl is standalone and not specific to any buildcljs-repl is part if your build, started and managed by younode-replnode-repl output is currently only going to where the node-repl was startednode-repl window just now. Don't know what I did, but it's not appearing inside node-repl window now. cljs-repl works thoughshadow-cljs watch and it works nownode-repl and restarted it, the output disappearednode-repl isn't stopped if you leave itnode-repl the output disappeared completelyshadow-cljs clj-repl (shadow/stop-worker :node-repl) to stop it(shadow/node-repl) from the clj-replnode-repl when leaving itnode-repl is preferred to cljs-repl?node-repl is recommended if you just want to explore at the replnode-repl you can re-direct the output to REPL.m2 and .boot directories and sure enough, I can no longer compile 😢boot show -pclojure.lang.Symbol cannot be cast to java.lang.Number[[thheller/shadow-cljs "2.6.4"]]start-server!shadow-cljs clj-repl command( "cljs/core.cljs")ClassNotFoundException shadow.cljs.devtools.cli java.net.URLClassLoader.findClass (URLClassLoader.java:381)boot shadow/servershadow-cljs clj-repl doesn't work?node_modules/... but someplace elseshadow.cljs.devtools.cli namespace is required1.9.946 ends up on the classpath BEFORE 1.10.339( "cljs/user.cljs") is probably the easiest way to verify if the version is correct(shadow/cljs.devtools.api/watch-compile! :the-build-id) or (shadow.cljs.devtools.api/watch-compile-all!)watch-compile! does what I was hoping[:client] Compiling ... The required namespace "shadow.cljs.devtools.client.console" is not available.
(shadow.cljs.devtools.api/find-resources-using-ns 'shadow.cljs.devtools.client.console)( "shadow/build.clj") or so( "shadow/cljs/devtools/client/console.cljs")?.shadow-cljs directory. maybe some bad cache?(System/getenv "boot.class.path")boot.class.path, shadow.class.path and java.class.pathSystem/getProperty.clj(s|c) files. you never ship compiled CLJS code to other CLJS users. so any method of producing/publishing a jar file it valid you do not need shadow-cljs for that, although it will likely get support for it at some point.lein.Uncaught ReferenceError: module$react is not definedshadow-cljs you just npm install the-thing and (:require ["the-thing" :as x])npx create-cljs-project test-project cd test-project npm install your-thingleinbyte[] responses, than enable NIO in some servers------ ERROR ------------------------------------------------------------------- 09:29:53 cljs | File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/components/constructors.cljs 09:29:53 cljs | Exception: No namespace: compute.ui-frontend.components.constructors foundThe
constructors ns follows the two ns pattern for exposing macros - there's a constructors.clj and a constructors.cljs. I had forgotten to remove a reader conditional from my constructors.clj file which caused that error. Once I fixed it the error went away. If I add the misplaced reader conditional back in after the initial compile, I get a much better error:
09:30:43 cljs | [2018-09-04 09:30:43.832 - WARNING] :shadow.cljs.devtools.server.reload-macros/macro-reload-ex - {:ns-sym compute.ui-frontend.components.constructors}
09:30:43 cljs | CompilerException java.lang.RuntimeException: Conditional read not allowed, compiling:(compute/ui_frontend/components/constructors.clj:9:3)
antd react package from NPM or https://github.com/priornix/antizer which is a clojurescript libtest.check/defspec with the default :runner-ns shadow.test.browser. the workaround is easy, i just wrote a custom runner that calls clojure.test/run-tests in start, but curious if im missing something or what other solutions may be out therecreate-react-class, which is a helper library that lets you create components using a function instead of es6 classescreate-react-class and that looks more comfortable for cljsclojure.test/run-tests not cljs.test/run-tests?clojure.test/deftest and one clojure.test.check.clojure-test/defspec defined in test/some-test, and originally i was trying to use the default runner namespace (i.e. shadow.test.browser) with the following build config:
:tests
{:target :browser-test
:test-dir "target/test"
:devtools {...}
when i built and ran the tests, it would ignore the defspec test and only run the deftest. If i called clojure.test.check/quick-check directly within a deftest, it would run and work fine, but forfeit the test.check reporting line.
adding a custom :runner-ns to the build config fixed the problem, where start looks like this:
(ns runner-main
(:require [clojure.test :as t]
[some-test]))
(defn start []
(t/run-tests `some-test))
... ;; trivial stop and init
let me know if this helps, happy to provide more info:browser-test isn't meant to run clojure code(ns ^:dev/always the-runner)run-tests is a macro that need to be recompiledshadow.test.browser thing works by hacking the deftest macro so it doesn't have to use the macro to actually run the testsdefspec thing and therefore can only "discover" the extra tests in the macrodeftest hack and just use the macro after alljava.lang.Exception: Unable to resolve spec: :clojure.core.specs.alpha/args+body clojure.lang.ExceptionInfo: Unable to resolve spec: :clojure.core.specs.alpha/args+body
(ns cljsjs.antd (:require ["antd" :as antd])) (js/goog.exportSymbol "antd" antd)and npm installed antd. but the value of
antd in that namespace is just coming up as nil. Anyone know what might be going on here?shadow-cljs browser-repl and try (require '["antd" :as x]) xYou are using a whole package of antd, please use to reduce app bundle size.and a repl timeout
[0:0]~cljs.user=> x
#js {:Affix #object[Affix], :Anchor #object[Anchor], :AutoComplete #object[AutoComplete], :Alert #object[Alert], :Avatar #object[Avatar], :BackTop #object[BackTop], :Badge #object[Badge], :Breadcrumb #object[Breadcrumb], :Button #object[Button], :Calendar #object[Calendar], :Card #object[Card], :Collapse #object[Collapse], :Carousel #object[Carousel], :Cascader #object[Cascader], :Checkbox #object[Checkbox], :Col #object[Col], :DatePicker #object[PickerWrapper], :Divider #object[Function], :Dropdown #object[Dropdown], :Drawer #object[Drawer], :Form #object[Form], :Icon #object[global], :Input #object[Input], :InputNumber #object[InputNumber], :Layout #object[Adapter], :List #object[List], :LocaleProvider #object[LocaleProvider], :message #js {:open #object[open], :config #object[config], :destroy #object[destroy], :success #object[Function], :info #object[Function], :warning #object[Function], :error #object[Function], :loading #object[Function], :warn #object[Function]}, :Menu #object[Menu], :Modal #object[Modal], :notification #js {:open #object[open], :close #object[close], :config #object[config], :destroy #object[destroy], :success #object[Function], :info #object[Function], :warning #object[Function], :error #object[Function], :warn #object[Function]}, :Pagination #object[Pagination], :Popconfirm #object[Popconfirm], :Popover #object[Popover], :Progress #object[Progress], :Radio #object[Radio], :Rate #object[Rate], :Row #object[Row], :Select #object[Select], :Skeleton #object[Skeleton], :Slider #object[Slider], :Spin #object[Spin], :Steps #object[Steps], :Switch #object[Switch], :Table #object[Table], :Transfer #object[Transfer], :Tree #object[Tree], :TreeSelect #object[TreeSelect], :Tabs #object[Tabs], :Tag #object[Tag], :TimePicker #object[TimePicker], :Timeline #object[Timeline], :Tooltip #object[Tooltip], :Mention #object[Mention], :Upload #object[Upload], :version "3.9.1"}
shadow.js.js:87 shadow-cljs - failed to load module$node_modules$fbjs$lib$UnicodeBidi shadow.js.jsRequire @ shadow.js.js:87 shadow$provide.module$node_modules$fbjs$lib$UnicodeBidiService @ UnicodeBidiService.js:46 shadow.js.jsRequire @ shadow.js.js:85 shadow$provide.module$node_modules$draft_js$lib$EditorBidiService @ EditorBidiService.js:18 shadow.js.jsRequire @ shadow.js.js:85 ... shadow.js.jsRequire @ shadow.js.js:87 shadow$provide.module$node_modules$antd$lib$index @ index.js:485 shadow.js.jsRequire @ shadow.js.js:85 shadow.js.require @ shadow.js.js:111 (anonymous) @ cljsjs.antd.js:3 shadow.js.js:87 shadow-cljs - failed to load module$node_modules$antd$lib$indexerrors in js console
antd doesn't existantdantd fine just a few days ago. which version are you using?[cljsjs/antd "3.8.0-0"]
:version "3.9.1"<meta charset="UTF-8"> in your HTML (or the http header if you control those)antizer and rather import only what you need from antd directly'react.createElement for :create-element but it complains that ReferenceError: react is not defined(ns your.thing (:require ["react" :as react])) (defn create-element [...] (react/createElement ...))your.thing/create-element. Closure will optimize the extra wrapper fn away(def create-element react/createElement) if you don't care about the wrapping partfailed to require :target :browser-test for build :test
CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defelem in this context, compiling:(hiccup/page.clj:20:1)
clojure.lang.Compiler.analyze (Compiler.java:6792)
clojure.lang.Compiler.analyze (Compiler.java:6729)
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3813)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7005) clojure.lang.Compiler.analyze (Compiler.java:6773)
clojure.lang.Compiler.analyze (Compiler.java:6729)
clojure.lang.Compiler.eval (Compiler.java:7066)
clojure.lang.Compiler.load (Compiler.java:7514)
clojure.lang.RT.loadResourceScript (RT.java:379)
clojure.lang.RT.loadResourceScript (RT.java:370)
clojure.lang.RT.load (RT.java:460)
clojure.lang.RT.load (RT.java:426)
clojure.core/load/fn--6548 (core.clj:6046)
clojure.core/load (core.clj:6045)
clojure.core/load (core.clj:6029)
clojure.core/load-one (core.clj:5848)
clojure.core/load-one (core.clj:5843)
clojure.core/load-lib/fn--6493 (core.clj:5888)
clojure.core/load-lib (core.clj:5887)
clojure.core/load-lib (core.clj:5868)
clojure.core/apply (core.clj:659)
clojure.core/load-libs (core.clj:5925)
clojure.core/load-libs (core.clj:5909)
clojure.core/apply (core.clj:659)
clojure.core/require (core.clj:5947)
clojure.core/require (core.clj:5947)
shadow.build.targets.browser-test/eval91055/loading--6434--auto----91056 (browser_test.clj:1)
shadow.build.targets.browser-test/eval91055 (browser_test.clj:1)
shadow.build.targets.browser-test/eval91055 (browser_test.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7062)
clojure.lang.Compiler.eval (Compiler.java:7051)
clojure.lang.Compiler.load (Compiler.java:7514)
when trying to use browser-test, when I add hiccup it works again. So maybe you did some deps cleanup?npx shadow-cljs watch test
hiccup namespace in another thread but due to how Clojure works the namespace will be immediately availablens.(:require [hiccup.core ...]) and clojure sees that the ns is already loadeddefelem but it isn't loaded yet and boom:node-test target how can I get the node process to connect to my REPL?:node-script target that requires all the test namespaces so that they are compiled. Not ideal I know, maybe @thheller has a better idea:node-test disables all devtools since it supposed to exit after running the tests since we need the exit code for CI. is it not sufficient if you just use node-repl and manually load whichever test you are working on/want to run?node-repl compiling everything on the classpath independently? I think that is the problem I have noticedrequire it(ns my.registry.repl
(:require [cljs.spec.alpha :as s]
;; so that we have the test compiled in the REPL
[my.registry-test]
[my.registry.aws-test]
[my.registry.azure-test]))
node-repl compiles everything independently from the entry point then it should be goodns before anything can be usednode-test to preload that particular one ns would be convenient 😉:browser-test target, if I use a custom runner-ns do I need to :require all of them test namespaces?cljs-test-display looks real nice and I was thinking about using it by default:module-hash-names true option for my build, looks like manifest.edn has the mapping to the output name, but how do I make index.html point to that specific js file?shadowcljs release main with the md5 hashed javascript, push it to S3 and use cloudfront to serve the assets. However, I am trying to get this working with both the index.html and css parts of the buildclj-run sounds good maybe?(defn release [server]
(shadow/release :my-build)
(-> (io/file "output-dir" "js" "manifest.edn")
(slurp)
(edn/read-string)
(generate-index-html))
(sh "build-my-css" ...)
(sh "rsync" "-arzt" "path/to/output-dir" server))make. Just read the manifest.edn and generate the index.html for it via whatever means you prefer?[2:1]~cljs.user=> (defmacro foo [] `(1 2 3)) #'cljs.user/foo [2:1]~cljs.user=> (foo) (1 2 3)
defmacro work in a cljs repl?(macroexpand '(foo)) actually worksbinding with shadow cljs?(defn foo [] (binding [x y] (shadow.cljs.devtools.api/compile :the-build))[:picture [:img {:src "some.jpg"}]][:picture [:img {:src (your.lib/get-path "some.jpg")}]][:picture [:source {:srcset (your.lib/get-path "some.jpg" :small) :media "..."}]] [:img {:src (your.lib/get-path "some.jpg")}]]get-path looks like(defn get-path [img-name img-variant] (goog.object/get js/myImages img-name (name img-variant)))myImages[:picture [:source "various responsive sizes"] [:source "the same thing again but fallback image format"] [:img "the image again which contains more metadata and fallback"]]
.sh file with a bunch of convert img.jpg other-image.jpgnpm i pts. Doing a naive (:require ["pts" :refer Pt]) gives me the following error:
--- node_modules/pts/dist/index.js:3828 This code cannot be converted from ES6. extending native class: Float32Array --- node_modules/pts/dist/index.js:4022 This code cannot be converted from ES6. extending native class: ArrayHow do I approach this? There's a minified version in dst that contains different non-convertible es6-code and an es5-version that's follows UMD from what I can see. Trying to require the es5-version gives me
No such namespace: Pt, could not locate Pt.cljs, Pt.cljc, or JavaScript source providing "Pt".:js-options {:language-out :ecmascript6} in your build configshadow.js.babel in the shadow global variable? i skimmed the docs and it said something about running babel yourself for things like jsx interop, but there's a bundled babel as well?(.. form (stroke "#abc") (fill "#def")) it tries to optimize to heavily. even if i type-hint form it can't infer the call to stroke and won't know what it returns, causing it to not find fill which has been obfuscated(.. form ^js (stroke "#abc") ^js (fill "#def"))... but this doesn't feel like a sensible thing to do:auto by default?(-> ^js form (.stroke "#abc") (.fill "#def") (.point whatever)) seems to work.. has a bug in that it doesn't propagate typehints properly-> is fine so use thatbabel is used to transform ES6 code from node_modules only.cljsjs.create-react-class OR let the library do that(js/goog.exportSymbol "createReactClass" create-react-class)(create-react-class #js {:render (fn [] (this-as this ...))})(reagent.core/as-element [your {:hiccup "stuff"}]) and that will return a react element(defn ^:export my-component [props] (r/as-element [...]))2.6.7 and run shadow-cljs server and open you can see the shadow-cljs UI preview I'm working ongoog.global.setTimeout etcgoog.global and there should be no problem?goog.global = this is the default(string/replace slur "goog.global=this" "goog.global={}")(update-in build-state [:output [:shadow.build.classpath/resource "goog/base.js"] :js] str/replace ... ...):compile-finish stage//iter.js
goog.iter.StopIteration = ('StopIteration' in goog.global) ?
// For script engines that support legacy iterators.
goog.global['StopIteration'] :
{message: 'StopIteration', stack: ''};
:source-paths to your config manually. otherwise no.lein or deps.edn works tooUncaught ReferenceError: clojure is not defined in var G__15382__$1 = (((G__15382 == null))?null:clojure.string.replace(G__15382,/[#\*_^\-\\[\]=>~]/,""));` and similar errors. Could someone point me in the right direction from here to make it work? Also, I don't know if building an npm module is even the right approach here, I'm just experimenting a bit.clojure.string(clojure.string/replace ...) directly or (str/replace ...) via an aliasclojure.string/replace directly, I didn't require itdeps.edn, you can use :local/root and point directly to the folder, this way you get source paths and depencies:closure.defines through shadow/release function API? I need staging and production release builds and cannot get my head around the configuration. Or is there some better way I do not see?export default class RotatedMarker extends Marker
https://github.com/verdie-g/react-leaflet-rotatedmarker/blob/master/src/RotatedMarker.jsx#L5:default because I get a shadow require error error but with :as I don't get the errorUncaught TypeError: Super expression must either be null or a function, not object
at _inherits (react-leaflet-rotatedmarker.js:26)
at react-leaflet-rotatedmarker.js:29
at Object.shadow$provide.module$node_modules$react_leaflet_rotatedmarker$lib$react_leaflet_rotatedmarker (react-leaflet-rotatedmarker.js:28)
at Object.shadow.js.jsRequire (shadow.js.js:85)
at Object.shadow.js.require (shadow.js.js:111)
at ken.utils.leaflet_map.js:4
Marker? it is not defined anywhere in that file?cleanclean" what does this even mean?react-leaflet marker is a react element not a classrm -rf target; rm -rf public/js;["react-leaflet-rotatedmarker" :default RotatedMarker]
replace all Marker calls with RotatedMarker
remove/comment out ["react-leaflet-rotatedmarker" :default RotatedMarker]
and replace all RotatedMarker calls with Marker
shadow-cljs recompiles reloads the page and it works as though I'm calling RotatedMarker
clean
then try again... rotation doesn't workreact-leaflet-rotatedmarkerRotatedMarker calls to Marker, rotation works in the dev serverMarker(:require ["react-leaflet" :refer [Marker]]
["react-leaflet-rotatedmarker" :default RotatedMarker])
[:> RotatedMarker {...}]
react-leaflet exports an object with many problems which look like they are supposed to be classesMap, MapComponent ...Marker is just an object(:require ["react-leaflet" :refer [Marker]]
;["react-leaflet-rotatedmarker" :default RotatedMarker]
)
[:> Marker {...}]
Marker is not a classnode to verify ...$ node
> require("react-leaflet")
ReferenceError: window is not defined
at /mnt/c/Users/thheller/code/shadow-cljs/node_modules/leaflet/dist/leaflet-src.js:230:17
at version (/mnt/c/Users/thheller/code/shadow-cljs/node_modules/leaflet/dist/leaflet-src.js:7:65)
>react-leaflet-rotatedmarker is what's weirdreact-leaflet-rotatedmarker was released"react-leaflet": "^2.0.1", and it expects "react-leaflet": "^1.7.8",npm package "react-leaflet-rotatedmarker" expected version ".shadow-cljs/builds(:require ["create-react-class" :as crc]) (def MyComponent (crc #js {:render (fn [] (this-as this ...))}))#js {:render ...} as the last arg to the gobj/extend callcreate-react-class is completely fine:target :npm-module and :runtime :browser. And I get this error from the consumer of this published npm module.node and the way reagent uses the React global won't work there. Didn't reagent switch to a proper require a while ago? are you on an ancient version?(js/goog.exportSymbol "React" react js/global) when (:require ["react" :as react])React from shadow-cljs can I ask a naive question? Is pulling in a third-party React component as simple as npm install react-super-cool-component and then (require ["react-super-cool-component" :as rscc])?:node-script target, and ran shadow-cljs watch app which compiles the app just fine ( it's a hello world ) but when i use node to run the compiled file:devtools {:enabled false} in your build configcider-connect and then call (shadow/node-repl)shadow-cljs node-repl and cider-connect(shadow/repl :node-repl)Error: ENOENT: no such file or directory, open '/Users/.shadow-cljs/builds/babel-worker/dev/out/cljs-runtime/goog.debug.error.js'
.shadow-cljs in any build universe I live in2.6.8. sorry about that..shadow-cljs/babel-worker/Users/.shadow-cljs in the error abovenode_modules as wellwatch and then cljs-repl appcljs-repl never had any readline support natively?(shadow/repl :app)?rlwraplein repl :connect for nowgoog.net.xmlhttp.js:175 return new XMLHttpRequest(); ReferenceError: XMLHttpRequest is not defined. Any idea how I can set something like global.XMLHttpRequest = require('node-http-xhr'); ?(ns my.xhr-shim (:require ["node-http-xhr" :as xhr])) (set! js/global.XMLHttpRequest xhr) and include that in your :main namespacerequire will then do what you'd expect.const {a, b} = someObject)a or b they come undefinedconst {svg, svgWidth, svgHeight, data} = settingsa = c.svg;
var d = ;
b = c.uk;
var e = c.data;c.svg and c.data are correct, but was supposed to be c.svgWidth and c.uk would be c.svgHeightsvg and data are correct, but svgWidth and svgHeight are not (got mangled to Am and uk respectively)obj.someVar to likely obj.a … but if the js exposes obj.someVar, you will obviously get undefined or null trying to access obj.a.obj["someVar"] will never change), or use the newer ^js typehintexport function renderPathomTrace(element, settingsSource) {
const settings = initTrace(element, settingsSource)
const {svg, svgWidth, svgHeight, data} = settings
console.log("set svg", svgWidth, svgHeight);:language-in and :language-out, but I tried some combinations without success:language-in and :language-out as :ecmascript-next:advanced but there are likely no externs for those names since no externs inference is done for JS codeexterns/your-build.txt and add svgWidth, svgHeight, svg one line eachshadow-cljs check your-build(shadow/nrepl-select :client_build) this send everything to the browser.(shadow/repl :app) to connect. Which works finejs/temp1
It's ok, but sometimes it would be quicker if in the browser console, I could just type:
shadow.eval('(some clojure-script)');externs go? root of the project, source root?defspec work in shadow? for some reason I don't see my tests reported...cljs.test would workcljs-test-runner:mainparallel-build? it’s listed in the user guide as unsupported:compiler-options {:parallel-build false}reset-env! cls followed by a future reference to cls (that’s not a deref):
https://github.com/roman01la/cljss/blob/master/src/cljss/builder.clj#L10-L19npm package "slate-react" expected version "
npm install isn't exactly deterministicnpm install again may produce different resultsdeps-check so see potential version conflicts and fail if there areSymbol is undefined in IE11?Symbol or is it a npm lib?Symbol and inject accordingly:language-out configured in your :js-options?{:app {:target :browser
:output-dir "resources/cognician/manage/js/"
:asset-path "/cognician/manage/js/"
:devtools {:loader-mode :eval
:ignore-warnings true}
:modules {:app {:entries [cognician.manage.app]}}
;; build env specific settings
:dev {:compiler-options {:ignore-warnings true}
:closure-defines {cognician.manage.DEBUG true
goog.DEBUG true}}
;; production
:release {:compiler-options {:infer-externs :auto
:source-maps true}}}}
js/Symbol in your CLJS:compiler-options {:rewrite-polyfills true}deps.edn shadow-cljs can't find the namespace I use for clj-run.:source-paths? and does the deps.edn have matching :paths?:source-paths are here. https://github.com/groundedSAGE/shadow-jam/blob/master/shadow-cljs.edn#L3:paths to deps.edn too:checkouts option which was useful for pointing to a local jar instead of a published mvn artifact. to do the equivalent in shadow do I just add the dir to the :source-paths config? i feel like I read somewhere that shadow-cljs cannot modify the classpath above/outside its root, but not sure if that’s right:source-paths to wherever. the rule for non-project files is only for node_modules:js-options {:resolve {"moment" false}}2.6.9.shadow-cljs run shadow.cljs.build-report app build-report.html i get a spec error when trying to compile spectershadow-cljs release app as well or just be build report?(multi-transform
[ATOM (multi-path
[:notebook-order (terminal-val notebook-order)]
[:notebooks (terminal #(merge-with into % notebooks))])]
root)
This replaces one key and merges in with another in a single mutation{:repl-sessions {1 {:tool-id 1 ...} 2 {:tool-id 2 ...}}(defn by-id [id] (fn [elt] (= (:id elt) id))) (setval [ATOM :uploads ALL (by-id (:id upload))] upload root)
{...
:builds
{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true}}}
shadow-cljs compile testThe tests run fine:
shadow-cljs - connected to server [:test] Compiling ... ========= Running Tests ======================= FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9) expected: (= 1 2) actual: (not (= 1 2)) Testing test.classify-test FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9) expected: (= 1 2) actual: (not (= 1 2)) Ran 2 tests containing 2 assertions. 1 failures, 0 errors. =============================================== [:test] Build completed. (27 files, 1 compiled, 0 warnings, 0.99s)But then the tests quit and don’t watch for changes. What does autorun do? Is there a way to run the tests when either the tests change or the functions they test change? Thanks
shadow-cljs compile test compiles once and exitsshadow-cljs watch test will do what you wantnode process to execute the testsbunyan in shadow-cljs and they have a logger object that has a .child methodshadow-cljs check complains about it, which is good^js?{:optimizations :advanced
:variable-renaming :off
:property-renaming :off
:source-map true}
no time for fiddling 😄^js a reader macro? maybe I am mistaken(let [the-sym (with-meta (gensym) {:tag 'js})] ...)(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(. ^js (deref laputa.event-store.logging/parent-logger)
(~'child (cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info")))))
(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(.child ^js (deref laputa.event-store.logging/parent-logger)
(cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info")))). may be loosing the meta(let [the-sym (with-meta 'child {:tag 'js})]...(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(laputa.event-store.logging/get-child-logger
(cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info"))))(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(laputa.event-store.logging/get-child-logger
(laputa.event-store.logging/self-ns-name)
(if ^boolean goog.DEBUG "debug" "info")))process.env.PGDATABASEjs/process.env.PGDATABASE will never be renamedprocess.env.PGDATABASEjs/check yes, I just checkedFile: /home/arichiardi/git/laputa/event-store/src/laputa/event_store/db/config.cljs:31:19 Property PGDATABASE never defined on process.env
process.env.PGDATABASEcheck after js/ was addedshadow-cljs server started in the monorepo root?├── cljs-template ├── commit-event-fn ├── continuous-delivery ├── dashboard ├── lerna.json ├── metrics-fn ├── package.json ├── query-events-fn ├── README.md ├── registry-fn ├── scrutinizer-fneach folder has a
shadow-cljs file, I was wondering if I could share the jvmpackages/shadow-cljs for examplesrc/main not in packages/... at allshadow-cljs, I could potentially include everyting in a big deps.edn + shadow-cljs.edn at some point...will seecljs.test instead of shadow.testct/run-all-tests instead of st/...(ns ^:dev/always ...) though since its a macro and must always be recompiled to pick up new tests:reload in a (require) but i still see:
Circular dependency detected: laputa.event-store.db -> laputa.event-store.db
defspec after switching to the cljs.test/run-all-tests:devtools {:repl-init-ns my.app while https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL says to use :nrepl {:init-ns my.repl}. Are these two the same thing or unrelated? Thanks!(defonce !results (atom nil))
(defn print-results [results]
(reset! !results results))
(cljs/eval-str
(cljs/empty-state)
"(def asdf 1)"
'visual-spec.eval-test
{:eval cljs/js-eval}
print-results)
:bootstrap-support build or just compile it once?boot/init on each reload of my code? or is it just called once and then I can keep calling compile-it?boot/init on each hot reload?(defonce compile-state-ref (env/default-compiler-env))watch it) then you probably only need to call boot/init once:module-loader true and then trying to bootstrap would be incompatible?shadow.cljs.bootstrap.browser, it immediately breaks all of my modules/assets/js/cljs-runtime/shadow.module.main.append.js:4 Uncaught (in promise) TypeError: Cannot read property 'env' of undefined
at eval (/assets/js/cljs-runtime/shadow.module.main.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:2188)
at loadPending (main.js:2957)
at main.js:2990
shadow.cljs.boostrap.env ns may have been moved[shadow.cljs.bootstrap.env] to the requires in my main module immediately fixed all of my modules:modules {:shared {:entries []}
:main {:entries [app.main] :depends-on #{:shared}}
:brand {:entries [app.templates.brand] :depends-on #{:shared}}}
ln -s ../assets/index.html inside target or what?app.main which is an spa router and 2 pages (home & todo)
:modules {:shared {}
:main {:entries [app.main]
:depends-on #{:home :todo}}
:home {:entries [app.pages.home]}
:todo {:entries [app.pages.todo]}}
however doing so yields two modules without deps, please specify which one is the default. but those 2 pages dont really depends on anything except rum. Am I missing something here? 🤔:home depends-on #{:main} as well as todo depends on #{:main}app.main will always be loaded and home and todo on demand. so they depend on :main(loader/load "extra") resolver only indicate loaded/failed status and does not return the module itself. (in webpack it is import(() => "./foo").then(foo => foo.default))resolve to get to a function you defined((resolve 'your.ns/foo) 1 2 3)(your.ns/foo 1 2 3)(-> (reader/read-string "{:foo 5
:bar [1 2 3]}")
(meta))
comes back as nil(require ...
[cljs.tools.reader :as reader])
?shadow-cljs release hides js/React from my code?
I use shdow-cljs to produce an npm-module, which is then consumed by a .js file, processed by Webpack (during a gatsby build run). When I shadow-cljs compile app then everything works just fine. However, when I do shadow-cljs release app instead then webpack fails with
> WebpackError: js/React is missing
(thrown from https://github.com/reagent-project/reagent/blob/v0.7.0/src/reagent/impl/util.cljs#L12)
Why? What can I do to fix it? (The .js file that requires my cljs-based npm module does import React) Thansk a lot!!!!
(Here is the code: https://github.com/jakubholynet?tab=repositories)(set! js/global.React react) with (:require ["react" :as react])release just nicely(defn page-index
{:export true
:gatsby/page "index"
:gatsby/graphql
"query IndexQuery {
site {
siteMetadata {
description
}
}
}"}
[props]
(r/as-element
[:h1 "hello world!"]))src/pages filescreatePages stuff would work but should be simple to hook up AFAICTThe required namespace is not available.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2557444b4844564a4b65464440564457"}, :content ("[email protected]")}2.5.1 to 2.6.9.2.0.144, but I don't have the logs from when it worked last.devcards.core_card isn't part of devcards itself? is that one of your sources?shadow-cljs clj-repl (shadow/find-resources-using-ns 'devcards.core_card) to figure out who is using thatshadow-cljs watch service I ran :Piggieback :service as well with no confirmation if that worked properly.
When I try to evaluate a form that uses reader conditionals (just :clj and :cljs) in a .cljc, I get “Conditional read not allowed”. Is this because :Piggieback is failing, or some other configuration issue?[2:1]~cljs.user=> #?(:cljs 1) 1
failed to require :target :browser-test for build :browser-tests CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defelem in this context, compiling:(hiccup/page.clj:20:1) clojure.lang.Compiler.analyze (Compiler.java:6792) clojure.lang.Compiler.analyze (Compiler.java:6729) clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3813) clojure.lang.Compiler.analyzeSeq (Compiler.java:7005)
RuntimeException: Unable to resolve symbol: defelem in this context clojure.lang.Util.runtimeException (Util.java:221) clojure.lang.Compiler.resolveIn (Compiler.java:7299) clojure.lang.Compiler.resolve (Compiler.java:7243)
2.6.10 which should fix this now. its a weird race condition but its behind a lock now so it should be ok.devcards in your project. the file must come from somewheredeps.edn: devcards {:mvn/version "0.2.5"}
package.json: "devcards": "shadow-cljs watch devcards",
public/cards.html: <script>devcards.core_card.init();</script>
shadow-cljs.edn: :devcards {:target :browser
shadow-cljs.edn: {:entries [devcards.core_card]}}
shadow-cljs.edn: :dev {:compiler-options {:devcards true}}
src/cljs/devcards/core_card.cljs:(ns devcards.core_card
src/cljs/devcards/core_card.cljs: [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
src/cljs/devcards/core_card.cljs: [devcards.core :as dc]
src/cljs/devcards/core_card.cljs: [devcards.core-table :as table]
src/cljs/devcards/core_card.cljs: :filter (if (not-empty (get-in @devcards.core_card/card-state [:card :image-data]))
src/cljs/devcards/core_table.cljs:(ns devcards.core-table
src/cljs/devcards/core_table.cljs: [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
src/cljs/devcards/core_table.cljs: [devcards.core :as dc]
{:deps true
:nrepl {:port 8230}
; :cache-blockers #{deck-builder.macros}
:open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]
:builds {:browser
{:target :browser
:modules {:base {:entries [deck-builder.core]}}
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:devtools {:http-root "public"
:http-handler shadow.http.push-state/handle
:http-port 8280
:after-load deck-builder.core/mount-root
:preloads [devtools.preload]}}
:browser-test
{:target :browser-test
:test-dir "out/browser-test"
;; :compiler-options {:closure-defines {re-frame.trace.trace-enabled? true}}
:devtools {:http-root "out/browser-test"
:http-port 8290}}
:karma-test
{:target :karma
:output-to "out/karma/test.js"}
:devcards {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:main
{:entries [devcards.core_card]}}
:dev {:compiler-options {:devcards true}}
;; :closure-defines {goog.DEBUG true}}}
;; day8.re-frame.tracing.trace-enabled? true}}}
:devtools
{:autoload true
;; :before-load app.core/before-load
;; :after-load app.core/after-load
;; :http-handler shadow.http.push-state/handle
;; :preloads [day8.re-frame-10x.preload]
:http-root "public"
:http-port 3449}}}}
(ns devcards.core_card~/c/deck-builder ❯❯❯ cat deps.edn master ✭ ✖ ✱ ◼
{:deps {re-frame {:mvn/version "0.10.5"}
day8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}
binaryage/devtools {:mvn/version "0.9.10"}
proto-repl {:mvn/version "0.3.1"}
devcards {:mvn/version "0.2.5"}
cider/cider-nrepl {:mvn/version "0.18.0"}
refactor-nrepl {:mvn/version "2.4.0-SNAPSHOT"}
secretary {:mvn/version "1.2.3"}
venantius/accountant {:mvn/version "0.2.4"}
org.clojure/data.csv {:mvn/version "0.1.4"}
json-html {:mvn/version "0.4.4"}
io.joshmiller/exif-processor {:mvn/version "0.2.0"}
cljs-ajax {:mvn/version "0.7.4"}
camel-snake-kebab {:mvn/version "0.4.0"}
thheller/shadow-cljs {:mvn/version "2.6.10"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
:paths ["dev"
"test/cljs"
"src/clj"
"src/cljs"]
:aliases {:outdated {:extra-deps {olical/depot {:mvn/version "1.2.0"}}
:main-opts ["-m" "depot.outdated.main"]}}}
(ns devcards.core_card
(:require-macros
[devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
[cljs.test :as t :include-macros true :refer-macros [testing is]]
[deck-builder.macros :as dm])
(:require
["rmwc/Select" :refer (Select)]
["rmwc/Grid" :refer (Grid GridCell)]
["rmwc/Chip" :refer (Chip
ChipText
ChipIcon
ChipSet)]
["rmwc/Card" :refer (Card
CardPrimaryAction
CardMedia
CardAction
CardActions
CardActionButtons
CardActionIcons)]
["rmwc/Drawer" :refer (Drawer DrawerHeader DrawerContent)]
["rmwc/TextField" :refer (TextField TextFieldIcon TextFieldHelperText)]
["rmwc/Fab" :refer (Fab)]
["rmwc/Radio" :refer (Radio)]
["rmwc/Button" :refer (Button ButtonIcon)]
["rmwc/List" :refer (ListItem ListItemText)]
["rmwc/Toolbar" :refer (Toolbar
ToolbarRow
ToolbarSection
ToolbarTitle
ToolbarMenuIcon
ToolbarFixedAdjust
ToolbarIcon)]
["rmwc/Shape" :refer (ShapeContainer)]
["rmwc/Typography" :refer (Typography)]
["rmwc/Icon" :refer (Icon)]
["rmwc/Elevation" :refer (Elevation)]
[json-html.core :refer (edn->html)]
[reagent.core :as r]
[ajax.core :as ajax]
[ajax.protocols :as protocols]
;; [re-frame.core :as rf]
;; [re-frame.db :refer [app-db]]
[devcards.core :as dc]
[devcards.core-table :as table]
[deck-builder.views :as v]
[deck-builder.core :as c]
[clojure.string :as str]))
[cljs.test :as t :include-macros true :refer-macros [testing is]][cljs.test :as t :refer [testing is]] into your :require not :require-macros.shadow-cljs/jar-manifests directory and then start the server again as you did above[:devcards] Compiling ...
------ ERROR -------------------------------------------------------------------
File: /tank/rmason/code/deck-builder/src/cljs/devcards/core_table.cljs:1:1
--------------------------------------------------------------------------------
1 | (ns devcards.core-table
-------^------------------------------------------------------------------------
Invalid namespace declaration
-- Syntax error -------------------
(... ... (:require-macros
[devcards.core
:as
dc
:refer
[defcard defcard-rg deftest mkdn-pprint-str]]
[cljs.test :as t :include-macros true :refer-macros [testing is]]
[deck-builder.macros :as dm]) ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:shadow.build.ns-form/ns-form:
(clojure.spec.alpha/cat
:ns
'#{clojure.core/ns}
:name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:meta
(clojure.spec.alpha/? clojure.core/map?)
:clauses
:shadow.build.ns-form/ns-clauses)
-------------------------
Detected 1 error
--------------------------------------------------------------------------------
2 | (:require-macros
3 | [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
4 | [cljs.test :as t :include-macros true :refer-macros [testing is]]
5 | [deck-builder.macros :as dm])
--------------------------------------------------------------------------------
:error
[1:0]~shadow.user=>
1 (ns devcards.core_card
2 (:require-macros
3 [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
4 [deck-builder.macros :as dm])
5 (:require
6 ["rmwc/Select" :refer (Select)]
7 ["rmwc/Grid" :refer (Grid GridCell)]
8 ["rmwc/Chip" :refer (Chip
9 ChipText
10 ChipIcon
11 ChipSet)]
12 ["rmwc/Card" :refer (Card
13 CardPrimaryAction
14 CardMedia
15 CardAction
16 CardActions
17 CardActionButtons
18 CardActionIcons)]
19 ["rmwc/Drawer" :refer (Drawer DrawerHeader DrawerContent)]
20 ["rmwc/TextField" :refer (TextField TextFieldIcon TextFieldHelperText)]
21 ["rmwc/Fab" :refer (Fab)]
22 ["rmwc/Radio" :refer (Radio)]
23 ["rmwc/Button" :refer (Button ButtonIcon)]
24 ["rmwc/List" :refer (ListItem ListItemText)]
25 ["rmwc/Toolbar" :refer (Toolbar
26 ToolbarRow
27 ToolbarSection
28 ToolbarTitle
29 ToolbarMenuIcon
30 ToolbarFixedAdjust
31 ToolbarIcon)]
32 ["rmwc/Shape" :refer (ShapeContainer)]
33 ["rmwc/Typography" :refer (Typography)]
34 ["rmwc/Icon" :refer (Icon)]
35 ["rmwc/Elevation" :refer (Elevation)]
36 [json-html.core :refer (edn->html)]
37 [reagent.core :as r]
38 [ajax.core :as ajax]
39 [ajax.protocols :as protocols]
40 ;; [re-frame.core :as rf]
41 ;; [re-frame.db :refer [app-db]]
42 [devcards.core :as dc]
43 [devcards.core-table :as table]
44 [deck-builder.views :as v]
45 [deck-builder.core :as c]
46 [clojure.string :as str]
47 [cljs.test :as t :refer [testing is]]))
clean or something is now required?(shadow/once :devcards)shadow-cljs compile devcards? ie. kill all running shadow-cljs instances and start fresh?core_table.cljs also. Just too similar a name to pick it out of the error message.core_table.cljs was included in core_card.cljs but not when the error was in core_card.cljs which is what shadow-cljs.edn uses as it's entry point.[1:0]~shadow.user=> (shadow/once :devcards) [:devcards] Compiling ... npm package "fbjs" expected version "
~/c/deck-builder ❯❯❯ git diff deps.edn shadow-cljs.edn src ⏎ master ✭ ✖ ✱ ◼
diff --git i/deps.edn w/deps.edn
index 10891a0..342b4ac 100644
--- i/deps.edn
+++ w/deps.edn
@@ -12,7 +12,7 @@
io.joshmiller/exif-processor {:mvn/version "0.2.0"}
cljs-ajax {:mvn/version "0.7.4"}
camel-snake-kebab {:mvn/version "0.4.0"}
- thheller/shadow-cljs {:mvn/version "2.5.1"}
+ thheller/shadow-cljs {:mvn/version "2.6.10"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
:paths ["dev"
diff --git i/src/cljs/devcards/core_card.cljs w/src/cljs/devcards/core_card.cljs
index 974362c..f322b04 100644
--- i/src/cljs/devcards/core_card.cljs
+++ w/src/cljs/devcards/core_card.cljs
@@ -1,7 +1,6 @@
(ns devcards.core_card
(:require-macros
[devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
- [cljs.test :as t :include-macros true :refer-macros [testing is]]
[deck-builder.macros :as dm])
(:require
["rmwc/Select" :refer (Select)]
@@ -44,7 +43,8 @@
[devcards.core-table :as table]
[deck-builder.views :as v]
[deck-builder.core :as c]
- [clojure.string :as str]))
+ [clojure.string :as str]
+ [cljs.test :as t :refer [testing is]]))
(enable-console-print!)
diff --git i/src/cljs/devcards/core_table.cljs w/src/cljs/devcards/core_table.cljs
index 494687b..6046ea4 100644
--- i/src/cljs/devcards/core_table.cljs
+++ w/src/cljs/devcards/core_table.cljs
@@ -1,7 +1,6 @@
(ns devcards.core-table
(:require-macros
[devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
- [cljs.test :as t :include-macros true :refer-macros [testing is]]
[deck-builder.macros :as dm])
(:require
["rmwc/Select" :refer (Select)]
@@ -45,7 +44,8 @@
[deck-builder.views :as v]
[deck-builder.core :as c]
[deck-builder.rules :as rls]
- [clojure.string :as str]))
+ [clojure.string :as str]
+ [cljs.test :as t :refer [testing is]]))
(def fake-player-data
(apply merge
[2018-09-25 15:49:47.466 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/graphql-language-service-interface/dist/GraphQLLanguageService.js", :requires [{:line 149, :column 30}]}:npm-deps compiler flag or do you mean doing it the shadow-cljs way, where you install the library using npm or yarn and then require it directly?pdf.js library and in the end i just stopped trying to bundle it with shadow[cljsjs/graphiql "0.9.3-0"](:require ["graphiql" :default GraphiQL]) I get some other compilation errors. Which I assumed to be related to the warning.["graphiql" :as GraphiQL]Uncaught ReferenceError: process is not defined for React's prop-types moduleshaddow-cljs.edn filesprop-types in my current build so that should workglobal is not defined stands out. which index.js is that?js/cljs-runtime/node_modules/crypto-browserify/index.js:modules maybe?js/cljs-runtime/node_modules/buffer/index.js/js/main.js correct?<script> tags that do anything weird? 🙂public/js/cljs-runtime/module$node_modules$object_assign$index.js file pleasemain ns down to nothing, no errors_assign comes from that makes the others failpublic/js and start over?{:js-provider :closure} at one point?node_modules maybe on your :source-paths?(:require ["graphiql" :as GraphiQL](js/console.log GraphiQL) does the expected thing and prints the functionGraphiQL.Toolbar to GraphiQL/Toolbar it works as expectedimport GraphiQL from 'graphiql'; and so I took this line form the ES6 to require table: import defaultExport from "module-name"; (:require ["module-name" :default defaultExport]):default yet ...unravel localhost port but it seems to be detecting my clj namespaces, not my cljs ones. Also, there's no js namespace. Is there a way to tell it I'm on js? Or, even preferably, is there a way to use rebel-readline with shadow-cljs?(shadow/nrepl-select :my-app) and I think that’ll bump you into the cljs repl(shadow.cljs.devtools.api/nrepl-select :client) I get
IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set clojure.lang.Var.set (Var.java)
clojure.lang.Var.set (Var.java)
shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
user$eval14469.invokeStatic (unrepl-session)
user$eval14469.invoke (unrepl-session)
clojure.lang.Compiler.eval (Compiler.java)
clojure.lang.Compiler.eval (Compiler.java)
clojure.core$eval.invokeStatic (core.clj)
client build id?:builds {:client {...}}, so client? Or the build id something else?(shadow.cljs.devtools.api/nrepl-select :app) I get [:no-worker :app]{:source-paths ["src"]
:dependencies [[reagent "0.8.1"]]
:builds {:client
{:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [portal.client.core]}}
:devtools
{:http-root "public"
:http-port 8700}}}}
(shadow/repl :client)? Is it possible you're trying to bind from a non-nrepl?no such namespace shadow:repl/quit to exit the current repl and try again?user=> (shadow.cljs.devtools.api/nrepl-select :client) ClassNotFoundException shadow.cljs.devtools.api java.net.URLClassLoader.findClass (URLClassLoader.java:381)
clj -m rebel-readline.main for rebel, (haven't figured out how to connect to nrepl/socket repl yet); unravel localhost 57282 for unravel, that's the socket repl portshadow-cljs watch clientshadow-cljs clj-repl and then I bounce into the different repls.[1:0]~shadow.user=> (shadow/nrepl-select :client) [:no-worker :client]
watch client have to be running at the same time?(shadow/once :client)(shadow/watch :client)rlwrap shadow-cljs clj-repl shadow-cljs - config: /Users/jstaab/Desktop/cc/portal/shadow-cljs.edn cli version: 2.6.10 node: v8.4.0 shadow-cljs - starting ... Sep 26, 2018 3:29:46 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Sep 26, 2018 3:29:46 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :client available at shadow-cljs - server version: 2.6.10 shadow-cljs - server running at shadow-cljs - socket REPL running on port 59883 shadow-cljs - nREPL server started on port 59885 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [1:0]~shadow.user=> (shadow/watch :client) [:client] Configuring build. [:client] Compiling ... :watching [1:0]~shadow.user=> [:client] Build completed. (162 files, 1 compiled, 0 warnings, 8.57s) [1:0]~shadow.user=> (shadow/nrepl-select :client) IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set clojure.lang.Var.set (Var.java:223)
(shadow/repl :client) work?(shadow/nrepl-select :client) from within nrepl? Have you connected nREPL?nrepl or in nrepl?"scripts": {
"test": "shadow-cljs compile test"
}
and the shadow-cljs build config
:test {:target :node-test
:output-to "target/node-tests.js"
:ns-regexp "-test$"
:autorun true}}}
But when I run the tests (whether by npm test or npm run test) the exit status is zero even if there were failures. Is it just a bad idea to run the tests with :autorun?:autorun if you need the exit code. it mostly meant for running tests automatically with watch. use shadow-cljs compile test && node target/node-tests.js insteadwindow and such so it doesn't get loaded by the worker?{:shared {:entries []}
:web-shared
{:entries []
:depends-on #{:shared}}
:web1
{:init-fn
:depends-on #{:web-shared}}
:worker-shared
{:entries []
:depends-on #{:shared}}
:worker1
{:init-fn your.worker1/init
:web-worker true
:depends-on #{:worker-shared}}
:worker2
{:init-fn your.worker2/init
:web-worker true
:depends-on #{:worker-shared}}}:entries allows them to "catch" dependencies to they don't go further up the graphjava.net.SocketException: Socket closed exception when I terminate my shadow-cljs clj-repl (node repl) after working with some core.async I/O, is it due to me not close!ing a chan?core.asyncshadow-cljs with keechma. Hot-reload on the keechma project works with figwheel but does not work with shadow-cljs.keechma project is structured is usually this: core.cljs -> app/definition -> ui/ui -> componentfigwheel when the component is modified the dependency graph is resolved correctly, and app/definition is reloaded. In shadow-cljs, the reloading propogates from component and stops at ui/uishadow-cljs for the code above is as follows:
shadow-cljs: call example.client.core/stop shadow-cljs: load JS example/client/ui/main.cljs shadow-cljs: load JS example/client/ui.cljs shadow-cljs: load JS example/client/core.cljs
although it clearly has a dependency on ui/ui:
(def definition
{:components ui
:controllers controllers
:subscriptions subscriptions
:router :history
:routes [":category/:page"]})
(defn definition [] ...) and change all references to (definition)(ns ^:dev/always the.ns-with-definition)ui as well.keechma to re-frame it's a higher order abstraction than re-frame and deals nicely with app statesre-frame it's full of global states as well(def x {:a another/b})(def x {:a ns2/thing}) (ns ns2) (def thing {:a ns3/thing}):recompile-dependents:reload-dependents option{:reload-namspace :all} versus {:reload-namespace [foobar.core]}(ns a {:a another/a}) is totally fineanother both will be reloaded:devtools :preloads fulcro.inspect.preload that have the thing that depends on window.-localStorage:preloads in :modules themselves(defn ^:dev/after-load recalc []
(prim/transact!
(:reconciler @app)
`[(gsv.api.mutations/update-some-data {})]))
I don't have a ref to the state in the worker.:modules?:dev/after-load(defn ^:dev/after-load restart-workers [] (.terminate the-worker) (start-the-worker))after-load is completely independent of actual compilationshadow-cljs: call gsv.client/start browser.cljs:25 shadow-cljs: call gsv.client/recalc util.cljs:187 Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :asyncDon't happen when I change the worker code.
:dev/always so that some file of the main thread always gets reloaded(ns ^:dev/always some.reload-helper):preloads [some.reload-helper]-- Syntax error -------------------
(... ... ... (... [posh.plugin-base :as base :include-macros] ... ... ...))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
------ ERROR -------------------------------------------------------------------
File: jar:file:/tank/ranmason/.m2/repository/posh/posh/0.5.6/posh-0.5.6.jar!/posh/reagent.cljs:1:1
--------------------------------------------------------------------------------
1 | (ns posh.reagent
-------^------------------------------------------------------------------------
Invalid namespace declaration
-- Spec failed --------------------
(... ... ... (:require ... ... ... ...))
^^^^^^^^
should be one of: :import, :import-macros, :refer-clojure, :require-macros, :use, :use-macros
:include-macros true or better yet a :require-macros in the posh.plugin-base itselfSep 30, 2018 11:47:29 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Sep 30, 2018 11:47:29 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/jacek/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider() WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
[org.jboss.xnio/xnio-nio "3.6.5.Final"] + [org.jboss.xnio/xnio-api "3.6.5.Final"] to your depsSep 30, 2018 12:29:24 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.6.5.Final Sep 30, 2018 12:29:24 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.6.5.Final Sep 30, 2018 12:29:24 PM org.jboss.threads.Version <clinit> INFO: JBoss Threads version 2.3.0.Beta2 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.jboss.threads.ThreadLocalResetter$1 (file:/Users/jacek/.m2/repository/org/jboss/threads/jboss-threads/2.3.0.Beta2/jboss-threads-2.3.0.Beta2.jar) to field java.lang.Thread.threadLocals WARNING: Please consider reporting this to the maintainers of org.jboss.threads.ThreadLocalResetter$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
:exclusions [org.jboss.threads/jboss-threads]exclusions didn't help either/assets/bootstrap/js/cljs.core$macros.js:1 Uncaught ReferenceError: goog is not defined /assets/bootstrap/js/cljs.tools.reader.reader-types$macros.js:1 Uncaught ReferenceError: goog is not defined /assets/bootstrap/js/cljs.reader$macros.js:1 Uncaught ReferenceError: goog is not defined /assets/bootstrap/js/cljs.env.macros$macros.js:1 Uncaught ReferenceError: goog is not defined /assets/bootstrap/js/cljs.analyzer.macros$macros.js:1 Uncaught ReferenceError: goog is not defined /assets/bootstrap/js/cljs.compiler.macros$macros.js:1 Uncaught ReferenceError: goog is not defined
:advanced, only :simple:optimizations :simple to the :compiler-options.cljs files?shadow-cljs run build/hop watch app will call (build/hop "watch" "app"):npm-deps, I've forced myself to give shadow-cljs a try. I have to say, I'm very much pleased, and I think I've been missing out 🙂alter-var-root figwheel's CSS reload notificator because it was so annoying)
- better error messages and better monitoring of the state of your build, through the web interface:npm-deps and the "nameToPath" errors again, I'm switching careerslein clean to fix weird bugs 😉npm init that generates necessary files.npx create-cljs-project foo-bar works but its still a work in progresscreate-cljs-project is an npm module?npx or yarn though. don't install itcreate-react-app etcnpx before. I guess this is a bonusyarn create cljs-project foo-bar if you prefer yarnnpx is useful for running things without isntalling them<script>starter.browser.init();</script>. What should this be if my namespace is something like foo-bar.core?foo_bar.core thenThe required namespace "react" is not available, it was required by "reagent/core.cljs".I read the documentation, but not clear for me. How possible to solve? I added to project.clj exclusions too /cljsjs/react.
npm packages directly. so you need to npm install reactreagent doesn't properly declare its dependency on react since it uses cljsjsnpm install react react-dom create-react-classnpm installnpm install in the project directory<script>simple.core.init();</script> from html?shadow-cljs watch app, then if I start other build, and then stop app, the server stops entirelyshadow-cljs server to avoid it stopping?The required namespace "cljsjs.markdown" is not available, it was required by "hoplon/ui.cljs".Put it in my apps shadow dependencies?
shadow-cljs watch app will no longer receive output since the build it was watching endedshadow-cljs server commandrgb def https://github.com/hoplon/ui/blob/master/lib/src/hoplon/ui/attrs.cljs~/.m2 and whichever version you have specified in your dependencies yes.hl -> cljs compile?shadow-cljs clj-run does not seem to work?shadow-cljs.edn cli version: 2.6.10 node: v10.11.0
shadow-cljs - starting ...
failed to run function: demo.build/dev
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym demo.build/dev}
ExceptionInfo: failed to run function: demo.build/dev
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:129)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:84)
shadow.cljs.devtools.cli/blocking-action (cli.clj:145)
shadow.cljs.devtools.cli/blocking-action (cli.clj:135)
shadow.cljs.devtools.cli/main (cli.clj:196)
shadow.cljs.devtools.cli/main (cli.clj:151)
clojure.core/apply (core.clj:661)
clojure.core/apply (core.clj:652)
shadow.cljs.devtools.cli/-main (cli.clj:238)
shadow.cljs.devtools.cli/-main (cli.clj:236)
clojure.lang.Var.applyTo (Var.java:702)
clojure.core/apply (core.clj:657)
clojure.main/main-opt (main.clj:317)
clojure.main/main-opt (main.clj:313)
clojure.main/main (main.clj:424)
clojure.main/main (main.clj:387)
clojure.lang.Var.applyTo (Var.java:702)
clojure.main.main (main.java:37)
Caused by:
NullPointerException:
clojure.core/deref-future (core.clj:2292)
clojure.core/deref (core.clj:2312)
clojure.core/deref (core.clj:2298)
shadow.cljs.devtools.server.supervisor/active-builds (supervisor.clj:14)
shadow.cljs.devtools.server.supervisor/active-builds (supervisor.clj:12)
shadow.cljs.devtools.api/worker-running? (api.clj:132)
shadow.cljs.devtools.api/worker-running? (api.clj:128)
shadow.cljs.devtools.api/watch (api.clj:207)
shadow.cljs.devtools.api/watch (api.clj:201)
shadow.cljs.devtools.api/watch (api.clj:205)
shadow.cljs.devtools.api/watch (api.clj:201)
demo.build/dev (build.clj:9)
demo.build/dev (build.clj:6)
clojure.lang.Var.applyTo (Var.java:702)
clojure.core/apply (core.clj:657)
clojure.core/apply (core.clj:652)
shadow.cljs.devtools.cli/do-clj-run/body-fn--15420--auto----16265 (cli.clj:127)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:126)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:84)
shadow.cljs.devtools.cli/blocking-action (cli.clj:145)
shadow.cljs.devtools.cli/blocking-action (cli.clj:135)
shadow.cljs.devtools.cli/main (cli.clj:196)
shadow.cljs.devtools.cli/main (cli.clj:151)
clojure.core/apply (core.clj:661)
clojure.core/apply (core.clj:652)
shadow.cljs.devtools.cli/-main (cli.clj:238)
shadow.cljs.devtools.cli/-main (cli.clj:236)
clojure.lang.Var.applyTo (Var.java:702)
clojure.core/apply (core.clj:657)
clojure.main/main-opt (main.clj:317)
clojure.main/main-opt (main.clj:313)
clojure.main/main (main.clj:424)
clojure.main/main (main.clj:387)
clojure.lang.Var.applyTo (Var.java:702)
clojure.main.main (main.java:37)
(ns demo.build
(:require
[shadow.cljs.devtools.api :as shadow]
[clojure.java.shell :refer (sh)]))
(defn dev []
{:shadow/requires-server true}
(sh "ls" "-l")
(shadow/watch :app))
shadow-cljs clj-run demo.build/devshadow-cljs server first(defn dev []
{:shadow/requires-server true}
(sh "ls" "-l")
(shadow/watch :app))[] not after(defn ^:shadow/requires-server dev [] ...).cljs instead of a .clj file(:require ["antd/es/button" ...]) etc"antd" you will get everything thoughantd as a sample for the build reports featuresantd fully https://code.thheller.com/demos/build-report/huge.htmlantd/es/button in this case https://code.thheller.com/demos/build-report/not-so-huge.htmlimport './style.css' -- the closest I've come to that is this library but it's deprecated: https://github.com/rgdelato/styled-classnames------ WARNING #1 -------------------------------------------------------------- File: firebase/app.cljs:1:14 constant firebase assigned a value more than once. Original definition at externs.shadow.js:6 --------------------------------------------------------------------------------If I run with :optimizations :whitespace, I do not get any compile errors but the browser is not happy and I get
main.js:3157 Uncaught TypeError: Cannot set property 'Error' of undefined
at main.js:3157
at main.js:15494 Uncaught TypeError: Cannot read property 'main' of undefined
at window.onload ((index):14) goog.nodeGlobalRequire=function(path){return false};goog.provide("goog.debug.Error") Any ideas on what is going on and how to resolve? TNX(go-loop []
(let [[[request-spec preload started] result] (<! finished-requests)
request-took-ms (- (.getTime (js/Date.))
(.getTime started))
latest-ten (cons request-took-ms (take 9 @avg-processing-time-coll))
avg-processing-time (/ (reduce + latest-ten) (count latest-ten))]
(when (not preload)
(do (aset result "took" (+ avg-processing-time 100))
(js/postMessage result #js [result])))
(recur)))
163 | (js/postMessage #js {:result result} (to-array [(aget result "data")]))))
----------------------------------------------^---------------------------------
Use of undeclared Var gsv.worker/result
(js-obj "result" result) does that complain?(js/postMessage (clj->js {:result result}) (to-array [(aget result "data")])) that works.(go (let [a 1]
(prn a)
(prn #js [a])
(prn #js {:a a})))#js usesgosun.nio.fs.UnixPath and I'm on Windows so that might explain it["aws-amplify-react" :refer [Authenticator]]
causes this:
The required JS dependency "babel-runtime/helpers/extends" is not available, it was required by "node_modules/aws-amplify-react/dist/AmplifyUI.js". Searched in:/Users/ErichOliphant/Documents/projects/sqd/node_modules You probably need to run: npm install babel-runtime/helpers/extendsThe transpiled AmplifyUI.js has the following
...
var _extends2 = require('babel-runtime/helpers/extends');
But the babel runtime package has the preceding @ in node_modules which I presume is the problem. Why can't everyone just use clojurescript.. Ugh...node_modules/babel-runtime exists?@babel/... scoped packagesrm -rf node_modules and npm installnpm WARN npm install aws-amplify aws-amplify-reactnpm install aws-amplify aws-amplify-reactnode_modules/babel-runtime exists and is NOT empty (it might be)node_modules/aws-amplify-react/node_modules/babel-runtime exists and is not emptynode_modules/babel-runtime
And the only thing under node_modules/aws-amplify-react/node_modules is regenerator-runtime whatever that isnpm install babel-runtime should fix it(:require ["auth0-js/dist/auth0.js" :as auth0]) seems to work fineshadow.js.js:88 Uncaught TypeError: Cannot read property 'lib' of undefined
at auth0.min.js:9
at auth0.min.js:9
at createCommonjsModule (auth0.min.js:9)
at auth0.min.js:9
at auth0.min.js:9
at Object.shadow$provide.module$node_modules$auth0_js$dist$auth0_min (auth0.min.js:9)
at Object.shadow.js.jsRequire (shadow.js.js:85)
at Object.shadow.js.require (shadow.js.js:111)
at sqd.ui.components.auth0.js:5
NoSuchMethodError is weird so it may just be a dependency conflict?:npm-module than to have a separate stand-alone :browser target build for development?
I currently have my project successfully imported as a module into our website, but hot-reloading doesn't seem to work out of the box that way (unless I've messed something up).npm-module is tricky since shadow-cljs is not in charge of the final bundle. so it is not super reliable:runtime :browser in your configrequire("shadow-cljs/shadow.cljs.devtools.client.browser") somewhere in your JS:npm-module works there is no easy way to do this outside of doing it via the JSif (process.env.NODE_ENV == "development") { ... } and you are set(defonce _hack (js/require "...")) in my main cljs file.(when ^boolean js/goog.DEBUG ...) that should remove it from productionadapt-react-class applied. I figured that since that was a 'use' of the react class, I was effectively pulling everything in. I've since setup another experiment, where I'm just pulling in a few classes for a small page. However, when I run the build report, I'm still seeing roughly the same 'optimized' sizesemantic-ui-react package directly as that it itself will pull everything in (regardless of use):advanced compilation for node_modules so it doesn't do full dead code removal:refer'ed just the components I wanted, but to your point I did it from the top level package(:require ["semantic-ui-react" :refer (Thing)])(:require ["semantic-ui-react/dist/es/views/Card" :as Card]):refer to eliminate code is a useful thing to do in the first place["semantic-ui-react/dist/es/collections/Menu" :refer (Menu MenuItem Image MenuMenu) ] just fine and now there's 73 vs 400+ kb of stuffdist/es but thats just not gonna be reliable againstream dependency when trying to (require '["sjcl" :as sjcl]). may be an easy fix, still havent gotten to the point where i can grok these types of issues quicklystream is written or bundledshadow-cljs install in your actual project?stream is one of those node native packages that is emulated for the browserpackage.json devDependencies (or dependencies);; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[
[binaryage/devtools "0.9.10"]
[adzerk/env "0.3.1" :scope "test"]
[com.rpl/specter "1.1.1"]
[hoplon/hoplon "7.3.0-SNAPSHOT"]
[cljsjs/markdown "LATEST"]
[vigilancetech/ui "0.3.0-SNAPSHOT"]
]
:builds
{:app { :target :browser
:compiler-options {:language-in :ecmascript5-strict }
:output-dir "public/assets/app/js"
:asset-path "/assets/app/js"
:build-hooks [(build.hop/foo)]
:modules {:main {:entries [guardian.dashboard]}}}}}
under src/build/hop.cljs
(ns build.hop
(:require [shadow.cljs.devtools.api :as shadow]
[hoplon :refer hoplon]))
(defn foo
{:shadow/requires-server true}
[build]
(hoplon/hoplon)
(shadow/watch (keyword build)))
With the command line:
shadow-cljs run build.hop/foo appI'm getting the error:
failed to load namespace: build.hop
.cljs file. must be either .clj or .cljc:build-hooks is not correctrun or :build-hooks but the same function cannot be used for bothhoplon namespace as far as I can tell?boot to work at all.cljs files and shadow-cljs will understand it no problem.cljs file really is.cljsand .html filesfailed to load namespace: build.hop
[hoplon :refer hoplon] then its because it can't load thatshadow-cljs clj-repl instead and (require 'build.hop)[12:0]~shadow.user=> (require 'build.hop)
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses), Extra input
#:clojure.spec.alpha{:problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x780884b2 "[hoplon :refer hoplon]:refer is always a collection of symbolshoplon ns doesn't exist in the first place[hoplon :refer (hoplon)] would be correct use of :refer but hoplon is still invalid:refer but it can be a vector too yesboot watch shadow/serverboot watch shadow/compile or boot watch shadow/release(comp (shadow/compile :build :client)) what is this?shadow/ is from boot-shadow it wraps the shadow-cljs library and calls it as a boot taskhoplon pre-process is a boot task. you simply cannot run that from shadow-cljs.(page) macro:advanced. which posh version do you use? the default one uses an invalid :require and doesn't compile at all:npm-module with expo. it works ok-ish. https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-modulenpx shadow-cljs node-repl and it starts fine, but that REPL runs on the terminal only, I want to connect and send commands from my editor, but when I connect to the nREPL I only get the Clojure one, how can I transition that to run from my editor targeting the node repl?(shadow.cljs.devtools.api/repl :node-repl) so switch the nrepl session over(shadow/node-repl) did the tricknode-repl"(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)"
\n are there so that the error message matches the line of the actual file{:file "(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)", :file-name "api.clj", :file-path "C:/Users/thheller/code/shadow-cljs/src/main/shadow/cljs/devtools/api.clj", :id "a2b09333-3223-4d43-9cb6-54236e79dbb8", :op "load-file"}load-file without an actual file (thats the full nrepl message that gets sent){:code "(prn :foo)", :id "549215c5-9e36-4eb9-9e8e-f17288de92bf", :ns "demo.browser", :op "eval"}:ns but its just ignored:ns for the CLJS message 😛localhost and whatever port was spit outgoog version loaded on the page?goog in the console without loading the .js generated by shadow-cljs?:prepend "goog.isProvided_ = function(name) { return false; }; to your base modulegoog?goog = {};:prepend option working for some reason during dev is it possible to set it with the :devtools option?fulcro-inspect stop working but I can live with that for nowvar Confirm = require('react-confirm-bootstrap');
var ConfirmAction = React.createClass({
onConfirm() {
// Preform your action.
},
render() {
return (
<Confirm
onConfirm={this.onConfirm}
body="Are you sure you want to delete this?"
confirmText="Confirm Delete"
title="Deleting Stuff">
<button>Delete Stuff</button>
</Confirm>
)
},
});
I'd expect something in cljs like this:
(ns ....
(:require ["react-confirm-bootstrap" :default Confirm]))
[:> Confirm {:body "question"
:title "whatever"
:onConfirm #(println "confirmed")}
[:span "push me"]]
There are no errors or warnings, but when clicking 'push me', nothing happens...["react-confirm-bootstrap" :as Confirm] not :default:as: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.[:> Confirm {:onConfirm #(println "test")
:title "title"
:body "body"}
[:button "test"]]
still nothing happens 😛(r/as-element [:button "test"]) maybe:buttonTextas-element should workz-index 😛goog. any other namespace will have the same issues (eg. cljs.core). but no there is no way to adjust thatnpm install marked but still get the same error.npm install marked but the error still occurs.npm install marked --save in such a way that will get devcard build to compile.marked, but now I'm getting this errror: The required namespace "create-react-class" is not available, it was required by "devcards/core.cljs". but I thought the required shim for react already existed in shadow.create-react-class in shadow-cljsjs project.error in process sentinel: Could not start nREPL server: shadow-cljs - config: /home/kevin/tmp/minimal-shadow-cljs-browser/shadow-cljs.edn cli version: 2.6.6 node: v8.11.1 shadow-cljs - connected to server server already running
If the popular cider-nrepl is found on the classpath it will be added automatically. No additional configuration required.but the cider's man page says:
Much of CIDER's functionality depends on the presence of CIDER's own nREPL middleware. Starting with version 0.11, When cider-jack-in (C-c C-x (C-)j (C-)j) is used, CIDER takes care of injecting it and its other dependencies.so, should I remove the cider-nrepl from my system to have it work with shadow or is that the nrepl shadow is looking for?
shadow-cljs tests with karma (3.0.0), how do I run only a single deftest (and rerun when files change)?(deftest with #_(deftest and comment in the tests you want to focus on.
Please let me know if there’s a better way.deftest (for instance ^:focus) but it is not a clojure.test featureclojure.test/test-var and friends thoughkarma currently no. but you can always just fire up a REPL and run a singular test.shadow-cljs server separatelycider-connect as describe here https://shadow-cljs.github.io/docs/UsersGuide.html#ciderbulma and 'bulma-react-components` npm packages and am using bulma components in my app by requiring it as ["react-bulma-components" :as bulma], an i can see the component part working. Now, how do i import the css in my app?<link rel="stylesheet" href="..." /> or is there a better way to load npm-packaged css module in clojurescript through shadow-cljs ?node-sass cli or just copy the css manually into my public/css directoryleinmodules/no-data-to-display.js to your imports. I did this by adding ["highcharts/modules/no-data-to-display"] to my :require but that doesn't appear to work. I'm curious if there is any sort of initialization that I need to do to get the plugin to work. Any thoughts?["highcharts/modules/no-data-to-display" :as foo] and run (js/console.log foo) it logs a function, not a map like most npm modules do.(foo highcharts) where highcharts is ["highcharts/js/highcharts" :as highcharts] and it worked. Very weird. In their examples all they do is add <script src=""></script> to their index.html.2.6.11 which should now properly use the REPL ns even for CLJS-g[:failed-to-compare "^2.2.5" "2.2.6" #error {
:cause nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]}]
:trace
[[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]
[shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 11]
[shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18306 invoke "npm_deps.clj" 27]
[clojure.lang.Delay deref "Delay.java" 42]
[clojure.core$deref invokeStatic "core.clj" 2312]
[clojure.core$deref invoke "core.clj" 2298]
[shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18308 invoke "npm_deps.clj" 33]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 163]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 157]
[shadow.cljs.devtools.server.npm_deps$main$fn__18389 invoke "npm_deps.clj" 179]
[clojure.core$complement$fn__5391 invoke "core.clj" 1433]
[clojure.core$filter$fn__5614 invoke "core.clj" 2813]
[clojure.lang.LazySeq sval "LazySeq.java" 40]
[clojure.lang.LazySeq seq "LazySeq.java" 49]
[clojure.lang.RT seq "RT.java" 528]
[clojure.core$seq__5124 invokeStatic "core.clj" 137]
[clojure.core$seq__5124 invoke "core.clj" 137]
[shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 181]
[shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 172]
[shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 162]
[shadow.cljs.devtools.cli$main doInvoke "cli.clj" 153]
[clojure.lang.RestFn applyTo "RestFn.java" 137]2.6.12File: jar:file:/home/hukka/.m2/repository/thheller/shadow-cljs/2.4.21/shadow-cljs-2.4.21.jar!/shadow/cljs/devtools/client/hud.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.cljs.devtools.client.hud -------^------------------------------------------------------------------------ Invalid :refer, var cljs.core.async/go does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [shadow.dom :as dom] 4 | [shadow.xhr :as xhr] 5 | [shadow.animate :as anim] --------------------------------------------------------------------------------no matter what kind of requires I use in my code
core.async version in your classpath0.4.474MY_ENV=foo shadow-cljs server,
2. connect via nrepl and compile a node-script build,
3. start the script with MY_ENV=bar node out/my-script.js,
4. connect a node-repl,
then (.-MY_ENV js/process.env) has the value foo. How come? I’d expect bar.node-repl or the REPL for your build?node-repl is its own node process started by shadow-cljs:npm-module project that's being yarn installed from a git repo by a website, and so runs shadow-cljs release npm in the package.json postinstall hook.
Unfortunately the module uses Reagent, which needs (but doesn't explicitly depend on) other packages, so shadow-cljs apparently doesn't have some namespaces (for example, create-react-class) available at this point.
The dependencies are installed by yarn, but in the main website's node_modules, which I guess isn't accessible to each individual package's postinstall command.
Are there any good/recommended ways of making such packages available when the project is installed as a dependency?shadow-cljs in a postinstall hook, thats just way too slow. instead you do the release and just publish the compiled files instead:closure-defines. what else would you want access to?:asset-path is required in this case.node_modules to :asset-path, and then use the copied files either as arguments to TinyMCE or somewhere in index.html (e.g. CSS files).:asset-path is available as js/CLOSURE_BASE_PATHgoog-define itscript tag in the DOM and taking its src attributeshadow-cljs.edn via some marco that just inlines all requested values?:asset-path:asset-path as well)
2. In index.html (not an issue with :asset-path since the server can just read the EDN and inline all values in the HTML template)
3. In nginx.conf (not an issue since this file is being generated from different files, including the EDN)
Of course, for (1) I could use the same thing as in (2) or (3), but it would become much more convoluted than it is now, and also it would probably lose some integration with IDE since I would have to use some kind of templating.
Another solution would be to read the EDN with some Lein plugin (I also use project.clj). I think something like that can be achieved since there's already lein-environ plugin that does something similar.require("./some-path/some.png") and it'll return the path to that file(def some-tiny-mce-asset (assets/path-for "tiny-mce/theme/foo.css"))?require. That is, in JS. In CLJS, I just include the relevant CSS files in index.html and copy them from node_modules/something to :asset-path.
And some things, like TinyMCE require a user to supply a bunch of files with a specific naming convention. So in this case, I just copy the whole folder from node_modules/tinymce to :asset-path and then pass the configured path (mapped in nginx.conf) to tinymce.init.
> the problem with having a macro access the config is cache invalidation since the code must be recompiled if the values change
Ahhh, that's right. I remember having this issue with lein-environ. Thanks for making me aware of that.
Would the option with goog-define that you've suggested solve it? If so, could you please describe it a bit more? I have no clue on how one would link it with shadow-cljs.edn.(ns your.config) (goog-define asset-path "/foo") and in the config :closure-defines {your.config/asset-path "/bar"}(defn path-for [asset] (str asset-path asset))(config/path-for "/some.css") in your code:asset-path - in :asset-path itself and in :closure-defines?:asset-path itself has no meaning in release builds<script src="/something/foo.js">#error {:message
"Invalid symbol: cloj … lang.ExceptionInfo:."
, :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:151
(anonymous) @ browser.cljs:343
: on require(ns ... (require ....12 will try to repro:e from the :build-failure message precisely because of those errors(pr-str (ex-info "foo" {:bar 1})) in your project? I don't understand why :e would not print as #error .... It seems like something is messing with the default printing setup?env.cljs:167 failed to parse websocket message {:type :build-failure, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs:55:43\n--------------------------------------------------------------------------------\n 52 | (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})\n 53 | (ui/text-field-raw {:maxLength \"8\"\n 54 | :value postcode-lookup\n 55 | :onChange })\n-------------------------------------------------^------------------------------\nnubank/shuffle/modules/logistic/components.cljs [line 55, col 43] The map literal starting with :maxLength on line 53 column 30 contains 5 form(s). Map literals must contain an even number of forms.\n\n--------------------------------------------------------------------------------\n 56 | (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})\n 57 | (ui/button {:onClick #(let [postcode (-> this fp/props :address/postcode)]\n 58 | (if (= 8 (count postcode))\n 59 | (db.h/load this (fp/get-ident this) AddressForm {:params {:abrams.api/extra-attrs {:address.brazil/postcode postcode}}}))\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"] {:ex-kind :reader-error, :source-excerpt {:start-idx 51, :before [" (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})" " (ui/text-field-raw {:maxLength \"8\"" " :value postcode-lookup"], :line " :onChange })", :after [" (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})" " (ui/button {:onClick #(let [postcode (-> this fp/props :address/postcode)]" " (if (= 8 (count postcode))" " (db.h/load this (fp/get-ident this) AddressForm {:params {:abrams.api/extra-attrs {:address.brazil/postcode postcode}}}))"]}, :file #object[java.io.File 0x396f9cf3 "/Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs"], :resource-id [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"], :ex-type :reader-exception, :column 43, :line 55, :url #object[java.net.URL 0x37a875ae "file:/Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs"], :source-id [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"], :tag :shadow.build.compiler/compile-cljs}, :build-id :workspaces} #error {:message "Invalid symbol: cloj … lang.ExceptionInfo:.", :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:167
(anonymous) @ browser.cljs:344
`:e clojure.lang.ExceptionInfo: failed to compile resource:#error {:message
"Invalid symbol: cloj … lang.ExceptionInfo:."
Invalid symbol: clojure.lang.ExceptionInfo:.
, :data {:type :reader-exception, :ex-kind :reader-error}}
shadow-cljs clj-repl to that process?(pr-str (ex-info "foo" {:bar 1})) prints as #error ...?:e is no longer part of that message[1:0]~shadow.user=> (pr-str (ex-info "foo" {:bar 1}))
"#error {\n :cause \"foo\"\n :data {:bar 1}\n :via\n [{:type clojure.lang.ExceptionInfo\n :message \"foo\"\n :data {:bar 1}\n :at [clojure.core$ex_info invokeStatic \"core.clj\" 4739]}]\n :trace\n [[clojure.core$ex_info invokeStatic \"core.clj\" 4739]\n [clojure.core$ex_info invoke \"core.clj\" 4739]\n [shadow.user$eval33297 invokeStatic \"form-init8724609811994379936.clj\" 1]\n [shadow.user$eval33297 invoke \"form-init8724609811994379936.clj\" 1]\n [clojure.lang.Compiler eval \"Compiler.java\" 7062]\n [clojure.lang.Compiler eval \"Compiler.java\" 7025]\n [clojure.core$eval invokeStatic \"core.clj\" 3206]\n [clojure.core$eval invoke \"core.clj\" 3202]\n [shadow.cljs.devtools.server.socket_repl$repl$fn__17857 invoke \"socket_repl.clj\" 97]\n [clojure.main$repl$read_eval_print__8572$fn__8575 invoke \"main.clj\" 243]\n [clojure.main$repl$read_eval_print__8572 invoke \"main.clj\" 243]\n [clojure.main$repl$fn__8581 invoke \"main.clj\" 261]\n [clojure.main$repl invokeStatic \"main.clj\" 261]\n [clojure.main$repl doInvoke \"main.clj\" 177]\n [clojure.lang.RestFn invoke \"RestFn.java\" 805]\n [shadow.cljs.devtools.server.socket_repl$repl invokeStatic \"socket_repl.clj\" 64]\n [shadow.cljs.devtools.server.socket_repl$repl invoke \"socket_repl.clj\" 28]\n [shadow.cljs.devtools.server$from_cli$fn__19792 invoke \"server.clj\" 606]\n [shadow.cljs.devtools.server$from_cli invokeStatic \"server.clj\" 605]\n [shadow.cljs.devtools.server$from_cli invoke \"server.clj\" 517]\n [clojure.lang.AFn applyToHelper \"AFn.java\" 160]\n [clojure.lang.AFn applyTo \"AFn.java\" 144]\n [clojure.lang.Var applyTo \"Var.java\" 702]\n [clojure.core$apply invokeStatic \"core.clj\" 657]\n [clojure.core$apply invoke \"core.clj\" 652]\n [shadow.cljs.devtools.cli$lazy_invoke invokeStatic \"cli.clj\" 22]\n [shadow.cljs.devtools.cli$lazy_invoke doInvoke \"cli.clj\" 19]\n [clojure.lang.RestFn invoke \"RestFn.java\" 460]\n [shadow.cljs.devtools.cli$blocking_action invokeStatic \"cli.clj\" 148]\n [shadow.cljs.devtools.cli$blocking_action invoke \"cli.clj\" 135]\n [shadow.cljs.devtools.cli$main invokeStatic \"cli.clj\" 196]\n [shadow.cljs.devtools.cli$main doInvoke \"cli.clj\" 151]\n [clojure.lang.RestFn applyTo \"RestFn.java\" 137]\n [clojure.core$apply invokeStatic \"core.clj\" 661]\n [clojure.core$apply invoke \"core.clj\" 652]\n [shadow.cljs.devtools.cli$_main invokeStatic \"cli.clj\" 238]\n [shadow.cljs.devtools.cli$_main doInvoke \"cli.clj\" 236]\n [clojure.lang.RestFn invoke \"RestFn.java\" 421]\n [clojure.lang.Var invoke \"Var.java\" 385]\n [user$eval543 invokeStatic \"form-init8724609811994379936.clj\" 1]\n [user$eval543 invoke \"form-init8724609811994379936.clj\" 1]\n [clojure.lang.Compiler eval \"Compiler.java\" 7062]\n [clojure.lang.Compiler eval \"Compiler.java\" 7052]\n [clojure.lang.Compiler load \"Compiler.java\" 7514]\n [clojure.lang.Compiler loadFile \"Compiler.java\" 7452]\n [clojure.main$load_script invokeStatic \"main.clj\" 278]\n [clojure.main$init_opt invokeStatic \"main.clj\" 280]\n [clojure.main$init_opt invoke \"main.clj\" 280]\n [clojure.main$initialize invokeStatic \"main.clj\" 311]\n [clojure.main$null_opt invokeStatic \"main.clj\" 345]\n [clojure.main$null_opt invoke \"main.clj\" 342]\n [clojure.main$main invokeStatic \"main.clj\" 424]\n [clojure.main$main doInvoke \"main.clj\" 387]\n [clojure.lang.RestFn applyTo \"RestFn.java\" 137]\n [clojure.lang.Var applyTo \"Var.java\" 702]\n [clojure.main main \"main.java\" 37]]}"pr-str in this casepr-str:e from the :build-failure message[:workspaces] Build failure:
:e of course ...npm-module which I import into react storybook (which has it's own server and index.html runner). I'm trying to get the browser repl working for this build, is there a javascript file I need to import into the foreign index.html?shadow.cljs.devtools.client.browser namespace:runtime :browser in your config so it gets compiledrequire("./path-to/shadow.cljs.devtools.client.browser")release will also include it then2.6.12:[com.google.javascript/closure-compiler-unshaded "v20180910"]project.clj)lein deps :tree.shadow-cljslein-cljsbuild may actually be messing with you deps an inject older versionsget-x from 1 to 2 and eval get-x into repl, the console will start to log 2 instead of 1.
(defn get-x [] 1) (defn loop [] (js/console.log (get-x) (loop))
(defn loop [] (js/console.log (get-x) (js/setTimtout loop 0))
after-load hook to re-render in case you are using reagent or so2.6.14 which has a few performance optimizations. Nothing super major but can save a couple secs on larger builds2.6.14 I get an exception printed out but everything seems fine:
RejectedExecutionException: Task
clara-rules is not very cache friendly. IIRC the problematic part of fact-ui is the f/rulebase call^:dev/alwaysTerminated? did you ctrl+c or something? normally a watch never terminates the threadpool? not even when the watch is stopped since its shared on the entire system (only stop! does that)cond->watch recompile times of 10sec+ please let me know. there is probably something to be improved just waiting to be found! do not assume that 10s+ is normal:ns when evaling from a file::foo from that will be :cljs.user:ns or not[2018-10-19 19:41:40.023 - INFO] :shadow.build.classpath/jar-cache-read-ex - {:file #object[java.io.File 0x1f0f5174 ".shadow-cljs/jar-manifest/1539977882000-core.rrb-vector-0.0.12.jar.manifest"]}
RuntimeException java.io.EOFException
com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:114)
cognitect.transit/read (transit.clj:319)
cognitect.transit/read (transit.clj:315)
shadow.build.cache/read-cache (cache.clj:49)
shadow.build.cache/read-cache (cache.clj:33)
shadow.build.classpath/find-jar-resources/fn--11757 (classpath.clj:565)
… cognitect.transit/read (transit.clj:319)
aborted par-compile, [:shadow.build.classpath/resource "clojure/string.cljs"] still waiting for #{cljs.core}
{:aborted [:shadow.build.classpath/resource "clojure/string.cljs"], :pending #{cljs.core}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "clojure/string.cljs"] still waiting for #{cljs.core}
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.compiler/par-compile-one (compiler.clj:760)
shadow.build.compiler/par-compile-one (compiler.clj:729)
shadow.build.compiler/par-compile-cljs-sources/fn--12969/iter--12970--12974/fn--12975/fn--12976/fn--12977 (compiler.clj:822)
clojure.core/apply (core.clj:657)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/with-bindings* (core.clj:1965)
clojure.core/apply (core.clj:661)
clojure.core/bound-fn*/fn--5471 (core.clj:1995)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
:optimizations :advanced, :infer-externs :auto and :shadow-keywords true, and still, a release build looks like this:material-ui is huge if you import all of it(:require ["@material-ui/core/Button" ...]) to only include parts of the package["@material-ui/core/Button" :default muiButton] ["@material-ui/core/TextField" :default muiTextField]for test
shadow-cljs to manage your deps 😉npx shadow-cljs release server client dev-client:verbose true in the config please--verbose on the CLI)--parallel=false option(ns release
(:require [shadow.cljs.devtools.server :as server]
[shadow.cljs.devtools.api :as shadow]))
(defn -main [& args]
(server/start!)
(shadow/release :server {:verbose true})
(shadow/release :client {:verbose true})
(shadow/release :dev-client {:verbose true})
(server/stop!)
(System/exit 0))
I'll report back if I see those errors againreleaseshadow-cljs run release/all also works a bit better probably(defn all [] ...) of course .. not -main(shadow/with-runtime ...) yourself(defn -main [& args]
(shadow/with-runtime
(shadow/release :server {:verbose true})
(shadow/release :client {:verbose true})
(shadow/release :dev-client {:verbose true})))shadow-cljs run thats done automatically(defn all [& args]
(shadow/release :server {:verbose true})
(shadow/release :client {:verbose true})
(shadow/release :dev-client {:verbose true}))api/node-repl which started its own process. Using api/nrepl-select works as expected.:body (subs body start (inc end))body will be a java.io.File instance IIRC... ;; ;; You can remove this message with the <M-x cider-repl-clear-help-banner> command. ;; You can disable it from appearing on start by setting ;; ‘cider-repl-display-help-banner’ to nil. ;; ====================================================================== shadow.user> WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings. To quit, type: :cljs/quit [:selected :renderer] WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:55) WARNING: Use of undeclared Var shadow/watch (<stdin> at 1:55) WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:76) WARNING: Use of undeclared Var shadow/nrepl-select (<stdin> at 1:76) cljs.user>there's a 2nd repl buffer that is created with similar, but not quite exactly the same, results:
...
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; ‘cider-repl-display-help-banner’ to nil.
;; ======================================================================
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
shadow.user> TypeError: shadow.watch is not a function
at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:4:8)
at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:7:3)
at file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:139:108)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:827:46)
at shadow$cljs$devtools$client$browser$handle_message (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:907:44)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:258:102)
at WebSocket.<anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:1002:40)
shadow.user>
The 2nd repl's buffer status says it's only pending. The renderer repl doesn't initially have those (non-middleware) errors until after the sibling is created.
From the terminal(s) the repls work perfectly. The renderer can do things like (js/alert "foo") and it works. The main issues an error when trying to do that (as it should because its only the launcher).
Help!?!?lein new:source-paths ["src"]?["src"] if you do not need or want itdev at the root I prefer to put it in src/devsrc and test at the rootdev later on:jvm-opts ["-Xmx1G"] to you shadow-cljs.edn to limit the amount of memory to 1gb(require ["Buffer" :as Buffer]) (Buffer/alloc 1024)
Buffer? try to print it (js/console.log Buffer)(js/Buffer.alloc ...)(:require ["Buffer" :refer (Buffer)])(random-uuid) and uuid?, what features are you guys getting from those external libraries?uuid? checks the type not the content so we used the lib for validation2.6.15 which should now properly support range requests and 206node_modules that are npm linked? It seems shadow-cljs doesn't pick them up.The required namespace "konserve.filestore" is not available, it was required by "infinitor/collector/database.cljs". "konserve/filestore.clj" was found on the classpath. Should this be a .cljs file?Looking in the repo for konserve they have one .clj file and one .cljs file. Is this a bug in shadow-cljs or should I look elsewhere?
.jar is. and that doesn't include the filestore.cljs. looks like that was created after the last release.node_modules/the-thing/... exists. the-thing is allowed to be a link. maybe need to upgrade if you get a complaint about not being allowed to use sources outside the project. that was fixed.[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 1.62s) ------ WARNING #1 -------------------------------------------------------------- point_cloud_layer_fragment_glsl assigned a value more than once. -------------------------------------------------------------------------------- [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 2.72s) [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 3.80s) [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 6.44s) [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 12.04s) [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 23.20s) [:main] Build completed. (1197 files, 3 compiled, 0 warnings, 57.57s) ;;after shadow-cljs restart [:main] Build completed. (1197 files, 1040 compiled, 0 warnings, 112.28s)
--verbose2.4.20 so must be something else<- msg with a high ms number?-> without a matching <-?<- Closure JS Cache read: 4 JS files (2427 ms).shadow-cljs/builds/main/dev/shadow-js/index.json.transit is?.shadow-cljs/builds/main/dev/closure-js/index.json.transit.js files directly?.shadow-cljs/builds/main/dev/closure-js-rw-r--r-- 1 baruchberger staff 298854289 Oct 24 22:55 index.json.transit -rw-r--r-- 1 baruchberger staff 3958 Oct 24 19:43 module$gsv$api$partition.js -rw-r--r-- 1 baruchberger staff 20392 Oct 24 22:53 module$gsv$ui$custom_point_cloud.js -rw-r--r-- 1 baruchberger staff 5023 Oct 24 19:43 module$gsv$ui$point_cloud_layer_fragment_glsl.js -rw-r--r-- 1 baruchberger staff 7160 Oct 24 19:43 module$gsv$ui$point_cloud_layer_vertex_glsl.js
npm packs the directory (100mb) in the process.:module-move messages are gone in the latest versionlein installlein install you must run the build-all.sh first-rw-r--r-- 1 baruchberger staff 10699 Oct 24 23:21 start.index.json.transit -> -rw-r--r-- 1 baruchberger staff 26659 Oct 24 23:27 index.json.transitEnough of a growth increase? or is this expected?
:injected-libs ("es6/util/inherits"
"es6/util/setprototypeof"
"util/objectcreate"
"es6/util/arrayfromiterable"
"es6/util/arrayfromiterator"
"es6/util/makeiterator"
"es6/symbol"
"es6/object/assign"
"util/polyfill"
"util/global"
"util/defineproperty"injected-libs
(-> (.get injected-libraries-field cc)
(keys)
(into #{})-> instead of ->> ...(clojure.set/union #{} '(1 2 3)) => (1 2 3)into ...dev> (clojure.set/union #{1 2 3} '(1 2 3))
#{1 3 2}
dev> (clojure.set/union #{1 2 3} '(1 2 3 4))
(2 3 1 1 2 3 4)dev> (source clojure.set/union)
(defn union
"Return a set that is the union of the input sets"
{:added "1.0"}
([] #{})
([s1] s1)
([s1 s2]
(if (< (count s1) (count s2))
(reduce conj s2 s1)
(reduce conj s1 s2)))
([s1 s2 & sets]
(let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
(reduce into (first bubbled-sets) (rest bubbled-sets)))))2.6.17react to preact-compat when targeting :npm-module to build the leaves (view components) of an existing JS preact app in CLJS. Would you all expect this to work for my shadow-cljs.edn?
{:source-paths ["src"]
:dependencies [[cljs-css-modules "0.2.1"]
[reagent "0.8.1"]]
:builds {:npm {:target :npm-module
:output-dir "build/cljs"
:compiler-options {:infer-externs :auto}
:js-options {:resolve {"react" {:target :npm
:require "preact-compat"}
"react-dom" {:target :npm
:require "preact-compat"}}}}}}
When I npx shadow-cljs compile npm I get
[:npm] Build failure: The required namespace "react" is not available, it was required by "reagent/core.cljs".The only way I've found to move forward is to create symlinks from
node_modules/[react|react-dom] to node_modules/preact-compat:resolve is not supported for :npm-module or rather it is very limited:browser really. for :npm-module you really need to configure it in whatever you are targetting:resolve?another.ns> (require '[policy-fn.env :as env]) Circular dependency detected: policy-fn.env -> policy-fn.env (require '[policy-fn.env :as env])
clojure.string[:did-not-find ...]set instead of (into #{})-> and ->>into but yes set would have prevented this problem. Kinda still using into because it used to be faster ...Module Entry "cambia.web.experience.dashboard.components.survey-prompt.client" was moved out of module ":survey-prompt".
It was moved to ":main" and used by #{:onboarding :survey-prompt}.
and the bundle is not created:entries for one of your modules:survey-prompt module useless:main previously as well:main larger that it would otherwise beshadow-cljs - browser quickstart should it be possible to just do an npm install to use an npm module. I tried, https://github.com/gklijs/shadow-gol-3d (last commit, rest is copy) but it keeps saying The required JS dependency "game-of-life-3d" is not available, it was required by "gol/main.cljs". Searched in:/Users/gerardklijs/Workspace/shadow-gol-3d/node_modules You probably need to run: npm install game-of-life-3dbut when I look in node_modules it's there
.wasm yet so that module won't loadmain but only module.wasm file.js file is Rust output?[:did-not-find policy-fn.api.query-events] error when connecting to nrepl? it does not happen in socket REPL but it does in nrepl, I switch a couple of versions of shadow, now on 2.6.10REPL command timed out. followsin-ns before require or nsin-ns before the policy-fn.api.query-events has been compiled.js files imports the .wasm and the .wasm imports the .js file right back.js in any meaningful way 😛(cider-nrepl-request:eval (format "(in-ns '%s)" ns)
(cider-repl-switch-ns-handler connection))
in-ns is fine but what is happening BEFORE that? where is the require or so?node-repl?select-nrepl(import "./game_of_life_3d" "__wbg_time_ff03c978915ebe44" (func $./game_of_life_3d.__wbg_time_ff03c978915ebe44 (type $t2))) (import "./game_of_life_3d" "__wbg_timeEnd_5ba22134470392e6" (func $./game_of_life_3d.__wbg_timeEnd_5ba22134470392e6 (type $t2))) (import "./game_of_life_3d" "__wbg_random_86efc8986c8a8805" (func $./game_of_life_3d.__wbg_random_86efc8986c8a8805 (type $t3))) (import "./game_of_life_3d" "__wbindgen_throw" (func $./game_of_life_3d.__wbindgen_throw (type $t2)))
<script type="module" ...>(--> id "20" op "eval" session "b5cba90b-dd4f-446a-81ea-2a02be297cb2" time-stamp "2018-10-24 14:32:34.813926979" code "(in-ns 'laputa.policy-fn.api.query-events)" ) (<-- id "7" session "b5cba90b-dd4f-446a-81ea-2a02be297cb2" time-stamp "2018-10-24 14:32:34.864485854" out "[:did-not-find laputa.policy-fn.api.query-events] " ) (<-- id "20" session "b5cba90b-dd4f-446a-81ea-2a02be297cb2" time-stamp "2018-10-24 14:32:44.826639415" err "REPL command timed out. " )
require for that ns?(in-ns 'i.do.not.exist)(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s)):target? how is it started?node-repl? :browser?require?yarn shadow-cljs watch azdeps.edn:target :azure-app?yarn shadow-cljs watch az --verbosefn-map?(require 'laputa.policy-fn.api.query-events) (in-ns 'laputa.policy-fn.api.query-events)in-ns without require first also sucks in clojure(in-ns 'foo.bar) => #object[clojure.lang.Namespace 0x25e67a35 "foo.bar"] (+ 1 2) CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(C:\Users\thheller\AppData\Local\Temp\form-init11452515739617339391.clj:1:1)
[:not-required .....]? It would be clearer what you have to do next and what the problem was$ cljs-node-repl [Rebel readline] Type :repl/help for online help info cljs.user=> (in-ns 'foo.bar) foo.bar=> (+ 1 2) 3 foo.bar=>
in-ns into a ns that actually exists but was not required yet?shadow/repl instead shadow/select-nrepl, maybe I should PR cidershadow/repl IMHO but for a tool it doesn't matter(defmacro defstart! [args & body]
`(do
(defn ~'-start! ~args
{:export true :dev/after-load true} from a macro. not having any success yet(defmacro defstart! [args & body]
`(do
(defn ~'-start! ~args
shadow.loader in dev, it seems to 404 since it’s making the request for the additional compiled JS files to the port that the actual application is running in (5000), and not the port that the shadow dev server is serving the JS files from (3449). I have {:devtools {:loader-mode :eval :http-port 3449 :http-root "resources/public"}} set in the associated build, is there anything else I might be missing?:asset-path is correct:loader-mode :eval still a valid flag? I think at one time it was used to opt-in to a new loading mode, but can’t find any mention of it in the docs.loader-mode :eval2.6.182.6.10 so that might be it2.6.18 and still running into the same issue. The app has a script tag to load the main JS bundle from the shadow dev server (http://localhost:3449/js/compiled/dev/main.js), which is working fine. Are you saying that any modules loaded via shadow.loader (e.g. /js/compiled/dev/cljs-runtime/lazily_loaded_module.js) won’t load from that same localhost:3449, but that our application server (instead of the shadow-cljs devtools server) needs to be configured to statically serve the compiled JS bundles?<script src="">?:asset-path to {:devtools {:push-state/headers {"content-type" "text/html; charset=utf-8"
"access-control-allow-origin" "*"}
to my shadow-cljs.edn, but don’t see the second header.:5000 just serve the files?:3449 and let it proxy to :5000 for API stuff:devtools {:proxy-url ""}aborted par-compile, [:shadow.build.classpath/resource "garden/compiler.cljc"] still waiting for #{garden.units}
{:aborted [:shadow.build.classpath/resource "garden/compiler.cljc"], :pending #{garden.units}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "garden/compiler.cljc"] still waiting for #{garden.units}
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)still wanting for usually changes, so I'm wondering if that's some shadow timeout? if it is, can I increase it somehow? as the codebase grows I'm feeling its starting to happen more often, a second trigger of the build usually works:build-options {:par-timeout <num-in-ms>}garden.units is compiled before garden.compiler.garden.compiler is even waiting for compile is when a thread is becoming available while the others are still compilinggarden.units takes 60sec to compile:verbose true (globally in config) or run with --verbosegarden.units should never take this long to complete and it must have started no matter how many other jobs there aregarden.units to completecljs.core as well, and I'm running 2 parallel builds, the total compilation time gets to about 6 minutes when it works.js files, but I can't remember how I fixed that, is that a way to tell the compilation to dont mangle code from .js files?shadow-cljs check the-build should tell yourelease builds don't run in parallel by defaultshadow-cljs.edn?deps.edn alias?shadow-cljs -A :foo:bar?:modules?.wasm is structured.wasm file and a .json or .edn file that has some data about the filejs/fetch the .wasm file an instantiate itinstantiateStreaming.wasm into shadow-cljs to make things nicer.wasm file I don't have and can't produce.wasm file + metadata.wasm file + metadata I can work something out.wasm file I have is never going to worklein with-profiles +whatever run -m shadow.cljs.devtools.cli release whatevershadow-cljs release whateverlein thing you want{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "77101e0337101e031f02155914181a"}, :content ("[email protected]")}
I'm getting nothing but Build failure: from the watch task and this from the server:
...
shadow-cljs - nREPL server started on port 42651
Exception in thread "async-dispatch-5" java.lang.Error: java.net.SocketException: Socket closed
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
at java.io.BufferedWriter.flush(BufferedWriter.java:253)
at clojure.core$flush.invokeStatic(core.clj:3703)
at clojure.core$prn.invokeStatic(core.clj:3713)
at clojure.core$prn.doInvoke(core.clj:3706)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at shadow.cljs.devtools.server.util$stdout_dump$fn__13982$state_machine__6460__auto____13987$fn__13990.invoke(util.clj:213)
at shadow.cljs.devtools.server.util$stdout_dump$fn__13982$state_machine__6460__auto____13987.invoke(util.clj:213)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__6478.invoke(ioc_macros.clj:986)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__2089$fn__2090.invoke(channels.clj:95)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more
This is me toying around with shadow's electron example. This is one thing ya gotta love about clojuresque languages. Opaque error messages. Anyone have an idea what it is (and why it doesn't tell me anything useful)?shadow-cljs server and open shadow-cljs run2.6.19 which now does release sequentially instead of parallelshadow-cljs always tracks the latest CLJS version and it is not recommended to change that. Downgrades are generally not supported. You can use master in most cases unless there have been breaking changes but I'm not aware of any. There was supposed to be a new release a while ago ...{:source-paths ["src"]
:dependencies []
:builds {"app" {:output-dir "target/"
:asset-path "."
:target :browser
:modules {"main" {:init-fn app.main/main!}}
:devtools {:after-load app.main/reload!
:http-root "target"
:http-port 8080}}}}
"app" instead of :app to indicate that it's specified by me and not part of shadow-cljs' options."main":modules is always specified by you, not sure how a string would make that clearer?:depends-on when code splitting:depends-on #{"foo" "bar"} vs :depends-on #{:foo :bar}{"foo": {"bar": 1}} in JS either to express that it is "your" value.{foo: {bar: 1}} is possible and used, not .json files):modules {"SOMETHING foo \ bard" {:init-fn ...}}} would be bad:modules map will become the filenameshadow-cljs.edn for some weeks then looks into it again, I feel a bit confused that :main is in shadow-cljs' specification and where do I specify the filename.:index it is completely up to you:foo.bar or :foo-bar is perfectly valid. what would :foo/bar give you?(defn- update-values [m f & args]
(reduce (fn [r [k v]]
(assoc r k (apply f v args))) {} m))
(defn exclude-dev-code
{:shadow.build/stages #{:compile-finish}}
[build-state]
(update-in
build-state
[:output]
update-values
(fn [value]
(update-in value [:source]
#(clojure.string/replace
%
#"(?s)([^\n]+)\;\; exclude-line"
"")))))
but unfortunately this approach doesn’t work. Can you explain me please what am I doing wrong?:source in :output is only used for source map and you are calling it in :compile-finish which is after CLJS compilation:compile-prepare and inside :sources(ns test.components.app.nav.view (:require [ghostwheel.core :refer [>defn =>]] ;; clj-exclude-line
[quil "2.7.1"] to :dependencies in shaldow-cljs.edn and use the quil.core namespace, but it fails to compile with the following error:The required namespace "org.processingjs.Processing" is not available, it was required by "quil/core.cljc"
(ns org.processingjs.Processing (:require ["processing" :as proc])) (js/goog.exportSymbol "the-global-quil-uses" proc)
(js/goog.exportSymbol "Processing" proc) I guess[2018-10-28 09:54:53.504 - WARNING] provide conflict for #{clojure.string} provided by out/clojure/string.js and {"/clojure/string.cljs" #{clojure.string}}
[2018-10-28 09:54:53.504 - INFO] filename violation for ns vimsical.re-frame.fx.track, got: out/vimsical/re_frame/fx/track.cljc expected: vimsical/re_frame/fx/track.cljs (or .cljc)project.clj, therefore we use :lein true:app build looks basically like this:builds {:app {:target :browser}
:module-hash-names true
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:module-loader true
:modules {:common {:entries [foobar.main]}
.. a few other modules..}
:devtools {:http-port 4000
:http-root "resources/public"
:http-handler shadow.http.push-state/handle
:before-load foobar.main/before-load
:after-load foobar.main.main/after-load
:preloads [dev.preloads]
:loader-mode :eval}
:js-options {:resolve {"object.assign" {:target :npm :require "object-assign"}}}
:dev {:compiler-options {:optimizations :none
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
:release {:compiler-options {:optimizations :advanced}}}out seems to be on the classpath?:source-paths or :resource-paths?project.clj says :resource-paths ["resources"]:resource-paths elsewhere doesn't seem to affect the warnings.out in our source or configuration. Is it some internal shadow-cljs thing?out directory. maybe its leftovers from cljsbuild or so?^js you currently have since they are all incorrect^js this is requiredcljs file on a (possibly) complex react/jsx/npm project?.jar of one of our dependencies (https://github.com/vimsical/re-frame-utils) from clojars contains a directory called out (6.2 megabytes), which in turn contains cljs, goog, .. re_frame, .. reagent.. and a bunch of other compiled js libraries. Now I'm no expert on building packages, but that doesn't seem quite right?(def check-spec-interceptor (after (partial check-and-throw :custodian_assets.db/db)))
alpha.cljs:71 Uncaught Error: Unable to resolve spec: :custodian_assets.db/db
at Object.cljs$spec$alpha$reg_resolve_BANG_ [as reg_resolve_BANG_] (alpha.cljs:71)
at Object.cljs$spec$alpha$Specize$specize_STAR_$arity$1 (alpha.cljs:128)
at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:124)
at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:141)
at Function.cljs$core$IFn$_invoke$arity$2 (alpha.cljs:359)
at custodian_assets$handlers$check_and_throw (handlers.cljs:14)
at Function.G__14213__2 [as cljs$core$IFn$_invoke$arity$2] (core.cljs:4268)
at re_frame$std_interceptors$after_$_after_after (std_interceptors.cljc:313)
at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:68)
at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:106)(:require [cljsjs.semantic-ui-react]… in it. This adds about 600 files to my dev build, but when it’s compiled for production, only the actually used components will remain, or b/c it’s cljsjs, it’ll keep the whole semantic ui code? Thanks!(:require ["semantic-ui-react" ...])soda-ash lib uses cljsjs, so i should avoid that lib in shadow (?)shadow-cljs.edn file?:source-paths can only be configured once per shadow-cljs.edn, not per build. you run have multiple builds per config though that is perfectly fine. only code used in a build will actually be compiled:asset-path "/js" :release {:asset-path "/coolapp/js"}:dev {:asset-path ...} whichever you preferhttps for some reason403 Forbidden from cloudflare2.6.20rewriteHostHeader option for the proxy handler:asset-path but alone it does not work, assets have to be produced on specified path with specified :output-dir at least and I don't like that location is different for :dev and :release builds 😞:release {:output-dir "foo/bar"}:release specific config for years2.6.21 which fixed a couple issues with the proxy support and also now supports rewriting the host header:proxy-rewrite-host-header false to disable:devtools?master and there were 2 changes to the analyzer/compiler that aren't currently compatible. will need to wait for a final release. can't fix them now since that would break the current 1.10.339 releasemaster but I think they are getting ready to release "soon" nowbrowser.cljs:325 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
at shadow$cljs$devtools$client$browser$heartbeat_BANG_ ()NullPointerException when shadow-cljs release qiniu compiling a node-library:
:qiniu {:target :node-library
:output-to "out/node-library/qiniu.js"
:exports {:list qiniu.core/list-prefix
:del qiniu.core/delete-key
:clear qiniu.core/delete-keys}}
[:qiniu] Compiling ... NullPointerException: clojure.lang.Numbers.ops (Numbers.java:1018) clojure.lang.Numbers.dec (Numbers.java:120) shadow.build.warnings/get-source-excerpts/make-source-excerpt--10702 (warnings.clj:27) shadow.build.warnings/get-source-excerpts/iter--10704--10708/fn--10709/fn--10710 (warnings.clj:44) shadow.build.warnings/get-source-excerpts/iter--10704--10708/fn--10709 (warnings.clj:43) clojure.lang.LazySeq.sval (LazySeq.java:40) clojure.lang.LazySeq.seq (LazySeq.java:49) clojure.lang.RT.seq (RT.java:528) clojure.core/seq--5124 (core.clj:137) clojure.core.protocols/seq-reduce (protocols.clj:24) clojure.core.protocols/fn--7835 (protocols.clj:75) clojure.core.protocols/fn--7835 (protocols.clj:75) clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13) clojure.core/reduce (core.clj:6748) clojure.core/into (core.clj:6815) clojure.core/into (core.clj:6807) shadow.build.warnings/get-source-excerpts (warnings.clj:45) shadow.build.warnings/get-source-excerpts (warnings.clj:9) shadow.build.warnings/get-source-excerpts-for-rc (warnings.clj:51) shadow.build.warnings/get-source-excerpts-for-rc (warnings.clj:47) shadow.build/enhance-warnings (build.clj:34) shadow.build/enhance-warnings (build.clj:21) shadow.build/extract-build-info/fn--12724 (build.clj:92) clojure.core/map/fn--5587 (core.clj:2745) clojure.lang.LazySeq.sval (LazySeq.java:40) clojure.lang.LazySeq.seq (LazySeq.java:49) clojure.lang.RT.seq (RT.java:528) clojure.core/seq--5124 (core.clj:137) clojure.core.protocols/seq-reduce (protocols.clj:24) clojure.core.protocols/fn--7835 (protocols.clj:75) clojure.core.protocols/fn--7835 (protocols.clj:75) clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13) clojure.core/reduce (core.clj:6748) clojure.core/into (core.clj:6815) clojure.core/into (core.clj:6807) shadow.build/extract-build-info (build.clj:94) shadow.build/extract-build-info (build.clj:64) shadow.build/update-build-info-after-compile (build.clj:102) shadow.build/update-build-info-after-compile (build.clj:100) shadow.build/compile (build.clj:354) shadow.build/compile (build.clj:344) shadow.cljs.devtools.api/release* (api.clj:306) shadow.cljs.devtools.api/release* (api.clj:293) shadow.cljs.devtools.cli/do-build-command (cli.clj:29) shadow.cljs.devtools.cli/do-build-command (cli.clj:26) shadow.cljs.devtools.cli/do-build-commands (cli.clj:51) shadow.cljs.devtools.cli/do-build-commands (cli.clj:40) shadow.cljs.devtools.cli/main/body-fn--15607--auto----16461 (cli.clj:168) shadow.cljs.devtools.cli/main (cli.clj:167) shadow.cljs.devtools.cli/main (cli.clj:134) clojure.core/apply (core.clj:661) clojure.core/apply (core.clj:652) shadow.cljs.devtools.cli/-main (cli.clj:221) shadow.cljs.devtools.cli/-main (cli.clj:219) clojure.lang.Var.applyTo (Var.java:702) clojure.core/apply (core.clj:657) clojure.main/main-opt (main.clj:317) clojure.main/main-opt (main.clj:313) clojure.main/main (main.clj:424) clojure.main/main (main.clj:387) clojure.lang.Var.applyTo (Var.java:702) clojure.main.main (main.java:37)
shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn cli version: 2.6.21 node: v8.9.4into [] of extract-build-info of build.clj.2.6.22 which catches those exceptions since they are not critical. would help if you could paste the remaining warnings so that I can maybe figure out why it would fail to extract the source excerpt.core.async to work it in... just curiousjs/require itcore.async fetch[com.google.javascript/closure-compiler-unshaded "v20180910"] or laterhawk library.2.6.23. error might still happen but now I should be able to fix it if it does.:output-to, but I have not triedrelease you get an optimized filelein for CLJ. as far as sharing sources is concerned you just point both at the same :source-paths and use the code as normal:source path and slurp it back in my cljs file?js->clj.project.clj they use :external-config {
:devtools/config {
:features-to-install [:formatters :hints]
:fn-symbol "F"
:print-config-overrides true}}:compiler-options {:external-config {:devtools/config ...}}} should do itlein ancient-ish plugin for shadow-cljs for deps?yarn update-interactive to update your javascript dependencies.depot with deps.edn or lein-ancient with project.clj, depending on how you encode your dependencies.ncu all the time for package.json, the clojure deps tend to update way slower than npm 🙂 well, I could do it, at minimum I hope I planted seeds 😛clj-run, and calling watch and server within this task? Maybe there's another way?IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
clojure.lang.RT.seqFrom (RT.java:550)
clojure.lang.RT.seq (RT.java:530)
clojure.core/seq--5124 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--7829 (protocols.clj:75)
clojure.core.protocols/fn--7829 (protocols.clj:75)
clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
clojure.core/reduce (core.clj:6748)
list?load-file from the REPL to reload the code manuallydev and src, with "base" deps + "devcards" dep
one just with src, with "base" deps.
How can I write it in shadow-cljs.edn?dev build, you'll require the base and devcards namespaces:require in your namespaces2.2.x). I found that something changed in 2.3.9 which causes ReferenceError: goog is not defined errors when loading cljs.core macros (`/js/compiled/bootstrap/js/e9a22ddf.cljs.core$macros.js`), the stacktrace points to the first line, goog.provide('cljs.core$macros');.
Not a lot changed between 2.3.8 and 2.3.9, https://github.com/thheller/shadow-cljs/compare/2.3.8...2.3.9:output-wrapper default changed so that may be causing the issues:compiler-options {:output-wrapper false}:simple for the host build?goog is not defined is probably cause by the output-wrappernpm install some packages, but I will have some global variables exported (ie js/FlipMove), which means that somehow these lines are still taken into account? https://github.com/cljsjs/packages/blob/ade50f320730c9f144382a519414e09c8ba73fe5/react-flip-move/build.boot#L33-L36npm install some packages, but I will have some global variables exported (ie js/FlipMove), which means that somehow these lines are still taken into account? https://github.com/cljsjs/packages/blob/ade50f320730c9f144382a519414e09c8ba73fe5/react-flip-move/build.boot#L33-L36cljsjs, but they dontshadow-cljsjs ? because I thought I had to add it manually, but ok that would make sense... Thanks!! I was confused 🙂63 | (when (exists? event.target.files) ------------------------------------^------------------------------------------- js/event is shadowed by a local
(let [event ...] ...)? exists? assumes to only check global variableswatch running while npm install was doing its thing?watch since npm modifies so many files"inferno": "^6.1.4",
"inferno-clone-vnode": "^6.1.4",
"inferno-compat": "^6.1.4",
"inferno-create-class": "^6.1.4",
"inferno-create-element": "^6.1.4",node_modules/inferno-compat actually had the new version?:resolve settings?:js-options {:resolve {"moment" false
"react" {:target :npm :require "inferno-compat"}
"react-dom" {:target :npm :require "inferno-compat"}
"create-react-class" {:target :npm :require "inferno-reagent-compat"}
"jquery" {:target :global
:global "jQuery"}}}requirerequire the local file that I've compiled...The required JS dependency "../../dist/test.js" is not available, it was required by "workers/core.cljs".
reitit and the maintainer (@ikitommi) noted that there’s something weird about how backtick resolution works with shadow-cljs. This code https://github.com/dancek/reitit-frontend-spec-coercion-repro runs (js/console.log `int?)and the value is
starter.browser/int? instead of the expected cljs.core/int?. Did I do something wrong or is that a bug?2.6.24 which fixes the incorrect int? resolve. thanks for the report.:npm-module (with :entries) and the :node-library target?:node-library has one thing JS can require while :npm-module has one per NS:output-dir to node_modules when using :node-library if I'm looking for smooth JS ecosystem interop?:node-library:node-library can't do (eg. multiple require entries). in them are now checked more strictly and may produce warnings when used improperly. without validation (eg. i.dont.exist) would not warn at compile time and only fail at runtime~/.shadow-cljs directory and your ~/.m2/repository directory and create a new project directory and go in there and do shadow-cljs init then see if you can put something in there to work. (`~` here is my home directory. Not sure how that is designated under windows).lein or deps.edn and did not do that upgrade?reagent with npm React with shadow-cljs do I need to exclude cljsjs/react from reagent dependency and add empty cljsjs/react ns definitions to the project or it is taken care of automatically?npm install react react-dom create-react-class------ WARNING #1 --------------------------------------------------------------
File: com/rpl/specter.cljc:1275:19
--------------------------------------------------------------------------------
1272 | ns (namespace structure)]
1273 | (cond (keyword? structure) (keyword ns new-name)
1274 | (symbol? structure) (symbol ns new-name)
1275 | :else (i/throw-illegal "NAME can only be used on symbols or keywords - " structure)
-------------------------^------------------------------------------------------
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
1276 | ))))
1277 |
1278 | (defnav ^{:doc "Navigates to the namespace portion of the keyword or symbol"}
1279 | NAMESPACE
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: com/rpl/specter.cljc:1288:19
--------------------------------------------------------------------------------
1285 | new-ns (next-fn (namespace structure))]
1286 | (cond (keyword? structure) (keyword new-ns name)
1287 | (symbol? structure) (symbol new-ns name)
1288 | :else (i/throw-illegal "NAMESPACE can only be used on symbols or keywords - " structure)
-------------------------^------------------------------------------------------
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
1289 | ))))
1290 |
1291 | (defdynamicnav
1292 | ^{:doc "Adds the result of running select with the given path on the
--------------------------------------------------------------------------------
com.rpl.specter.NAME_transform_STAR_ = (function com$rpl$specter$NAME_transform_STAR_(structure,next_fn){
var new_name = (function (){var G__36732 = cljs.core.name(structure);
return (next_fn.cljs$core$IFn$_invoke$arity$1 ? next_fn.cljs$core$IFn$_invoke$arity$1(G__36732) : next_fn.call(null,G__36732));
})();
var ns = cljs.core.namespace(structure);
if((structure instanceof cljs.core.Keyword)){
return cljs.core.keyword.cljs$core$IFn$_invoke$arity$2(ns,new_name);
} else {
if((structure instanceof cljs.core.Symbol)){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(ns,new_name);
} else {
throw (new java.lang.IllegalArgumentException(com.rpl.specter.impl.smart_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["NAME can only be used on symbols or keywords - ",structure], 0))));
}
}
});throw (new java.lang.IllegalArgumentException... is certainly not valid JS 😉#?(
:clj
(defmacro throw-illegal [& args]
`(throw* IllegalArgumentException defun?(defun ... is a third-party library.? .defun .deploy_cencus_function. notationcljs version too:
#?(
:clj
(defmacro throw-illegal [& args]
`(throw* IllegalArgumentException defun as well. It's a macro over the core.match macro 😄23 | (defun.core/defun deploy-census-function -------^------------------------------------------------------------------------ IllegalArgumentException: Invalid signature "..." should be a list clojure.core/assert-valid-fdecl/fn--8348 (core.clj:7405) clojure.core/map/fn--5587 (core.clj:2747) clojure.lang.LazySeq.sval (LazySeq.java:40) clojure.lang.LazySeq.seq (LazySeq.java:49)
defun to work at allrequire or sodefun still doesn't like the code[cljsjs.vega] [cljsjs.vega-lite] [cljsjs.vega-embed] [cljsjs.vega-tooltip]as well as:
[re-com.core
:as rcm
:refer [h-box v-box box gap line h-split v-split
button row-button md-icon-button md-circle-icon-button info-button
input-text input-password input-textarea
label title p
single-dropdown
checkbox radio-button slider progress-bar throbber
horizontal-bar-tabs vertical-bar-tabs
modal-panel popover-content-wrapper popover-anchor-wrapper]
:refer-macros [handler-fn]]
[re-com.box
:refer [h-box v-box box gap line flex-child-style]]
[re-com.dropdown
:refer [filter-choices-by-keyword single-dropdown-args-desc]]
[aerial.hanami.utils
:refer [title2 href]]
re-com.core and re-com.box have a :refer for h-box (and others)d3 is not complicated at all. just (:require ["d3" :as d3]) and then (d3/whatever ...)npm install d3 all I need?npm install d3 will add it to package.json automatically yes(def circle-demo
(
-> d3
(.select "#myCircle")
(.append "svg")
(.attr "r" "30")
(.attr "cx" "50")
(.attr "cy" "50")
(.attr "fill" "grey")
)
)
a valid syntax?
That's with "d3" required as d3deps.cljs in shadow...it looks like it does not read our custom registry setting in .npmrc...has anyone tried that?:managed-by option 😄react-sortable-hoc https://github.com/clauderic/react-sortable-hoc. I installed it locally using npm install extern/react-sortable-hoc. The package.json file contains the following:
"dependencies": {
"create-react-class": "^15.6.2",
"left-pad": "file:extern/left-pad",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-sortable-hoc": "file:extern/react-sortable-hoc"
}
I have also checked that node_modules/react-sortable-hoc is pointing to the extern/react-sortable-hoc. But when I refer to this library from cljs, the following error appears
[:frontend] Build failure: The required JS dependency "react-sortable-hoc" is not available, it was required by "sortable/frontend/sortable.cljs". Searched in:sortable/node_modulesAs a test, I git-cloned the
left-pad library and installed it locally, but it works.
(:require [reagent.core :as r :refer [atom]]
[reagent.ratom :refer-macros [reaction]]
["react-sortable-hoc" :as rsh]
["left-pad" :as lp]
npm install <packages-from-deps-cljs> or yarn add <packages> (if yarn.lock) exists.npmrc if that needs an extra flag or something?node_modules/react-sortable-hoc? npm sometimes leaves empty directories (non-linked)react-sortable-hoc? the git repo does not contain the dist files so that may be the problem?npm install. Running npm run-scripts build works.1.10.439project.clj2.7.0 for example requires 1.10.439+ since there were some breaking changes in the cljs.analyzer (given that breaking changes are quite rare){:test #(assert...)} metadata of a function? If not, I can pull them out. I just liked that I could have my tests right next to my functions...yarn add that Shadow launches is not see my .yarnrc ...HOME are not set when the shell with yarn add is launched?ProcessBuilder and they should be setclosure-defines in my release?:release {:compiler-options {:optimizations :advanced}}
node_modules and js/compiled folders (`js/compiled` is my output-dir).
But... after that, a few warnings and misbehaviors shows up... the first one is these several warnings that compiler is now showing:------ WARNING #1 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/events.cljc:61:11
--------------------------------------------------------------------------------
58 | (if *handling*
59 | (console :error "re-frame: while handling \"" *handling* "\", dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler.")
60 | (binding [*handling* event-v]
61 | (trace/with-trace {:operation event-id
-----------------^--------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.events/java
--------------------------------------------------------------------------------
62 | :op-type kind
63 | :tags {:event event-v}}
64 | (interceptor/execute event-v interceptors)))))))
65 |
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:48:29
--------------------------------------------------------------------------------
45 | (let [cache-key [query-v dynv]]
46 | ;; when this reaction is no longer being used, remove it from the cache
47 | (add-on-dispose! r #(do (swap! query->reaction dissoc cache-key)
48 | (trace/with-trace {:operation (first-in-vector query-v)
-----------------------------------^--------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
49 | :op-type :sub/dispose
50 | :tags {:query-v query-v
51 | :reaction (reagent-id r)}}
52 | nil)))
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:111:4
--------------------------------------------------------------------------------
108 | "
109 |
110 | ([query]
111 | (trace/with-trace {:operation (first-in-vector query)
----------^---------------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
112 | :op-type :sub/create
113 | :tags {:query-v query}}
114 | (if-let [cached (cache-lookup query)]
115 | (do
--------------------------------------------------------------------------------...
:dependencies [
[re-frame "0.10.5"]
[day8.re-frame/re-frame-10x "0.3.3-react16"]
..."dependencies": {
"@material-ui/core": "^1.3.1",
"@material-ui/icons": "^1.1.0",
"@material-ui/lab": "^1.0.0-alpha.5",
"create-react-class": "^15.6.3",
"highlight.js": "^9.13.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-flip-move": "^3.0.1",
"react-highlight.js": "^1.0.7",
"d3": "^3.5.16"
},
"devDependencies": {
"shadow-cljs": "^2.4.17"
}if((i__34699_34962 < count__34698_34961)){
var vec__34702_34963 = chunk__34697_34960.cljs$core$IIndexed$_nth$arity$2(null,i__34699_34962);
var k__34636__auto___34964 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__34702_34963,(0),null);
var cb__34637__auto___34965 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__34702_34963,(1),null);
try{var G__34706_34970 = new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(mranderson048.re_frame.v0v10v2.re_frame.trace._STAR_current_trace_STAR_,new cljs.core.Keyword(null,"duration","duration",1444101068),duration__34635__auto___34957,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"end","end",-268185958),mranderson048.re_frame.v0v10v2.re_frame.interop.now()], 0))], null);
(cb__34637__auto___34965.cljs$core$IFn$_invoke$arity$1 ? cb__34637__auto___34965.cljs$core$IFn$_invoke$arity$1(G__34706_34970) : cb__34637__auto___34965.call(null,G__34706_34970));
}catch (e34705){if((e34705 instanceof java.lang.Exception)){
var e__34638__auto___34973 = e34705;
mranderson048.re_frame.v0v10v2.re_frame.loggers.console.cljs$core$IFn$_invoke$arity$variadic(new cljs.core.Keyword(null,"error","error",-978969032),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Error thrown from trace cb",k__34636__auto___34964,"while storing",mranderson048.re_frame.v0v10v2.re_frame.trace._STAR_current_trace_STAR_,e__34638__auto___34973], 0));
} else {
throw e34705;if((e34705 instanceof java.lang.Exception)) is certainly not valid JSshadow-cljs release and I just want to turn it off for now. I thought I could do that with:
:builds {:main {:target :browser
...
:modules {.. some modules...}
:compiler-options {:optimization :simple
:infer-externs :auto}}
But it seems that doesn't have any effect on the minification. I added the infer-externs so I could see if I'm running the right build and it does have an effect. Not sure what's going on.. 🤔:optimizations not :optimizationshadow-cljs info) that the nrepl dependence are different. How can I get the specific library that is bringing that lib to my project? I mean.. I don't have nrepl as a declared dependence, so I think that another one is bringing that. It is possible to build a graph showing who is bringing who?shadow-cljs --cli-info shows a basic graphinfo and --cli-info are the same... I can't see diffence among then(= "nodejs"
(-> @cljs.env/*compiler*
:options
:closure-defines
(get 'cljs.core/*target*)))
:compiler-options ends up in (:options @cljs.env/*compiler*) so you could add your own option:compiler-options {:external-config {...}} has some extra treatment to invalidate all cache when anything in there changes(:require [#?(:node some.thing :cljs some.other-thing) :as foo]):jvm-opts ["-Xmx1G"] in the shadow-cljs.edn top level-Xmx256M but probably not much lower than thatCaused by: java.lang.RuntimeException: Unable to resolve var: comp/*source-map-data-gen-col* in this context2.7.X requires CLJS 1.10.439. this is enforced when using shadow-cljs.edn but lein or so may need manual tweaking2.4.24 did not use that binding1.10.339 so at least one version differs.cpcache directory 😞 😞 😞shadow-cljs watch [...]
- CLJS REPL: the sibling of the above
Is this the expected situation? cider-find-var doesn't seem to be working, but I can interact with the browser from the CLJS REPL.cider-find-var is or does thoughcider-find-var is a jump-to-definition.(shadow/nrepl-select :build-name) in that repl buffer windowdeps.cljs and add {:npm-deps {"that-lib" "1.2.3"}}deps.cljs must be on the classpath and yes deps.cljsdeps.edn usually isn'tcider-find-var is not working yet, though~/.clojure/deps.edn cider/cider-nrepl {:mvn/version "0.18.0-SNAPSHOT"}shadow-cljs.ednuser-error: ‘cider-find-var’ requires the nREPL op "info" (provided by cider-nrepl).clojure/deps.edn refactor-nrepl {:mvn/version "2.4.0"}re-frame-10x warnings you reported a few days ago https://github.com/Day8/re-frame-10x/issues/219refactor-nrepl to my shadow-cljs.edn, and cider-find-var is working now..dir-locals.el, BTW.:node-script but I get:
node bin/migrate-event-store
Error: ENOENT: no such file or directory, open '/home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:47:15)
at /home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3006:1
at Object.<anonymous> (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3115:3)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
what was the reason for that again?.shadow-cljs dir without recompiling?-rw-rw-r-- 1 arichiardi arichiardi 5671 Nov 13 10:04 goog.debug.console.js -rw-rw-r-- 1 arichiardi arichiardi 19066 Nov 13 10:04 goog.debug.debug.js -rw-rw-r-- 1 arichiardi arichiardi 1713 Nov 13 10:04 goog.debug.errorcontext.js -rw-rw-r-- 1 arichiardi arichiardi 1797 Nov 13 10:04 goog.debug.error.js -rw-rw-r-- 1 arichiardi arichiardi 13935 Nov 13 10:04 goog.debug.formatter.js -rw-rw-r-- 1 arichiardi arichiardi 4312 Nov 13 10:04 goog.debug.logbuffer.js -rw-rw-r-- 1 arichiardi arichiardi 26315 Nov 13 10:04 goog.debug.logger.js -rw-rw-r-- 1 arichiardi arichiardi 6131 Nov 13 10:04 goog.debug.logrecord.js -rw-rw-r-- 1 arichiardi arichiardi 2404 Nov 13 10:04 goog.debug.relativetimeprovider.js
/home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js?/home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js:output-to file generated by the build :output-to "./bin/migrate-event-store"var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/script/dev/out/cljs-runtime'; at the beginning somewherevar SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/migrate/dev/out/cljs-runtime';2.6.23 in this projectif (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime"; }__dirname is HEY /home/arichiardi/git/laputa/event-store/binconsole.log:output-to "bin/migrate-event-store":output-to is always relative to the project root so ./ is pointless:node-script REPLs 😄{:target :node-script
:main laputa.event-store.migrate/-main
:output-to "bin/migrate-event-store"
:release {:compiler-options {:optimizations :advanced
:source-map true}}}
$ cat .shadow-cljs/config.edn
{:node-modules {:install-cmd ["--network-concurrency" "1" :packages]}}
running: yarn add ... packages$HOME...but I also can put it in shadow-cljs.edn it seemsshadow-cljs - config: /home/arichiardi/git/laputa/scrutinize-fn/shadow-cljs.edn cli version: 2.7.3 node: v8.12.0 shadow-cljs - starting via "clojure" running: yarn add --network-concurrency 1 ....packages....
shadow-cljs.edn or ~/.shadow-cljs/config.edn.shadow-cljs in the project dir is a useful location(shadow/release :prod) for the production build, do we need to do compression ourselves?gzip -9 js-file.jsbuild-state from within a :flush build hook?:build-sources key has the resource-ids in dependency order(get-in build-state [:sources resource-id]) and [:output resource-id] for the source and generated output:shadow.build/build-info which has the full summary:compiles #{rc-a rc-b} set for each resource that was actually compiled(shadow.build/resources-compiled-recently build-state)watch):shadow.build/build-info is what the websocket uses to decide which code to reload and stuff so that might be most useful(get-in build-state [:shadow.build/info :compiled]) contains exactly what I need.[:img {:src "${img/ponys.png}"}] becomes [:img {:src "${img/ponys-HASH.png}"}][:img {:src (helper/get-img-src "img/ponys.png")}]helper/get-img-src fn look it up from the JSON objectget-img-src references a built manifest file?:compile-prepare hook but getting correct caching is tricky enough as it isimg->hashed-img-path map available to the implementation of get-img-src.:compile-finish (or :flush)(defn get-img-src [path] (or (goog.object/get js/your$lookup$map path) path))echo "\nvar your$lookup$map = {"img/ponys.png": "img/ponys-HASH.png"};" >> main.jsecho though?!build-state can I prepend to the top of main.js?mode to either skip or fingerprint the assets.ponys.png will the browser receive a message to reload that asset?get-img-src return the original either via a :closure-define or some logic that checks if the path was overridden:flush will be called after the file has been written:configure by basically setting :modules {:main {:prepend-js "var lookup$map = <json>;\n"}}}(update-in build-state [:shadow.build.modules/config <module-id> :prepend-js] str "var lookup$map = " (json/write-str {"foo" "bar"})):prepend-js or :append-js doesn't really matter:prepend :append:prepend-js will go through :advanced so the closure compiler may be smart enough to directly inline the stringsget-img-src lookup completely:compile-prepare you can modify the sourceD:\home\.shadow-cljs\builds\az\dev\out\cljs-runtime\goog.debug.error.jsaz is the name of target :azure-app./ and it should work:app-dir "azure/build"SHADOW-IMPORT like yesterdayvar SHADOW_IMPORT_PATH = __dirname + '/../../../.shadow-cljs/builds/az/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/Users/user/github-ep/laputa/commit-event-fn/.shadow-cljs/builds/az/dev/out/cljs-runtime"; }
global.$CLJS = global;
./{:exports fn-map
;; FIXME: can't have a {:cljs some.ns/fn} function when using cljs dir
:output-to (str app-dir "/cljs/shared.js")}`
d:\home windows location and the code snippet above is clearly not windowsrelease compiled filescompile or watchcljs-runtime it was not a release buildcompiled thing happened<- Cache read: cljs/core.cljs (151 ms)
-> Compile CLJS: cljs/core.cljs
------ ERROR -------------------------------------------------------------------
File: jar:file:/Users/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs
NullPointerException:
cljs.compiler/emit/fn--3144 (compiler.cljc:189)
clojure.lang.Atom.swap (Atom.java:37)
clojure.core/swap! (core.clj:2344)
clojure.core/swap! (core.clj:2337)
cljs.compiler/emit (compiler.cljc:187)
cljs.compiler/emit (compiler.cljc:182)
shadow.build.compiler/eval12942/fn--12943 (compiler.clj:238)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.build.compiler/default-compile-cljs/fn--12969 (compiler.clj:289)
shadow.build.compiler/default-compile-cljs (compiler.clj:288)
shadow.build.compiler/default-compile-cljs (compiler.clj:274)
clojure.core/partial/fn--5739 (core.clj:2617)
shadow.build.compiler/do-compile-cljs-string/fn--12930 (compiler.clj:227)
yarn install after updating to 2.7.3deps.edn? (or lein)yarn shadow-cljs for launching things but I am interesting in knowing more about deps.edn casedeps.edn because the version conflict above can't happen with pure shadow-cljs.edndeps.edn that can't be enforced so whatever you have in there will be useddeps.edndeps.edn basicallynpm run scripts will stop workingdeps.edn on startupshadow-cljs.edn so you don't get such issues 😉yarn shadow-cljs but haven't had the time to figure out the replacementclojure -A:shadow watch as a replacement["-m" "shadow.cljs.devtools.cli"] for whatever the args key way:main-opts?:after-load or :before-load hooks configured?load JS messageherman.core/mount-root or herman.core/init do? are you sure both should be called on reload?:dev/after-load metadata on it?:after-load herman.core/init in your build config?npx shadow-cljs watch server shadow-cljs - config: /home/claudiu/clojure/fulcro-nodejs-ssr-example/shadow-cljs.edn cli version: 2.7.3 node: v8.11.0 shadow-cljs - starting via "clojure" Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: comp/*source-map-data-gen-col* in this context, compiling:(shadow/build/compiler.clj:455:13)
1.10.339 to 1.10.439 fixed the error2.7.x depends on cljs 1.10.439 yes. since cljs added that backwards incompatible change older versions don't work anymore2.6.7 and got the error. 🙂1.10.439 can't be used <2.7.0src/main/app and src/main/server is not necessary. namespaces already split the code enough and server code won't be included in the app build:npm-module target (for now in convenience mode) to include some cljs into an existing JS project. I know that I can 'hot reload' the cljs code into the JS code base using shadow-cljs watch npm, but is it also possible to use a cljs repl with that target? I've tried using cider and manage to start a cljs repl, but everytime I try to eval something it tells me that the application hasn't connected to the REPL server. I've tried navigating to (which works), but this doesn't connect. Is connecting via browser even possible with :npm-module?:npm-module does not have a clearly defined entry the devtools cannot be injected automatically:runtime :browser in the config{:source-paths
["src"]
:dependencies
[]
:runtime :browser
:builds {}}
?:builds
{:npm
{:target :npm-module
:runtime-browser
:output-dir "node_modules/shadow-cljs"}}:runtime :browserrequire("shadow-cljs/shadow.cljs.devtools.client.browser") somewhere in your JSshadow-cljs watch mode to expose the value of an environment variable to a value in cljs-land?:browser-test target).shadow-cljs watch browser-test to get this, but then I don't have the app running as well. Do I need 2 watch processes? Can I combine them somehow? Or should I just use the :node-test target?shadow-cljs watch browser-test your-app runs 2 watcheswatch if you prefer to split the terminals and not have all output in one(require '["quagga" :default Quagga]) ; default export is nil, as it looks like what's in node_modules, doesn't have a nice index.js, etc
(require '["quagga/dist/quagga" :default Quagga])
; blows up with
failed to resolve: ./config.node.js from /Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js
{:relative-to #object[java.io.File 0x400fd1fa "/Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js"], :entry "./config.node.js"}
ExceptionInfo: failed to resolve: ./config.node.js from /Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.npm/find-relative (npm.clj:268)
; it works on node and in the browser, guessing that there's something going on with the conditional stuff?
(require '["quagga" :as Quagga]) seems to work fine. not sure why it has a default property in nodedist are not for build consumption and look like standalone builds that you'd include directly via <script>:default isn't available. it seems to be available on node:as works just fine for quagga "browser": "dist/quagga.min.js",if (false) {
config = require('./config.dev.js');
} else if (true) {
config = __webpack_require__(58);
} else {
config = require('./config.prod.js');
}:exclusions to the shadow dependency if I am using it through package.json. I tried a couple of things to no availdeps.edn?shadow-cljs.edndeps.edn but not for shadow, cause the automatic detection of server mode is not working unless I have it in package.json. Am I right?.shadow-cljs/http.port file which is written when the server is startedyarn shadow-cljs server from the parent and all the child projects could connect to itshadow-cljs server at the start of the day and leave that running?:source-paths ["lambda1/src/main" "lambda2/src/main"] and just create a combined config:dependenciesnode_modules...nice touch btw)shadow-cljs could wrap the lib and provide a fully fledged solution for monoreposrepo/lamba1/shadow-cljs.edn + repo/lamba2/shadow-cljs.edn OR repo/shadow-cljs.edn:source-paths ["lambda1/src" ...] and in the builds just use :app-dir "lambda1/output"` or whatevershadow-cljs.edn files .. extracts the builds and rewrites the pathsdeps.edn....if there is no reason I can think about moving 😉shadow-cljs npm package to actually talk to itclj -m shadow.cljs.devtools.cli release your-build is totally fine for CIclj -m shadow.cljs.devtools.cli server to start the dev serverdeps.edn but if you want to tweak stuff for CI thats your best option currently(if (find-ns 'shadow)...) maybe?js/goog.DEBUG is one of themre-frame . shadow-cljs gives me so many warnings, but I think things such as Use of undeclared Var re-frame.events/java re-frame.events/java are not exist in the source code. The error messages are:[re-frame "0.10.6"] [day8.re-frame/undo "0.3.2"] [day8.re-frame/http-fx "0.1.7"] [com.smxemail/re-frame-cookie-fx "0.0.2" ]
re-frame.2.6.24 for nowshadow-cljs clj-repl and ( "re_frame/trace.cljc") to check which file is actually getting used0.10.2. I removed .shadow-cljs and compiled again. Another question, @thheller. https://github.com/funcool/cats/blob/master/project.clj project like this uses (defproject funcool/cats ...), how should I require this? I use [cats.core :as m] but shadow-cljs tells me The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs"., while [funcool/cats.core :as m] just syntax error.defproject name is only relevant for the dependency itself. it has nothing to do with the namespaces you use in CLJS[funcool/cats "2.3.1"] but (:require [cats.core ...]).shadow-cljs should not affect anything in your dependencies?[funcool/cats "2.3.1"] this to my deps.[cats.core :as m] will get the error The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs"lein/`deps.edn` right?:dependencies in shadow-cljs.edn?{:dependencies
[[cljs-ajax "0.7.2"]
[reagent "0.8.0-alpha2"]
[reagent-utils "0.3.1"]
[re-frame "0.10.6"]
[day8.re-frame/undo "0.3.2"]
[day8.re-frame/http-fx "0.1.7"]
[secretary "1.2.3"]
[garden "1.3.3"]
[funcool/cats "2.3.1"] ;; <- just added this line
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.smxemail/re-frame-cookie-fx "0.0.2" ]
[com.taoensso/timbre "4.10.0"]
[hiccups "0.3.0"]
[thheller/shadow-cljsjs "0.0.16"]
[org.clojure/core.async "0.4.474"]]
shadow-cljs.edn:lein or :deps keys? please confirm thatlein install this?:lein no :depsshadow-cljs watch doumi. not start another server.shadow-cljs watch doumi shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn cli version: 2.7.4 node: v10.13.0 shadow-cljs - starting ... 11月 21, 2018 6:28:38 下午 org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final 11月 21, 2018 6:28:38 下午 org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/yuzhao/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider() WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release shadow-cljs - server version: 2.7.4 shadow-cljs - server running at shadow-cljs - socket REPL running on port 53798 shadow-cljs - nREPL server started on port 53800 shadow-cljs - watching build :doumi [:doumi] Configuring build. [:doumi] Compiling ... ^[[:doumi] Build failure: The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs".
shadow-cljs watch doumi [2h0m] ✹ ✭ shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn cli version: 2.7.4 node: v10.13.0 shadow-cljs - starting ... 11月 21, 2018 6:30:21 下午 org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final 11月 21, 2018 6:30:21 下午 org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/yuzhao/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider() WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release shadow-cljs - server version: 2.7.4 shadow-cljs - server running at shadow-cljs - socket REPL running on port 53912 shadow-cljs - nREPL server started on port 53914 shadow-cljs - watching build :doumi [:doumi] Configuring build. [:doumi] Compiling ... [:doumi] Build failure: The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs".
shadow-cljs clj-repl and ( "cats/core.cljc")[1:0]~shadow.user=> ( "cats/core.cljc") nil
shadow-cljs.edn?/Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn:source-paths conditionally:source-paths hack an anti-pattern and its not supported by shadow-cljs itself. you can still use it when using deps.edn or lein if you really want toinit function in your appyour.app.init() or something<script> or any other means really<script>var app$config = {"s3url":"...."};</script>index.html + index-dev.htmlUncaught ReferenceError: __webpack_require__ is not defined
at eval (index.js:1)
at Object../components/index.js (app.js:330)
at c (app.js:234)
at ./components/Button/Button.jsx (app.js:236)
at Object.shadow$provide.module$node_modules$$grantsolutions$grant_solutions_ui$dist$index (app.js:236)
at oI (app.js:1362)
at app.js:2070
at app.js:2164
Fortunately, this is a react lib that’s being developed by another group, so if I can figure out what the problem is I can have them tweak the build to fix this.
Any offhand ideas re: what might cause this. In poking around in the code, so far haven’t seen some of the other stuff that’s caused issues... ;; example of how we're pulling it in ["@grantsolutions/grant-solutions-ui" :as gsui] (def Button (uc/component-factory gsui/Button))
dist folder__webpack_require__ is defined in the index.js
function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
maybe it’s getting munged away in the release build?:npm-module?["@grantsolutions/grant-solutions-ui" :as gsui]module.exports = {
entry: "./components",
output: {
path: path.resolve(__dirname, "dist"),
filename: "index.js",
library: "",
libraryTarget: "commonjs"
},
plugins: [new MiniCssExtractPlugin(), new StyleLintPlugin()],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader", "eslint-loader"]
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader"
]
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: "file-loader"
}
]
},
resolve: {
extensions: [".js", ".jsx"]
}
};
---
{
"presets": ["@babel/env", "@babel/flow", "@babel/react"],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"flow-react-proptypes"
]
}
index.js// @flow // $FlowFixMe import "../styles/main.scss"; export * from "./Button"; export * from "./Icon"; export * from "./Notification"; export * from "./Form"; export * from "./Modal"; export * from "./Popover"; export * from "./Search"; export * from "./List"; export * from "./Table"; export * from "./utils"; export * from "./Progress";
__webpack_require__Uncaught TypeError: Cannot set property 'Error' of undefined
at app.js:768
at app.js:11615
And it looks like it’s goog.debug.Error that’s missingindex.js?webpack in production modewebpack -peval("__webpack_require__.r(__webpack_exports__);\n/* harm__webpack__require function was unused and removed it"compile": "run-s compile:*",
"compile:storybook": "build-storybook -o dist/storybook",
"compile:webpack": "webpack --mode=development",
"format": "run-s format:*",
"format:icons": "eslint components/Icon/glyphs/*.jsx --fix",
"prepack": "run-s clean:build test compile",
node_modules version of the lib you currently havenpm install"start": "start-storybook --port 1999",
"prepack": "run-s clean:build test compile",
"clean": "yarn clean:build && yarn clean:modules",
"clean:build": "rm -rf dist",
"clean:modules": "rm -rf node_modules",
"test": "run-s test:*",
"test:flow": "flow",
"test:eslint": "eslint components --ext .js --ext .jsx",
"test:stylelint": "stylelint styles",
"test:jest": "jest",
"compile": "run-s compile:*",
"compile:storybook": "build-storybook -o dist/storybook",
"compile:webpack": "webpack --mode=development",
"verify:eslint": "eslint --print-config .eslintrc | eslint-config-prettier-check",
"format": "run-s format:*",
"format:icons": "eslint components/Icon/glyphs/*.jsx --fix"
aside from the complie:webpack /npx babel components --out-dir outout folder should jsut contain a bunch of clean .js files["@grantsolutions/grant-solutions-ui/out/index.js" :as gsui] should then maybe work?lein or deps.edn to start the server?cider-jack-in-cljs-nrepl-middlewares is or means so I can't say if that is correct or notcider-jack-in + deps.ednshadow-cljs server and cider-connect or whatever thats calledlein. I just can't tell you how to do it for deps.edn + emacsshadow-cljs has been reporting this on my build:
------ WARNING #1 -------------------------------------------------------------- File: bidi/bidi.cljc:29:12 -------------------------------------------------------------------------------- 26 | actually a valid UUID (this is handled by the route matching logic)." 27 | [s] 28 | #?(:clj (java.util.UUID/fromString s) 29 | :cljs (cljs.core.UUID. s))) ------------------^------------------------------------------------------------- Wrong number of args (1) passed to cljs.core.UUID -------------------------------------------------------------------------------- 30 | 31 | ;; When forming paths, parameters are encoded into the URI according to 32 | ;; the parameter value type. 33 | --------------------------------------------------------------------------------It's a warning, so nothing serious as I can keep working with no problem. Just wondering: should I report it to
bidi?(cljs.core/uuid s)(uuid s)configure build hook similar to how we outlined it last week. Deploying today. If it all works then I'll run the implementation past you."shadow-cljs":"^2.6.12" or whatever:resource-name field come from in the rc map that the various shadow-cljs compiler functions use? I have a weird issue where increasingly large numbers of letters are being dropped from the beginning of the :resource-name for my cljs source files, which eventually causes the path to start with a /, which causes IllegalArgumentException: /middle-of-my-namespace/core.cljs.cache.transit.json is not a relative path when interacting with the cache. I scoured the source to try to figure out where the issue is coming from but I can't for the life of me figure out where the details for the source files are coming from.:resource-name is just a name. it is never used in any file ops..
├── client
│ └── core.cljs
└── src
└── main
└── my
└── namespace
└── client -> ../../../../clientclient -> src/main/my/namespace/client?2.7.6. I think it should work properly now*check-assert* in a shadow release compilation step?*check-asserts*?:compiler-options {:elide-asserts false}. not aware of any other.release[refactor-nrepl "2.4.0"] in my shadow-cljs.edn, I am connected to the nREPL server started by shadow-cljs watch via cider-connect and (shadow/nrepl-select my-app). When I try to do M-x cljr-clean-ns in a CLJS file, I get this: user-error: The refactor-nrepl middleware isn’t available! Did you remember to install it? Am I missing something?:nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]}shadow-cljs.edn?release build with the built-in development server?npx shadow-cljs serverwatch needs to be running:js-options {:js-provider :closure}shadow-cljs check app and got a bunch of warnings. All of them come either from cljs.core or from reagent - is that expected?Java from cljs.core yes that is expectedreagent not sure?------ WARNING #28 ------------------------------------------------------------- File: ~/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:10520 actual parameter 2 of goog.object.set does not match formal parameter found : (string|symbol) required: string --------------------------------------------------------------------------------
------ WARNING #31 ------------------------------------------------------------- File: ~/.m2/repository/reagent/reagent/0.8.1/reagent-0.8.1.jar!/reagent/impl/component.cljs:296:33 Property _reactInternalInstance never defined on G__2678 --------------------------------------------------------------------------------
goog.object.set is due to an outdated closure library I thinkcheck unfortunately is not very useful sometimesrelease 🙂:closure?:closure:closure. main.js is 95kb instead of 98kb with :shadow, nothing is rendered due to minified react error. And it was just react + material-ui with a single button rendered on the screen.:advanced:foreign-libs (https://github.com/clojure/clojurescript-site/blob/master/content/reference/packaging-foreign-deps.adoc), but shadow on the other side can import js files directly, but no :foreign-libs, I'm working in the Workspaces project and I have a dependency on a simple js file, is there a way to write it so users of the library get correct behavior with both standard cljs and shadow?document:foreign-libs are used before the classpath or after:modules {:main {... :web-worker true}}}{:foreign-libs
[{:file "react/react.js"
:file-min "react/react.min.js"
:provides ["com.facebook.React"]}]
:externs ["react/externs.js"]}:provides, so, in this case: (:require [com.facebook.React])goog.provide("some.ns.fuzzy") some.ns.fuzzy.fn = function ...goog.scope stuff for your file since its so shortgoog.provide("some.ns")some.ns.foo = function() ...$ shadow-cljs server shadow-cljs - config: /home/souenzzo/src/my-next-stack/shadow-cljs.edn cli version: 2.7.6 node: v11.2.0 shadow-cljs - running: lein with-profile client,webdev run -m shadow.cljs.devtools.cli --npm server Executable '' not found on system path.
'' should be lein 🙂leinlein found via which lein?http-root in devtools can be a array?output-dir on target/public/js/out then serve target/public and resources/public (my index.html is on resources/public/index.html ):http-resource-root "public":http-root)http-resource-root and http-root ???resources is on the classpath, which is is by default in lein but not shadow-cljs.edn)shadow from repl I get
(shadow/watch :main :cards) Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance
server/start!(shadow/watch :main) (shadow/watch :cards)[fulcrologic/fulcro "2.6.15" :exclusions [cljsjs/react]] ??
Should I exclude in project.clj and just add in package.json?No app connected. in Fulcro Inspect tab on console
- after-load dont call cljs.user/on-jsload after load
https://github.com/souenzzo/my-next-stack/blob/feature/shadow-cljs-wip/shadow-cljs.ednwebdev profile active?cljs/user.cljs then instead uses the default which doesn't have the after-load hookuser.cljs is loaded on browser and when I call cljs.user.on_jsload() on js console it works as expected....java.lang.NoSuchMethodError: com.google.javascript.jscomp.AbstractCompiler.getInputsInOrder()Ljava/lang/Iterable when releasing (even if optimization is just set to :whitespace), I've tried using --debug and -v but couldn't find any clues.lein deps :treeclosure-compiler-unshaded[com.google.javascript/closure-compiler-unshaded "v20180910"] to your :dependencies(set! *print-fn* (fn [& _])). What is the best way to achieve this in shadow-cljs? In lein-cljsbuild I've included different paths to :source-paths which contained cljs files with build-specific commands.:source-paths for release and dev or is there any other way to inject different code for dev/release?(when-not ^boolean js/goog.DEBUG (set! *print-fn* (fn [& _])))releasebuild report https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report . Will it build AND generate a report or it will only generate a report on an existing build?release as it modifies the build to ensure it can generate all the info it needscljs.* files are not checked for reload metadata because I assumed they would never have anycljs.user. probably best to just pick another namenode-sass cli and just a main.scss which directly @import "node_modules/foo/bar.scss";link element. We're using garden or I'd probably do the import route via sass(defn debug [x] [:pre (with-out-str (pprint data))])cljs.pprint can not currently be removed by closurecljs.pprint itself is the problem and remains as soon as you import itdefmulti/defmethod so as soon as that is used you are out of luckfipp was decently removeablenpm land. https://twitter.com/garybernhardt/status/1067111872225136640watch build.#navbar or #app in the HTML maybe?npm install <pkg dir>. During the release build it throws a “ExceptionInfo: files outside the project are not allowed: ” Have the same issue if you try an npm link(:require ["module-name" :refer (export)]) - why does :refer block is not in square brackets as usual?:refer. vector or even sets are fine toonode_modules/foo -> ../../whatever/foo?release functions:
[2018-11-27T23:26:20.408Z] INFO: scrutinize-event-fn/10976 on RD28187871EEEA: interceptor error (function=scrutinize-event-fn, :namespace=cljs.user, :level=info, retry-counter=0, trace-id=3
aa0f630-2610-4cb4-9f51-8000fda9a3b8, error={})
Error: [object Object] is not ISeqable
at Object.cljs.core.seq (D:\home\site\wwwroot\cljs\shared.js:6731:9)
at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:8386:25)
at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:8463:136)
at Object.cljs.core.vec (D:\home\site\wwwroot\cljs\shared.js:15652:235)
at Function.cljs.core.async.map.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:59880:19)
at Function.cljs.core.async.map.cljs$core$IFn$_invoke$arity$2 (D:\home\site\wwwroot\cljs\shared.js:59877:30)
at Object.laputa.scrutinize_fn.fx.command_commit_event_BANG_ (D:\home\site\wwwroot\cljs\shared.js:65920:120)
at laputa.scrutinize_fn.interceptor.commit_event_BANG_ (D:\home\site\wwwroot\cljs\shared.js:66027:34)
at Object.sieppari.core.try_f (D:\home\site\wwwroot\cljs\shared.js:55118:89)
at sieppari.core.leave (D:\home\site\wwwroot\cljs\shared.js:55133:202)
I was wondering how can I see the source mapped version with release?shadow-cljs release the-build --source-mapsshadow-cljs release the-build --debug (for source maps + pseudo-names)laputa.scrutinize_fn.fx.command_commit_event_BANG_ guess you are running :simple?:source-maps true:source-map true I thinksource-map or source-maps:release {:compiler-options {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:source-map true}
:autorun false}
source-map-support is in the deployed node_modules together with the .mapnode -r source-map-support your-script.js or however that worksnodenode -r source-map-support/register compiled.js:browser-tests {:target :browser-test
:test-dir "target/browser-tests/"
:module-loader true
:ns-regexp "-test"
:runner-ns runner.core
:devtools {:http-port 8021
:http-root "target/browser-tests/"}}
for some reason, this works perfectly fine on my computer but not on my coworkers. I'm using macOS and she is using Windows, though I don't think that's the issuetest.js built correctly, however it responds with a 404 from the shadow-cljs HTTP server:http-root:test-dirshadow-cljs with jvm11 it says Warning: Nashorn engine is planned to be removed from a future JDK release
Is it a know issue?The required namespace "decimal.extern.decimaljs" is not available, it was required by "decimal/core.cljs".(ns decimal.extern.decimaljs (:require ["decimal.js" :as dec])) (js/goog.exportSymbol "something" dec)Decimaldecimal.js file, packaged inside [funcool/decimal] jar instead of installing it from npm?Absolute requires like /some-library/components/foo mean that the compiler will look for a some-library/components/foo.js on the classpath;:advancedFile: ... failed to require macro-ns "clojure.core.strint", it was required by "..." FileNotFoundException: Could not locate clojure/core/strint__init.class or clojure/core/strint.clj on classpath.
strint was moved from the core....lein-cljsbuild...core.incubator in leiningen dependencies...load-file to try and reach the file.(require '[some.ns :as x]) as normal but load-file is limited to files in your :source-pathsns form.(load-file "DailyProgrammer/single_symbols_squares.cljs")src:npm-module target?firebase npm module with my app and I’m having issues importing things from the module. for example, when I try to
(:require ["firebase/database" :as database])it comes up as an empty object
(:require ["firebase/app" :as firebase])
["firebase/database"] instead, and initialize with (def database (.firestore firebase))(:require ["firebase/app" :as firebase]
["@firebase/database"]):browser-test build of my project, it looks like specs don't get cleared when hot reloading, so some tests appear to still work until the page is reloaded and the registered specs cleared. I've just been re-namespacing a bunch of my specs, and was confused why tests weren't failing when I knew they should.
Is this a (known?) issue, or might I have just misconfigured something?expound?:npm-module target?
ProtoREPL works with the base REPL, but as soon as I change to the build repl no further command works (even though the ns changes to cljs.user, and the message for :cljs/quit appears):npm-module given that we are not in control how the JS is loadedrequire("shadow-cljs/shadow.cljs.devtools.client.browser") from the JS(goog-define EMBEDDED_DEV false)
(when EMBEDDED_DEV
(defonce _dirty_repl_hack
(js/require "my-module/build/npm/shadow.cljs.devtools.client.browser")))
This doesn't require anything additional in the embedding javascript project, and will get optimized away in release builds$ electron public/main.js it gives me this:
REPL client error { Error: connect ECONNREFUSED 192.168.43.81:9630
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '192.168.43.81',
port: 9630 }
REPL client disconnected
and now cider-connect-cljs gives me a failed error. 9630 isn't my repl port. It's the shadow console port. I've tried blowing off ~/.cache and .shadow-cljs in the project dir. Also rmmed .nrepl-port in the project dir. How do I fix?shadow-cljs Project: /home/kevin/0work/guardian-dashboard Release Snapshots
9630 is the default port used by the shadow-cljs webserver which serves the websockets used for the REPL:devtools?:devtools {:http-root "public"
:http-port 8080}}
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d0a3b8b1b4bfa7fdb3bcbaa390e2fee7fee6"}, :content ("[email protected]")} and I get the same errortoJS(), get and so on). Adding hints clears the errors and the warnings. Adding externs clears the errors only.externs/build.txt?shadow-cljs.edn without needing a restart!release snapshots on the console. How do I tell what version of shadow is actually executing? I don't see any -version optionshadow-cljs command will use whatever version of it is installed in your projectcljs.core versions:npm-module:node-library depending on how many exposed API's you actually need:npm-module working last time I tried it. So went back to :node-library even though the API is pretty thick.cljs.corecljs.core "instances".cljs files.js filesnpm i @shadow-cljs/npm-module-demo then require("@shadow-cljs/npm-module-demo")require("@shadow-cljs/npm-module-demo").hello("x")require("@shadow-cljs/npm-module-demo/foo.bar").hello("x")require("@shadow-cljs/npm-module-demo/foo.baz").hello("x") to access the other nscalva-core to npm that wayrequire("calva-core/foo.bar") so get access to whatever CLJS fn it needscljs.core will only be loaded oncecalva-core can talk to any other CLJS in calva-core but not to any other CLJS not in calva-core:warnings under :compiler-options?2. Unhandled clojure.lang.Compiler$CompilerException Error compiling shadow/build/compiler.clj at (455:13) 1. Caused by java.lang.RuntimeException Unable to resolve var: comp/*source-map-data-gen-col* in this context
project.cljproject.clj. the problem is taken care of in shadow-cljs.edn 😉project.clj 😞Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (23 frames hidden)
1. Unhandled clojure.lang.ExceptionInfo
missing instance
{}
core.clj: 4739 clojure.core/ex-info
core.clj: 4739 clojure.core/ex-info
runtime.clj: 11 shadow.cljs.devtools.server.runtime/get-instance!
runtime.clj: 8 shadow.cljs.devtools.server.runtime/get-instance!
api.clj: 130 shadow.cljs.devtools.api/worker-running?
api.clj: 128 shadow.cljs.devtools.api/worker-running?
api.clj: 207 shadow.cljs.devtools.api/watch
api.clj: 201 shadow.cljs.devtools.api/watch
api.clj: 205 shadow.cljs.devtools.api/watch
api.clj: 201 shadow.cljs.devtools.api/watch
REPL: 1 user/eval55989
REPL: 1 user/eval55989
Compiler.java: 7062 clojure.lang.Compiler/eval
Compiler.java: 7051 clojure.lang.Compiler/eval
Compiler.java: 7025 clojure.lang.Compiler/eval
core.clj: 3206 clojure.core/eval
core.clj: 3202 clojure.core/eval
main.clj: 243 clojure.main/repl/read-eval-print/fn
main.clj: 243 clojure.main/repl/read-eval-print
main.clj: 261 clojure.main/repl/fn
main.clj: 261 clojure.main/repl
main.clj: 177 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 652 clojure.core/apply
regrow.clj: 18 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 1965 clojure.core/with-bindings*
core.clj: 1965 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 85 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 55 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 222 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 190 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 745 java.lang.Thread/runshadow-cljs server separately, but still no luckshadow-cljs server starts its own instance with its own nrepl serverproject.clj for the server-side and shadow-cljs.edn for the CLJS side of things1. Unhandled java.lang.IllegalStateException
Can't change/establish root binding of: *nrepl-cljs* with set
Var.java: 223 clojure.lang.Var/set
api.clj: 361 shadow.cljs.devtools.api/nrepl-select
api.clj: 356 shadow.cljs.devtools.api/nrepl-select
api.clj: 358 shadow.cljs.devtools.api/nrepl-select
api.clj: 356 shadow.cljs.devtools.api/nrepl-select
REPL: 1 user/eval73496
REPL: 1 user/eval73496
Compiler.java: 7062 clojure.lang.Compiler/eval
Compiler.java: 7052 clojure.lang.Compiler/eval
Compiler.java: 7025 clojure.lang.Compiler/eval
core.clj: 3206 clojure.core/eval
core.clj: 3202 clojure.core/eval
main.clj: 243 clojure.main/repl/read-eval-print/fn
main.clj: 243 clojure.main/repl/read-eval-print
main.clj: 261 clojure.main/repl/fn
main.clj: 261 clojure.main/repl
main.clj: 177 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 652 clojure.core/apply
regrow.clj: 18 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 657 clojure.core/apply
core.clj: 1965 clojure.core/with-bindings*
shadow-cljs - config: /home/kevin/0work/guardian-dashboard/shadow-cljs.edn cli version: 2.3.24 node: v8.12.0
Why? Is there a cache somewhere I need to clean out first?lein or deps.edn? probably not just shadow-cljs.edn right?/home/kevin/0work/guardian-dashboard/node_modules/shadow-cljs/package.json say?shadow-cljs.edn file{
"_from": "npm i shadow-cljs in my project folder after changing the package.json shadow version. I have to change it here too?/home/kevin/0work/guardian-dashboard/package.json{
"name": "guardian-dashboard",
"version": "3.3.2",
"description": "UI to JBOG guardian server",
"main": "guardian/dashboard.js",
"directories": {
"doc": "doc"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+"
},
"author": "Jessie Umblerg/Kevin Haddock",
"license": "private trade secret",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"electron": "^3.0.6",
"jquery": "^3.3.1",
"markdown": "^0.5.0",
"npm": "^6.4.1",
"querystring": "^0.2.0",
"url": "^0.11.0",
"util": "^0.11.0"
},
"devDependencies": {
"shadow-cljs": "^2.7.6"
}
}
npm install or just edit the package.json manually?npm i shadow-cljs after editing it manuallyrm -rf node_modules && npm installnpm i in that directory and now the package.json in the node_modules/shadow-cljs says 2.7.6npm i shadow-cljs in there after changing the version in the package.json in the project's home folder and making it a dep in the shadow-cljs.edn and it didn't properly update it (even tho it said it did). I'll have to check that out again next time shadow's version number gets bumped to see if it does the same thing again.:simple optimziations. it does some DCE but not the real stuff.node-library target?
Here's my shadow-cljs.edn:
{:source-paths ["src"]
:builds
{:my-lib
{:target :node-library
:output-to "lib/my-lib.js"
:exports-fn my-lib.js/generate-exports}}}
And my file:
(ns my-lib.js (:require [my-lib.core])) (defn generate-exports [] (clj->js my-lib.core))
split: { [Function: d] A: [Function: c], a: [Function: b] },
gc: { [Function: d] A: [Function: c], a: [Function: b] },
(clj->js some.ns) as that will all be renamed#js {:foo my-lib.core/foo :bar my-lib.core/bar :baz some.ns/baz} and so on:advanced optimizations are not that relevant on node:npm-module instead since that controls what is exported directly in the ns(defn ^:export foo [])let bindings seems to do the trick while working in the REPL, once I shadow-cljs release to an :npm-library and import the work, the functions seem to be losing their internal state across calls. I'm not sure how to fix this (or if it's even possible), but I see that :rename-prefix-namespace creates a global var in JS. Might this keep those internal function bindings "alive" between calls?(ns app.core (:require [app.spooler :refer [spooler] cljs.core.async :as a]))
(let [cache... bindings are working in cljs, but not when I release the cache is never reached by the function across callsgo looks invalid>! in there even more so=I= AFAICT?release the function is wrapped in a self-executing context, which is run and then thrown away:advanced:advancedvolatiles are never getting the chance to get used when I import the compiled js(prn [:call url @$url$ ...]) just to verify that everything is what you think it is?getting data from source: ... (run the function again with the same args) getting data from cache: ...but when I use it in js land I get
getting data from source: ... (run the function again with the same args) getting data from source: ...
cond is what you think it is$GET$ again instead of re-using2.6.24 for the time beingrelease build of my browser npm module started erroring with Cannot read property 'navigator' of undefined during import of the module. I've tracked down that goog.base.js sets $ = window.global at the end, but window.global is undefined.
I'm not sure if it's something shadow-cljs is doing, or something webpack is doing, or both. Any ideas how to proceed?:node-library or :npm-module as is done with :web-worker true?:web-worker is relevant to the bundling but all dependencies for node is not possible// Auto-generated comment to the output file: https://github.com/shaunlebron/highlight-tree-sitter/blob/master/shadow-cljs.edn#L6\n:node-library respects that option//# sourceMappingURL=cljs.core.async.impl.buffers.js.map, which is not where they're actually served from. Accd to the user guide, :source-map-path doesn't have any effect at all - is there a solution to this? Thanks very much!require between :npm-module and :browser-test targets.
Given the sample import ["module/folder/file-with-default-function.js" :as file :default function], here's what the names get assigned to:
| | :browser-test | :npm-module |
|----------+----------------------------------------+-----------------------|
| file | Object{default: function(args){ ... }} | function(args){ ... } |
| function | function(args){ ... } | undefined |
Is that expected?
The current workaround is a shim cljs file that checks for the existence of a default and binds the var to that instead:npm-module it emits a straight up require("module/folder/file-with-default-function.js") call. however that is filled in I cannot control:js-options {:prefer-esm true} in the :browser-test build:npm-module:js-options is located at the root of the build config (next to :target), then the result is the same 😕:npm-module code loaded?"module/folder/file-with-default-function.js" which module is this?export default (args) => {
return ...
}
:npm-module is a problem for this3.11.0 project. Is there something specific I should look for?:browser-test looks correct to me. not sure about webpack and :npm-module------ WARNING #2 -------------------------------------------------------------- File: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- ------ WARNING #3 -------------------------------------------------------------- File: fulcro_css/css_implementation.cljc:212:56 variable garden is undeclared --------------------------------------------------------------------------------
java warningshadow-cljs - config: /home/kevin/0work/guardian-dashboard/shadow-cljs.edn cli version: 2.7.6 node: v8.12.0 shadow-cljs - starting ... Dec 03, 2018 2:28:19 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Dec 03, 2018 2:28:19 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - HTTP server for :client available at shadow-cljs - server version: 2.7.6 shadow-cljs - server running at shadow-cljs - socket REPL running on port 42319 shadow-cljs - nREPL server started on port 45695and
Starting Nmap 7.70 ( ) at 2018-12-03 14:38 PST Nmap scan report for localhost (127.0.0.1) Host is up (0.00016s latency). Other addresses for localhost (not scanned): ::1 Not shown: 998 closed ports PORT STATE SERVICE 631/tcp open ipp 8080/tcp open http-proxy Nmap done: 1 IP address (1 host up) scanned in 0.65 seconds(the latter was done with the
-Pn flag)
And cider won't connect with merely the "failed" error (nothing else, and doesn't get to the point where it even creates the nrepl message buffer even tho its enabled).nc localhost 45695 or whatever port is shown-Pn meanslein installed you can also do lein repl :connect localhost:<the-port> without a projectlein repl :connect localhost:42659 Connecting to nREPL at localhost:42659 CompilerException java.lang.ClassNotFoundException: clojure.tools.nrepl, compiling:(null:1:82) #namespace[user] Error loading namespace; falling back to user nil user=> Bye for now!
:dependencies [ [thheller/shadow-cljs "2.7.6"] [refactor-nrepl "2.4.0"] [org.clojure/clojure "1.10.0-alpha6"] [org.clojure/clojurescript "1.10.339"] [cider/cider-nrepl "0.19.0-SNAPSHOT"] [binaryage/devtools "0.9.10"] [adzerk/env "0.3.1" :scope "test"] [com.rpl/specter "1.1.2"] ;; [hoplon/hoplon "7.1.0"] [hoplon/hoplon "7.3.0-SNAPSHOT"] ;; [vigilancetech-com/hoplon "6.0.0-alpha17"] [cljsjs/markdown "0.6.0-beta1-0"] [vigilancetech/ui "0.3.0-SNAPSHOT"] ]
:node-library output with AWS Lambda and am running into problems when I take the output and upload it to lambda. Does the output require a specific node version as its minimum?[org.clojure/tools.nrepl "0.2.13"] to those dependencies.release and then upload the zip to AWS lambda it just returns null2.7.8. I changed how the exports are generated so it doesn't rely on the global.node_modules into the zip, as thomas is undecided on “single-file” node builds. that might be obvious to most people but i spent a decent bit of time figuring that out, especially with :advanced onuser.clj in your sources that tries to do something with nrepl?lein repl :connect localhost:8202 Connecting to nREPL at localhost:8202 shadow.user=>
user.cljshadow-cljs.edn with:
:release {:compiler-options {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:elide-asserts false
:source-map true}
:autorun false}
(= {:problems
[{:path []
:pred 'cljs.core/keyword?
:val {:foo :bar}
:via []
:in []}]
:value {:foo :bar}
::error2/id :this-is-an-error-id}
(ex-data (error2/spec-ex-info :this-is-an-error-id spec body)))
keyword? is the spec (predicate only) and {:foo :bar} the value. I will try to repro in core as wellshadow-cljs watch the above passes:release config above it does not(not
(= {:problems
[{:path [], :pred cljs.core/keyword?, :val {:foo :bar}, :via [], :in []}],
:value {:foo :bar},
:laputa.tools.error2/id :this-is-an-error-id}
{:laputa.tools.error2/id :this-is-an-error-id,
:value {:foo :bar},
:problems [{:path [],
:pred :cljs.spec.alpha/unknown,
:val {:foo :bar},
:via [],
:in []}]}))
:pred, which is :cljs.spec.alpha/unknown in :releasespec + body is missing from the code above so I can't say.keyword? is the spec (predicate only) and {:foo :bar} the value. I will try to repro in core as well thennode or the browser?node.:node-library and connects to the REPL when the extension starts. But this repackaging is really totally independent on VS Code or anything but node. And I can’t figure out how to get it connected to the REPL.:runtime :node and then loading require("./path-to-output/shadow.cljs.devtools.client.node"):npm-module target.global["SHADOW_NODE_EVAL"] = function (js, smJson) {
if (smJson) {
js += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,";
js += Buffer.from(smJson).toString('base64');
}
//console.log(js);
return eval(js);
};
node-repl outside all of this to work on the CLJS side of thingsvar shadow = require('./calva_lib/shadow.cljs.devtools.client.node')
undefined
> failed to parse websocket message {:type :repl/init, :repl-state ...ReferenceError: SHADOW_IMPORTED is not defined
at Object.shadow$cljs$devtools$client$node$is_loaded_QMARK_ [as is_loaded_QMARK_] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:64:24)
at Object.shadow$cljs$devtools$client$node$repl_init [as repl_init] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:137:40)
at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:478:41)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)
at WebSocket.emit (events.js:182:13)
at WebSocket.EventEmitter.emit (domain.js:460:23)
at Receiver._receiver.onmessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/WebSocket.js:141:47)
at Receiver.dataMessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:389:14)
at Receiver.getData (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:330:12)js/global.SHADOW_IMPORTED:runtime :node thing?ws module. so you are in node.(defn is-loaded? [src] (js/$CLJS.SHADOW_ENV.isLoaded src))
is-loaded? function and then I could require the client w/o complaints.ReferenceError: calva is not defined
at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:1:22)
at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:4:3)
at global.SHADOW_NODE_EVAL (repl:7:16)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:60:14)
at /Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:177:41
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:154:108)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:175:92)
at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:482:41)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)node inside the packages folder and then requiring the node client like so: require('./calva_lib/shadow.cljs.devtools.client.node')shadow-cljs node-repl instead?node-replnpx shadow-cljs cljs-repl :calva-libnpx shadow-cljs node-replnode.cljs still in your sources thats now gonna break stuff(shadow.cljs.devtools.api/node-repl)npx shadow-cljs browser-repl in addition to node-repl. same deal, configless but runs in the browser.:devtools {:preloads [foo.bar]}. as of recently individual modules also accept preloads, eg. :modules {:foo {:preloads [...]}}node-repl thing is perfect for my npm module in the making! Here testing the coming Calva support for it. Thanks again!deps.cljsnpm install it might have a completely different set of depspackage-lock.json in lib A and I am ok with that and I like the warning when deps.cljs is out of syncdeps.cljs dependencies gets added to its package.jsonnpm install it might have a completely different set of depsproject.clj which is modified by the transitive dependencies of lib A{:npm-deps {"react" "^16.0.0"}}npm install in the project NOTHING is installednpm install. we can agree that nothing happens yes?shadow in order to install the transitive deps for sure, because A does not declare them:install-cmd lets you do this already. I'm not changing the default.package.json of A is partly due to toolingnpm install something-a-wantsdeps.cljs since its not in package.jsonpackage.json or on node_modules? because the deps will be in node_modules...:npm-deps:install-cmd. maybe it works for you. I never used npm that way. it may actually work.npm relies on both, I need to carry them over cause I am relying on JS tooling like the Azure stuffnpm install is at least semi consistent given the widespread use of version ranges in the npm world:azure-app's :fn-map gets emitted? I have a weird error with 2.7.8[error] Worker was unable to load function trigger: 'TypeError: Cannot read property 'trigger' of null'.shadow-cljs release prevent instrument to happen somehow?release sets :elide-asserts true which may affect instrument. not actually sure. try setting :compiler-options {:elide-asserts false}(re-seq #"(?u)[\p{L}]+" "adams-äpple")
=> ("adams" "äpple")
But in shadow-cljs, targeting node, I get this:
(re-seq #"(?u)[\p{L}]+" "adams-äpple")
Error: <eval>:1
cljs.core.re_seq.call(null,/[\p{L}]+/u,"adams-\u00E4pple")
^
SyntaxError: Invalid regular expression: /[\p{L}]+/: Invalid escape
at <eval>:1:18
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at runInThisContext (vm.js:139:38)
at global.SHADOW_NODE_EVAL (/Users/pez/Projects/calva-fmt/lib/calva_fmt.js:83:30)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
at /Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:13
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:102:11)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:46:1)
at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:116:5)
> "adams-äpple".match(/[\p{L}]+/ug);
[ 'adams', 'äpple' ]
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code:builds
{:dev {:target :node-script
:nrepl {:init-ns ginandtomic.core}
:output-to "main.js"
:asset-path "/js"
:main ginandtomic.core/main}}
output some locations to connect, connected on nrepl port, ran
(require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :dev) (shadow/nrepl-select :dev)seems to believe everything is fine, outputting:
To quit, type: :cljs/quit => [:selected :dev]and yet, when I try to evaluate any cljs, it throws
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code(shadow/node-repl). comp/*source-map-data-gen-col*calva-lib as an npm module. One is that I can't require it when I npm install it, only if I do npm link (which is handy during development). Here's the repo: https://github.com/BetterThanTomorrow/calva-libfuncool/decimal properly.app.js + 351KB webpack-bundle.js. While shadow-cljs generates one 3.1MB app.js file. What could possibly be wrong?shadow-cljs server serve GZIPed files?(:require clojure.string) for the :npm-module to work, but not while I was using a :node-library target. And it seems that is what is happening inside a library I am using (`cljfmt`). I get ReferenceError: clojure is not defined.shadow-cljs watch test using a node-test autorun build? I tried using the main entry in my shadow-cljs.edn to override the formatter to print a thrown error, but that caused weird watch behavior that I didn't want to figure out. Right now, I'm not using a main module for the build, and I'm getting stuff like:
ERROR in (test-line-item-tax-exempt) (Error:NaN:NaN) Uncaught exception, not in assertion. expected: nil actual: #object[Error Error: No matching clause: ]
bluebird npm package. no idea how to do that for AWS though.:compiler-options {:infer-externs):all?cannot fine module bluebird. thats just means the the npm package bluebird is not found by node. they are not bundled in node build (unlike browser builds)zy.Fp is not a function or undefined or whatever that is most likely caused by externs.cljfmt in my npm-module build?cljfmt reaches certain paths in its code it croaks with the reference error of clojure not being defined.:npm-module and is more sensitive to use-without-require type of code problems.cljfmt uses clojure.string (or something similar) but does not :require it in its nscljfmt (if thats indeed the error):compiler-options {:output-charset "ASCII"} maybe?browser-repl?node --version.browser-repl.(js/RegExp. "[\p{L}]+" "u")(js/RegExp. "[\\p{L}]+" "u")browser-repl)$ node
> /[\p{L}]+/u
/[\p{L}]+/u
>npm install. Only if I npm link it locally.require("@shadow-cljs/npm-module-demo")). In my case I do const formatter = require('@cospaia/calva-lib/lib/calva.fmt.formatter');
But it does not work from an npm install only from an npm link.Activating extension 'cospaia.calva-fmt' failed: Cannot find module '@cospaia/calva-lib/lib/calva.fmt.formatter'.cljfmt thing that I need to fix).node_modules/@cospaia/calva-lib/lib/calva.fmt.formatter.js exist?lib/ directory?lib/? In some .ignore file?main: file (from packages/package.json) there.lib/calva.main.js in my case..npmignore but can't rememberpackages/ lists: *.js *.js.map
main: entry)."files": [
"lib/"
]
in package.json. Yay!:bootstrap target
[2018-12-11 13:01:18.740 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (symbol? current-ns)
shadow.build.cljs-hacks/shadow-js-access-global (cljs_hacks.cljc:16)
shadow.build.cljs-hacks/shadow-js-access-global (cljs_hacks.cljc:16)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:167)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:131)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:135)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:131)
cljs.analyzer/resolve-symbol/fn--2589 (analyzer.cljc:3910)
cljs.analyzer/resolve-symbol (analyzer.cljc:3909)
cljs.analyzer/resolve-symbol (analyzer.cljc:3905)
clojure.tools.reader/syntax-quote* (reader.clj:705)
clojure.tools.reader/syntax-quote* (reader.clj:693)
clojure.tools.reader/expand-list (reader.clj:623)
any ideas of where i should start looking to get rid of it?
thanks in advance..shadow-cljs clj-repl try (def x (shadow/compile! :the-build-id {}))tools.reader version[:app] Configuring build. -> build target: :browser stage: :configure <- build target: :browser stage: :configure (2 ms) [:app] Compiling ... -> Analyzing Module: :app [:app] Build failure: The required namespace "day8.re-frame.tracing" is not available, it was required by "dbiz_health/commom/events.cljs".
day8.re-frame.tracing in npmre-frame.trace https://github.com/Day8/re-frame/blob/master/src/re_frame/trace.cljc------ WARNING #1 -------------------------------------------------------------- File: bidi/bidi.cljc:29:12 -------------------------------------------------------------------------------- 26 | actually a valid UUID (this is handled by the route matching logic)." 27 | [s] 28 | #?(:clj (java.util.UUID/fromString s) 29 | :cljs (cljs.core.UUID. s))) ------------------^------------------------------------------------------------- Wrong number of args (1) passed to cljs.core.UUID -------------------------------------------------------------------------------- 30 | 31 | ;; When forming paths, parameters are encoded into the URI according to 32 | ;; the parameter value type. 33 | --------------------------------------------------------------------------------Someone knows how to solve this?
(cljs.core/uuid s)cljfmt problem with clojure.string being used without proper require, I found that it happens in rewrite.cljs: Here: https://github.com/rundis/rewrite-cljs/blob/5ed0980d4fc65ba00780deadb3cf245d742bfeb9/src/rewrite_clj/parser/string.cljs#L39 This is quite a bit more problematic than if it had been in cljfmt itself, because the latter is actively maintained, and PRs pulled, but it is not so with rewrite-cljs. Is my only option now to use my own version of rewrite-cljs, or is there something I can tell shadow-cljs that will make it handle this omission? Seeing that it does handle it when I have my lib compiled as a :node-library, but maybe that is totally accidental depending on if the clojure module has been required by some other piece of code earlier in the compile cycle? (I have the full stack trace, if that is of any help.)cljfmt, tracking upstream tightly, so it is not the end of the world if I have to fork rewrite-cljs to patch this, but if it can be avoided, I would rather avoid.):release some .js files are totally empty. Buildling using :compile works. Is there something that I loose by not using :release?^:export hints for fns you want to keeprelease is pretty much always worth it:optimizations :simple for node thoughrelease build looks like so it uses your builds release configrelease(defn release
"Build :browser release, with advanced compilation"
([] (release "local"))
([release-flag]
(shadow/release* (-> (config/get-build! :browser)
(assoc ::release-flag release-flag)) {})))
::release-flag?test, staging, prod, etcrelease*npm install --save some-font, what's the preferred method for actually using it?Error handling response - class java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
<eval>:12
:(function (){var writer__7270__auto__ = (new java.io.StringWriter());
^
ReferenceError: java is not defined
at <eval>:12:42
at <eval>:16:3
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at runInThisContext (vm.js:139:38)
at global.SHADOW_NODE_EVAL ([stdin]:75:30)
at
🤔:infer-externs :auto (shadow 2.7.9):
Given this code:
(ns foo.bar)
(defprotocol JustUsedAsATag)
(defrecord SomeRecord [field]
JustUsedAsATag)
I get this warning:
Cannot infer target type in expression (. (. SomeRecord -prototype) -foo$bar$JustUsedAsATag$)It happens only when the protocol do not declare any method (empty protocol). Is this related to shadow? Should I open an issue?
;; :dependencies
[com.billpiel/sayid "0.0.17"]
[refactor-nrepl "2.4.0"]
[cider/cider-nrepl "0.19.0-SNAPSHOT"]
;; Output after cider-connect
WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
CIDER is working fine, I'm just missing the refactoring features. (Haven't tried sayid, but I doubt it works on cljs):nrepl {:middleware [something.from.refactor-nrepl]}:release build. I get this stack trace (hopefully I haven't trunkated it too early again): TypeError: Cannot read property 'core' of undefined extensionHostProcess.js:344 at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:8:280) at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:2044:3) at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio ) at Object.Module._extensions..js (module.js:653:10) at Module.load (module.js:561:32) at tryModuleLoad (module.js:504:12) at Function.Module._load (module.js:496:3) at Function.t._load (/Applications/Visual Studio ) at Function.t.getExtensionPathIndex.then.s._load (/Applications/Visual Studio ) at Function.t.getExtensionPathIndex.then.r._load (/Applications/Visual Studio ) at Module.require (module.js:586:17) at n (/Applications/Visual Studio ) at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:1:232) at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:37:3) at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio )At
/lib/calva.fmt.formatter.js:1:232 it is requiring calva.js_utils.js which is built from this small cljs file: (ns calva.js-utils) (defn ^:export jsify [o] (clj->js o)) (defn ^:export cljify [o] (js->clj o :keywordize-keys true))
/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js look like?var window=global;var $CLJS=require("./cljs_env");require("./goog.math.long.js");require("./goog.math.integer.js");require("./goog.string.string.js");require("./goog.object.object.js");require("./goog.array.array.js");require("./goog.uri.uri.js");require("./goog.string.stringbuffer.js");
var cljs$cst$keyword$ns,cljs$cst$symbol$root,cljs$cst$symbol$default_DASH_dispatch_DASH_val,cljs$cst$symbol$mseq,cljs$cst$symbol$defrecord_STAR_,cljs$cst$keyword$val,cljs$cst$symbol$_meta,cljs$cst$symbol$js_STAR_,cljs$cst$symbol$__hash,cljs$cst$symbol$ns_STAR_,cljs$cst$symbol$ascending_QMARK_,cljs$cst$symbol$fqn,cljs$cst$symbol$update_DASH_count,cljs$cst$symbol$off,cljs$cst$symbol$cnt,cljs$cst$keyword$status,cljs$cst$keyword$descendants,cljs$cst$symbol$nil_DASH_val,cljs$cst$symbol$dispatch_DASH_fn,:simple. not actually sure though.:simple$CLJS.cljs = { tools: {} }; is declared too later:simple the build works.[:app] Build failure: The required JS dependency "Components/list" is not available, it was required by "dbiz_health/common/views.cljs". Searched in:/Users/pimentel/Projetos/dbiz-health/node_modules You probably need to run: npm install Components/list
:source-paths ["src/cljs" "src/clj" "src/gen" "test/cljs" "test/clj"]
/ in front otherwise it'll check node_modules as thats the notation for npmimport React from "react"
const MyComponent = ({ key }) => {
console.log('child props: ', key)
return (
<li key={key}>
Hello JSX!
</li>
)
}
const MyDefaultComponent = ({ children }) =>
<div>
<h1>Hello JSX!</h1>
<ul>
{children}
</ul>
</div>
export { MyComponent }
export default MyDefaultComponentimport React from "react"MyComponent.js:7 Uncaught TypeError: Cannot read property 'createElement' of undefined
at MyComponent (MyComponent.js:7)
at beginWork (react-dom.development.js:14564)
at performUnitOfWork (react-dom.development.js:17821)
at workLoop (react-dom.development.js:17861)
at HTMLUnknownElement.callCallback (react-dom.development.js:150)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
at invokeGuardedCallback (react-dom.development.js:257)
at replayUnitOfWork (react-dom.development.js:17108)
at renderRoot (react-dom.development.js:17980)
at performWorkOnRoot (react-dom.development.js:18838)import React from "react";
var MyComponent = function MyComponent(_ref) {
var key = _ref.key;
console.log('child props: ', key);
return React.createElement(
"li",
{ key: key },
"Hello JSX!"
);
};
var MyDefaultComponent = function MyDefaultComponent(_ref2) {
var children = _ref2.children;
return React.createElement(
"div",
null,
React.createElement(
"h1",
null,
"Hello JSX!"
),
React.createElement(
"ul",
null,
children
)
);
};
export { MyComponent };
export default MyDefaultComponent;`React when trying to call .createElement(:require ["auth0-js" :as ajs])(ns (:require ["auth0-js" :as ajs]))But when I run
shadow-cljs watch frontend
This error pops up in my console:
"shadow.js.js:87 shadow-cljs - failed to load module$node_modules$auth0_js$dist$auth0_min"
I think what’s happening is that the “auth0-js” is getting converted to “auth0_js”, but npm doesn’t follow the naming convention where a - translate to a folder structure with an _.
I’ve got a repo here to recreate the issue:
https://github.com/justinbarclay/auth0-js-bugcannot read property lib of undefined is that error:js-options {:variable-renaming :local} in your build configauth0-js will always be renamed to auth0_js since auth0-js is auth0 - js in javascript since - is an operator:variable-renaming :local will break other JS libs{::spec/keys [:problems :fn :cljs.spec.test.alpha/caller]} data(let [{:spec/keys [:problems]} data]
problems)CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/local-name at: [:args :bindings :binding :map :mb 0 :sym] predicate: simple-symbol?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/seq-binding-form at: [:args :bindings :binding :map :mb 0 :seq] predicate: vector?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-bindings at: [:args :bindings :binding :map :mb 0 :map] predicate: coll?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-special-binding at: [:args :bindings :binding :map :mb 0 :map] predicate: map?
In: [0 0 0 1 0] val: :problems fails spec: :clojure.core.specs.alpha/ns-keys at: [:args :bindings :binding :map :nsk 1] predicate: simple-symbol?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-bindings at: [:args :bindings :binding :map :msb 0] predicate: #{:as :or :syms :keys :strs}
...:keys destructuring?{:clojure.spec.alpha/keys [problems fn], :clojure.spec.test.alpha/keys [caller]} data is the clojure variant. not sure why that was changed?cljsjs/reactdeps.cljs {:npm-deps {"react" "that-version"}}could not find string alias for "socket.io-client" from app.clientm.aws.createTable() isn't immediately obvious what this actually callsshadow-cljs node-repl (require '[server.create-table :as ct]) (ct/invoke) might be cleaner"?rand=" (rand) at the end (after resource-name)src/cljs is your source path?.jar~/.m2/repository/whatever/macchiato..../something-version.jarjar -tvf that.jardeps.cljs insteadpackage.json or whatever:npm-deps in deps.cljs yes. nothing else.deps.cljspackage.json and KEEP your lock fileshadow-cljs watch :my-app, I am getting this:
[2018-12-18 09:39:02.276 - INFO] Using tools.nrepl 0.2.* server!This is my
shadow-cljs.edn:
{:source-paths ["src/cljs"]
:nrepl {:port 8777
:middleware [refactor-nrepl.middleware/wrap-refactor]}
:dependencies [[bidi "2.1.4"]
[binaryage/devtools "0.9.10"]
[cider/cider-nrepl "0.18.0"]
[cljs-ajax "0.8.0"]
[clojure-humanize "0.2.2"]
[com.cemerick/url "0.1.1"]
[hickory "0.7.1"]
[day8.re-frame/http-fx "0.1.6"]
[kibu/pushy "0.3.8"]
[macchiato/hiccups "0.4.1"]
[re-frame "0.10.6"]
[reagent "0.8.1"]
[reagent-utils "0.3.1"]
[refactor-nrepl "2.4.0"]]
:builds {:my-app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:entries [my-app.core]}}}}}
Any ideas? 🙂WARNING: CIDER requires nREPL 0.2.12 (or newer) to work properly
More information.
WARNING: Can't determine Clojure's version. CIDER requires Clojure 1.8.0 (or newer).
More information.
WARNING: CIDER requires cider-nrepl to be fully functional. Many things will not work without it!
More information.
CIDER 0.19.0snapshot (package: 20181212.1936). But even using [cider/cider-nrepl "0.19.0-SNAPSHOT"] in shadow-cljs.edn doesn't fix it.deps.edn? since you mentioned that[2018-12-18 09:39:02.276 - INFO] Using tools.nrepl 0.2.* server![cider/cider-nrepl "0.18.0"] I haven't got neither the message nor the warnings after CIDER connect.❯ shadow-cljs clj-repl shadow-cljs - config: /home/manuel/githubs/manuel-uberti/boodle/shadow-cljs.edn cli version: 2.7.9 node: v8.14.0 shadow-cljs - starting ... Dec 18, 2018 10:45:14 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Dec 18, 2018 10:45:14 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - server version: 2.7.9 shadow-cljs - server running at shadow-cljs - socket REPL running on port 36281 shadow-cljs - nREPL server started on port 8777 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [1:0]~shadow.user=> (require '[ :as io]) nil [1:0]~shadow.user=> (io/resource "cider/nrepl.clj") #object[java.net.URL 0x324afa73 "jar:file:/home/manuel/.m2/repository/cider/cider-nrepl/0.18.0/cider-nrepl-0.18.0.jar!/cider/nrepl.clj"]
[com.cemerick/austin "0.1.3"]
[com.cemerick/piggieback "0.1.2"]
[org.clojure/tools.nrepl "0.2.3"]cider.nrepl detection of which nrepl server to uisemacchiato/hiccups:require your lib:require npm modules and they obviously don't have the cljs analyzer data. In theory could something similar be done to :require the pre-compiled .js output?your-library-v1.3-compiled-by-cljs-1.10.439cljs-runtime dir for your lib only and put them into the classpath of the other appyour.lib.foo.jsgoog.provide("your.lib") which is all it needsCannot read property 'apply' of undefined when it tries to load the codemodule$node_modules$grommet$components$Box$Boxdeps.edn or lein to manage your depsjava.lang.NoSuchFieldError: PARSE_RESULTS
just after the server starts upNo application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.After running
(shadow.cljs.devtools.api/nrepl-select :app).shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn cli version: 2.7.9 node: v6.2.2 WARNING: The org.clojure/clojurescript dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility. shadow-cljs - starting ... Dec 18, 2018 4:14:27 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Dec 18, 2018 4:14:27 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - server version: 2.7.9 shadow-cljs - server running at shadow-cljs - socket REPL running on port 33453 shadow-cljs - nREPL server started on port 9009 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (141 files, 1 compiled, 0 warnings, 1.27s)I tried connecting to the url in that output http://localhost:9630 but that doesn't help.
:browsershadow-cljs server and shadow-cljs watch app separately if that's any helpshadow-cljs server shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn cli version: 2.7.9 node: v6.2.2 shadow-cljs - connected to server server already running
modules specified in your shadow-cljs.edn?{:source-paths ["src"]
:dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
:nrepl {:port 9009}
:builds {:app {:target :browser
:modules {:main {:entries [bide.core]}}}}}
shadow-cljs - HTTP server for ":app" available at
public directory in my project.http-port to your config:devtools stuff
{:source-paths ["src"]
:dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
:nrepl {:port 9009}
:builds {:app {:target :browser
:modules {:main {:entries [bide.core]}}
:devtools {:http-root "public"
:http-port 3000
:http-handler shadow.http.push-state/handle}}}}
then created an index.html and added script tag that loads the main.js file. That seems like a mighty high barrier to starting a browser REPL 🙂 It'd be cool to see that process simplified for cases like this..js files?TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2902)
at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:2897)
at mdc.615F7DC4.js:2901
at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2904)
at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (mdc.615F7DC4.js:2906)
at Object.cljs.core.clj__GT_js (mdc.615F7DC4.js:2899)
at Object.sablono.interpreter.attributes (back-office.9160B910.js:2201)
at Object.sablono.interpreter.element (back-office.9160B910.js:2203)
at Object.sablono.interpreter.interpret_vec (back-office.9160B910.js:2204)
at cljs.core.PersistentVector.sablono$interpreter$IInterpreter$interpret$arity$1 (back-office.9160B910.js:2205)
at Object.sablono.interpreter.interpret (back-office.9160B910.js:2187)
at Function.<anonymous> (back-office.9160B910.js:9408)
at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$3 (mdc.615F7DC4.js:1400)
at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1399)
at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1422)
at $class$$jscomp$6_mixins$$ (back-office.9160B910.js:2685)
at fh (back-office.9160B910.js:112)
at qg (back-office.9160B910.js:140)
at rg (back-office.9160B910.js:141)
at Jd (back-office.9160B910.js:153)
at Sa (back-office.9160B910.js:152)
at sg (back-office.9160B910.js:150)
at Hb (back-office.9160B910.js:148)
at Ag (back-office.9160B910.js:165)
at Qe (back-office.9160B910.js:165)
at sc.render (back-office.9160B910.js:214)
at back-office.9160B910.js:169
at yg (back-office.9160B910.js:164)
at Od (back-office.9160B910.js:169)
at Object.render (back-office.9160B910.js:216)
at Object.rum.core.mount (back-office.9160B910.js:2702)
at Object.my_trees.frontend.back_office.app.start (back-office.9160B910.js:9443)
at Object.my_trees.frontend.back_office.app.init (back-office.9160B910.js:9448)
at (index):1
node_modules? We observed a bunch of weird errors updating to 2.7.8 that went away with an rm -rf...$keyword_fn$$ is undefined in the clj->js function definition.name(shadow.cljs.devtools.api/repl :the-build)funcool/decimal issue https://github.com/funcool/decimal/issues/7#issuecomment-448576845Decimal global or so?js/Decimal.noConflict in a form of a function.(js/goog.exportSymbol "Decimal.noConflict" decimal-js/noConflict)funcool/decimal
(def ^:static +decimal+ (js/Decimal.noConflict)) (def ^:dynamic *decimal* +decimal+)I need to provide a function, which can be called by
decimal.core(js/goog.exportSymbol "Decimal" decimal-js) might also work?(js/goog.exportSymbol "Decimal" decimal-js) might also work?
I'm not sure about this one because noConflict depends on the global environment of javascript...// Export.
if (typeof window !== 'undefined') {
globalScope = window;
} else if (typeof global !== 'undefined') {
globalScope = global;
}
if (!globalScope) {
globalScope = typeof self != 'undefined' && self && self.self == self
? self : Function('return this')();
}
noConflict = globalScope.Decimal;
Decimal.noConflict = function () {
globalScope.Decimal = noConflict;
return Decimal;
};
globalScope.Decimal = Decimal;
})(this);globalScope.Decimal properly, but not globalScope.Decimal.noConflictfuncool tries to access noConflict instead of the Decimal directly - that does not always work properly...`C-c M-j to just jack into a lein project automatically, it seems I have to start a shadow-cljs repl in the terminal and use cider-connect and then manually type a port - is that usual?(shadow.cljs.devtools.api/node-repl :dev) by hand in the repl to get to the app / node repl I guess?C-c M-J command for cljs jack in, and I see that launches some type of nrepl with npx / shadow, but it then tries to open a browser ,which is useless for mewatch build like normal and then run the compile Node.js scriptcider-jack-in-cljs, choose shadow-cljs, and then I get a couple of prompts such as which build I’d like to use. This was very similar to how I jacked in to lein,:npm-module. https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-moduleyour.app.init("") to initialize your app:closure-defines {foo.bar/uri #shadow/env "URI"} so use env vars in the configclj-run stuff to call your own main function to run the testsshadow-cljs.edn file -> project.clj?project.clj + lein is easier currently IMHOproject.clj (i.e., can I just copy the shadow.cljs.edn file)?:dependencies (don't include clojurescript or shadow-cljs itself).cljc filesnode-script targetyarn shadow-cljs watch dev:browser targets onlyshadow-cljs - HTTP server for :workshop available atin which case I would expect that to not appear if you’re not configured your build to use the dev HTTP server options
Dec 21, 2018 11:39:24 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.3.8.Final Dec 21, 2018 11:39:24 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.3.8.Final shadow-cljs - server version: 2.7.9 shadow-cljs - server running at shadow-cljs - socket REPL running on port 44729 shadow-cljs - nREPL server started on port 45909 shadow-cljs - watching build :repl
`(add-to-list
'cider-cljs-repl-types
'(my-cljs-node-repl "(do (shadow.cljs.devtools.api/node-repl :dev))"))
shadow-cljs start seems to go on forever and shadow-cljs watch app is failing:head element and not the end of the body. Unfortunately I can’t work around that.shadow.dom/appendUncaught Error: No protocol method IMapEntry.-key defined for type object: (:page-id "notes")
Happens when code was generated with release compilation in secretary on some ubuntu linux (14.04 LTS).
Same sources compile differently [;)] on macOS High Sierra and don’t cause any trouble after.
Versions
macOS
shadow-cljs 6.4.1
lein 2.8.1
ubuntu
shadow-cljs 6.4.1
lein 2.6.1(:page-id "notes") what is that? that is not valid code?lein deps :tree is different on the systems~/.lein/profiles.clj?shadow-cljs release your-build --pseudo-names?--pseudo-names pretty muchapp.js?mtime=1545734833000:1642 Uncaught Error: No protocol method IMapEntry.-key defined for type object: (:page-id "notes")
at $cljs$core$missing_protocol$$ (app.js?mtime=1545734833000:1642)
at $cljs$core$_key$$ (app.js?mtime=1545734833000:1883)
at app.js?mtime=1545734833000:10170
at $cljs$core$seq_reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ (app.js?mtime=1545734833000:3895)
at $cljs$core$Cons$$.$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$3$ (app.js?mtime=1545734833000:4523)
at $cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ (app.js?mtime=1545734833000:3951)
at app.js?mtime=1545734833000:10167
at $cljs$core$array_reduce$cljs$0core$0IFn$0_invoke$0arity$04$$ (app.js?mtime=1545734833000:2864)
at $cljs$core$IndexedSeq$$.$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$2$ (app.js?mtime=1545734833000:3016)
at $cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$02$$ (app.js?mtime=1545734833000:3947)
$cljs$core$missing_protocol$$ @ app.js?mtime=1545734833000:1642
$cljs$core$_key$$ @ app.js?mtime=1545734833000:1883
(anonymous) @ app.js?mtime=1545734833000:10170
$cljs$core$seq_reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ @ app.js?mtime=1545734833000:3895
$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$3$ @ app.js?mtime=1545734833000:4523
$cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ @ app.js?mtime=1545734833000:3951
(anonymous) @ app.js?mtime=1545734833000:10167
$cljs$core$array_reduce$cljs$0core$0IFn$0_invoke$0arity$04$$ @ app.js?mtime=1545734833000:2864
$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$2$ @ app.js?mtime=1545734833000:3016
$cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$02$$ @ app.js?mtime=1545734833000:3947
$cljs$core$merge_with$$.$cljs$core$IFn$_invoke$arity$variadic$ @ app.js?mtime=1545734833000:10165
(anonymous) @ app.js?mtime=1545734833000:17692
$secretary$core$route_matches$$ @ app.js?mtime=1545734833000:17509
(anonymous) @ app.js?mtime=1545734833000:17716
$cljs$core$some$$ @ app.js?mtime=1545734833000:5440
$secretary$core$locate_route$$ @ app.js?mtime=1545734833000:17713
$secretary$core$dispatch_BANG_$$ @ app.js?mtime=1545734833000:17726
$app$routes$on_goog_navigate$$ @ app.js?mtime=1545734833000:17977
$JSCompiler_StaticMethods_fireListeners$$ @ app.js?mtime=1545734833000:17459
$goog$events$EventTarget$$.dispatchEvent @ app.js?mtime=1545734833000:17440
$app$routes$on_window_click$$ @ app.js?mtime=1545734833000:17970
.shadow-cljs/builds--pseudo-names didn't use the cache either so it really shouldn't matter.m2 usually doesn't need to be deletedshadow-cljs compile your-build?compile and release always produced healthy bundlesyarn.lock file in the repo index.
Fixed it all.compile on the remote host.------ WARNING #1 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/events.cljc:61:11
--------------------------------------------------------------------------------
58 | (if *handling*
59 | (console :error "re-frame: while handling \"" *handling* "\", dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler.")
60 | (binding [*handling* event-v]
61 | (trace/with-trace {:operation event-id
-----------------^--------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.events/java
--------------------------------------------------------------------------------
62 | :op-type kind
63 | :tags {:event event-v}}
64 | (interceptor/execute event-v interceptors)))))))
65 |
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:48:29
--------------------------------------------------------------------------------
45 | (let [cache-key [query-v dynv]]
46 | ;; when this reaction is no longer being used, remove it from the cache
47 | (add-on-dispose! r #(do (swap! query->reaction dissoc cache-key)
48 | (trace/with-trace {:operation (first-in-vector query-v)
-----------------------------------^--------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
49 | :op-type :sub/dispose
50 | :tags {:query-v query-v
51 | :reaction (reagent-id r)}}
52 | nil)))
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:111:4
--------------------------------------------------------------------------------
108 | "
109 |
110 | ([query]
111 | (trace/with-trace {:operation (first-in-vector query)
----------^---------------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
112 | :op-type :sub/create
113 | :tags {:query-v query}}
114 | (if-let [cached (cache-lookup query)]
115 | (do
--------------------------------------------------------------------------------
------ WARNING #4 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:129:4
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
------ WARNING #5 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:305:34
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
------ WARNING #6 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:320:34
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
------ WARNING #7 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/router.cljc:126:5
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.router/java
--------------------------------------------------------------------------------
------ WARNING #8 --------------------------------------------------------------
File: zprint/focus.cljc:100:47
cljs.core/-, all arguments must be numbers, got [#{nil clj-nil} number] instead
--------------------------------------------------------------------------------
------ WARNING #9 --------------------------------------------------------------
File: com/rpl/specter.cljc:1275:19
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
------ WARNING #10 -------------------------------------------------------------
File: com/rpl/specter.cljc:1288:19
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
@import 'handsontable/dist/handsontable.full.css'; (https://github.com/handsontable/react-handsontable#handsontable-community-edition)node-sass CLI it'll try to connect to you can override which url it connects to by setting :devtools {:devtools-url ""}shadow-cljs server start, which will then be available at .
I'm then running a couple of builds on different hosts, using shadow-cljs watch buildA and shadow-cljs watch buildB. At the moment these two builds start their own, new shadow-cljs processes instead of using the one already available at .shadow-cljs server process running both watch should be using itshadow-cljs watch buildA buildB to run bothshadow-cljs watch script or after changing anything in the src file:before-load-async and :after-load functions:node-script since they keep the process alive which isn't always what you want (eg. when building CLI scripts). you can set :devtools {:enabled true ...}:autoload and :ignore-warnings to true: https://github.com/thisdotrob/shadow-cljs-node-hot-code-reload__filenamex /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js starting server http server running stop called stop completed undefined __filenamex2 /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js start called starting server http server running
:http-root and :http-port so it is being served up automatically after compilingshadow-cljs node-repl and do things manually but it won't execute hooksshadow.dom.append.cljs$core$IFn$_invoke$arity$2 [Line: 867, Col: 1], shadow.dom.js shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$2 [Line: 360, Col: 1], shadow.cljs.devtools.client.hud.js shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$1 [Line: 342, Col: 1], shadow.cljs.devtools.client.hud.js shadow$cljs$devtools$client$hud$connection_error [Line: 770, Col: 1], shadow.cljs.devtools.client.hud.js Anonymous function [Line: 1038, Col: 1], shadow.cljs.devtools.client.browser.js
connection-error is trying to display a warning and that failsbody is not available yet when I load my code.shadow$cljs$devtools$client$hud$connection_error is pretty clear in what it does 😉shadow-cljs compile your-build:devtools {:devtools-url ""}hud/dom-insert is using js/document.body is a little smelly 🙂 I’ll see if I can tweak that to make sure the error reporting works.document.body 😉head (long story, unavoidable unfortunately). Many things break 🙂body element.head is not the issue herebody is not presenthud.cljs. I’ve placed it right in my source path, path is <source-path>/shadow/cljs/devtools/client/hud.cljs but my changes don’t seem to have any effect. Am I doing something wrong?watch)setTimeout to a DOMContentLoaded event?(if js/document.body (current-behaviour) (try-later))(js/setTimeout (ws-connect)):devtools-url to work. It seems the code in env/ws-url expects a full url because it tries to replace http with ws.devtools-url be /shadow-cljs-server so that it goes to whatever the serving address is…. I want to instruct shadow to connect to . But I’m also loading my page from , so I want then the connection to be env.cljs doesn’t seem to take any effect. I wonder if all the google-closure defines at the top have anything to do with it.SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status Code: 200, OK... works just fine when using chrome inside a VM and safari outside the VM, where original-host is different. It’s only IE11 that complains with that cryptic error.[reload failed] invalid calling objectdocument.writes something that shadow-cljs controls? Or does it come from some lower level?:devtools {:loader-mode :eval}. should make things faster.lein. no need to compile anything, just need to publish the source files themselvesproject.clj with :dependencies and :source-paths. nothing else.(defproject my-lib "0.1.0"
:description "FIXME: write description"
:url ""
:license {:name "Eclipse Public License"
:url ""}
:dependencies [[some/thing "1.2.3"]]
:source-paths ["src/main"])
lein deploy clojarsshadow-cljs.edn for everything else and just use project.clj for publishingmain directory, i.e. src/main/my_project/core/lib.cljc. I would like to test it using devcards, so I created a file src/cards/my_project/core/lib.cljs (mirroring the main tree). I thought I would be apple to access methods define in my lib.cljc file but it looks like it’s not getting compiled as part of shadow-cljs watch cards. How can I remedy this?
(I am posting my question here as well as on #fulcro as I think the answer is shadow-related)lib_cards, after which I could import the core/lib.cljc namespace and take it from there. I would rather have both share the same namespace though, so my question still stands 🙂.shadow-cljs)?We detected unexpected middleware setup... should not be an issue, it is just a friendly reminder, that you should double-check it
you can suppress the check via {:skip-paranoid-middleware-setup-check true} passed as agent optionsjs/React to be present.cljsjs.react before devcardsReact(defn ^:export main [] (js/console.log "starting devcards UI") (dc/start-devcard-ui!) (devcards.system/renderer @devcards.system/app-state))
DEBUG global in the sources"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Empty object.
*/
exports.EMPTY_OBJECT = DEBUG ? Object.freeze({}) : {};
//# sourceMappingURL=empty_object.js.mapnode_modules\ivi-shared\dist\main\empty_object.js<script>window.DEBUG = false;</script> in your HTML before including the other JS(set! js/window.DEBUG false) should do itnode_modules. so I'd recommend converting and only publish "standard" JS to npm2.7.10(defn start []
(boot/init compile-state-ref
{:path "/bootstrap"}
compile-it))#!/bin/bash -eo pipefail
npx karma start --single-run
05 01 2019 20:23:40.760:WARN [watcher]: Pattern "/home/circleci/project/target/ci.js" does not match any file.
05 01 2019 20:23:40.766:INFO [karma-server]: Karma v3.1.4 server started at
05 01 2019 20:23:40.766:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
05 01 2019 20:23:40.770:INFO [launcher]: Starting browser ChromeHeadless
05 01 2019 20:23:41.059:INFO [HeadlessChrome 71.0.3578 (Linux 0.0.0)]: Connected on socket -fOAgM3QhFtvOxByAAAA with id 55473730
HeadlessChrome 71.0.3578 (Linux 0.0.0) ERROR
{
"message": "ReferenceError: shadow is not defined\n at eval (eval at <anonymous> (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at ",
"str": "ReferenceError: shadow is not defined\n at eval (eval at <anonymous> (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at "
}
Exited with code 1
ls before the karma command shows that the expected file target/ci.js is missing when the test failsshadow-cljs compile ci-tests prints [:ci-tests] Build completed. whereas on an unsuccessful build it doesn print that, however both return exit code 0shadow-cljs compile ci-tests prints [:ci-tests] Build completed. whereas on an unsuccessful build it doesn print that, however both return exit code 0`shadow-cljs - config: /home/circleci/project/shadow-cljs.edn cli version: 2.7.10 node: v10.15.0 shadow-cljs - starting via "clojure" WARNING: requiring-resolve already refers to: #'clojure.core/requiring-resolve in namespace: datomic.common, being replaced by: #'datomic.common/requiring-resolve NPM dependency "reakit" has installed version "0.15.13" "^0.11.1" was required by jar:file:/home/circleci/.m2/repository/fulcrologic/fulcro-incubator/0.0.24/fulcro-incubator-0.0.24.jar!/deps.cljs NPM dependency "react-icons" has installed version "3.2.2" "^2.2.7" was required by jar:file:/home/circleci/.m2/repository/fulcrologic/fulcro-incubator/0.0.24/fulcro-incubator-0.0.24.jar!/deps.cljs [:ci-tests] Compiling ... added 104 packages from 62 contributors and audited 1976 packages in 2.047s found 0 vulnerabilities
[:ci-tests] Build completed. (949 files, 814 compiled, 0 warnings, 23.88s)
<- Cache write: ucv/lib/form_encoding.cljc (7 ms) -> Compile CLJS: ucv/lib/uism_extensions.cljc -> Compile CLJS: ucv/ui/alert_test.cljs -> Compile CLJS: ucv/ui/order_flow/shared.cljs <- Cache write: ucv/util.cljc (11 ms) <- Compile CLJS: ucv/ui/order_flow/shared.cljs (10 ms)
:jvm-opts ["-Xmx2G"] or however much your CI machine allows:jvm-opts go? inside the build options along with stuff like :target and :compiler-options?shadow-cljs.ednshadow-cljs to not include a namespace? e.g. we get cljs.pprint in our bundle due to some bad DCE and would like to force it to be gone 😜 thinking maybe a hook could do this?cljs.pprint. the option for that however is not exposed since its kind of a footgun and easy to destroy your entire build using it2.7.11 which exposes those options. I'll just document with a warning but basically you can now add :compiler-options {:strip-type-prefixes #{"cljs.pprint"}}cljs.pprint related, which also includes every USE of cljs.pprint so beware 😉:release builds thoughshadow.cljs.devtools.api/nrepl-select, how can I switch over to another build? Can I require shadow-cljs from within the build?:cljs/quit------ WARNING #1 -------------------------------------------------------------- File: shadow/module/main/append.js:2 variable shadow$umd$export is undeclared --------------------------------------------------------------------------------any clues as to what might be wrong would be super helpful, thanks
{
"errorMessage": "Cannot find module 'bluebird'",
"errorType": "Error",
"stackTrace": [
"require (internal/module.js:11:18)",
"/var/task/main.js:494:240",
"shadow$umd$export (/var/task/main.js:5:22)",
"Object.<anonymous> (/var/task/main.js:9:3)",
"Module._compile (module.js:652:30)",
"Object.Module._extensions..js (module.js:663:10)",
"Module.load (module.js:565:32)"
]
}
I can see the shadow$umd$export mentioned in there, so I suspect it's related"errorMessage": "Cannot find module 'bluebird'"npm install bluebirdnpm install bluebird (i've done yarn add bluebird, which i'm hoping does the same thing)?target folder which is what i'm sending to AWSnode_modules folder in your uploadyarn add react react-dom create-react-classbluebird is most likely coming from promesa(js/fetch "something")js/fetch, what is that? is there some js interop i can use to make http requests without having to use a cljs one?js/fetch is for the browsercljs-http should be working for node?request lib is pretty popular I thinkhttp package is built-in and should work just finevariable shadow$umd$export is undeclared warning on compilation. is that something to worry about?shadow-cljs compile or shadow-cljs release?shadow-cljs release when copying something to AWSyarn shadow-cljs release app)$ yarn shadow-cljs release app; cd target; rm arch ive.zip; zip -r archive.zip *; cd .. yarn run v1.12.3 $ /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/node_modules/.bin/shadow-cljs release app shadow-cljs - config: /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/shadow-cljs.edn cli version: 2.7.9 node: v8.15.0 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app [:app] Compiling ... ------ WARNING #1 -------------------------------------------------------------- File: shadow/module/main/append.js:2 variable shadow$umd$export is undeclared -------------------------------------------------------------------------------- nil [:app] Build completed. (130 files, 1 compiled, 0 warnings, 16.52s) Done in 37.80s.
shadow-cljs.edn:
{:lein true
:builds {:app {:target :node-library
:exports {:handler server.main/handler}
:output-dir "target"
:output-to "target/main.js"}}}
:npm-module builds just work howeverrequire("shadow-cljs/shadow.cljs.devtools.client.react_native") from JS and set :runtime :react-native in your build configrequire("./path-to-output-dir/shadow.cljs.devtools.client.react_native")(.creatElement r example)hxhx.react.hooks namespacegulp and node-sass in a Makefilewith-letCannot infer target type in expression (. c__36937__auto__ -ratomGeneration):infer-externs or live with the warning/api/* into another server )The required namespace "cljsjs.antd" is not available, it was required by "brickmarket/ui.cljs". My deps.edn includes
cljsjs/antd {:mvn/version "3.12.0-0"}
antizer {:mvn/version "0.3.1"}
any guess what i'm doing wrong?npm install cljsjs/antd but npm fails to install it.npm install --save antdcljsjs.antd namespace that exposes antd. See https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjsshadow-cljs: reloading code but no :after-load hooks are configured! :devtools {:before-load cljs.dev/stop :after-load cljs.dev/start} in my :builds profilecljs.. they are reserved for CLJS itself. the hooks are not allowed in cljs.*IllegalStateException: could not find where to put constant for module goog.labs.useragent.engine.js
shadow.build.closure.ReplaceCLJSConstants.process (ReplaceCLJSConstants.java:60)
...
Any suggestions for what kind of thing should I be looking for to track down what might be triggering this?:depends-on configured correctly?IllegalStateException: could not find where to put constant for module this should only happen when :modules are setup incorrectly. can't explain how it would happen otherwise.closure-compiler version? yes if using shadow-cljs.end, maybe not if using deps/lein.shadow-cljs cache dir the build works once, but then fails on subsequent attempts:modules {:main {:entries [myapp.core]}}goog.labs.useragent.engine.js:modules.:target :browser I assume?:target :npm-module and :runtime :browser:modules. it is not allowed for :npm-module builds:entries.:build {:stuff {:target :npm-module :entries [myapp.core]}}:npm-module desugars to a pretty complex :modules configurationgoog.dom.dom.js, even after with the :entries fix:modules from all :npm-module buildsgoog.dom.dom.js. But this is after :modules has been removed!goog.labs.useragent.engine.js again. Same IllegalStateException, yeah.^:private be a problem?This branch. are you sure this branch has the updated build config? if you have a server instance running it may still be using an older version too?IllegalStateException: could not find where to put constant for module goog.dom.dom.js, but subsequent times I get the same error but for goog.labs.useragent.engine.js again.:npm-module builds before..shadow-cljs/builds/<your-build>/release directory. its all the cache files and generated JS. maybe I can find something?:options keyword in any view function is the trigger, even if the function isn't used.:options in re-frame subs or cljss/defstyles wihtout issue(defn secondary-config-mappings
[]
{:options nil})
triggers the error, but
defn secondary-config-mappings
[]
{:optionss nil})
does not. The function is not used anywhere in the code.(def blah :options) in another file, the error doesn't triggerdefn, the error still triggersoptions triggers it too 😕options argument didn't trigger the error:proxy-url to point at the local server? Or maybe it's more appropriate to configure the client's :http-handler to reference the server's main handler fn? This would suggest that the client/server projects are one monolith, or that the client project depends on the server project somehow.
Just trying to get a feel for what others have been doing...shared, server, client, so most of the code goes in shared, and in the others only specific code that calls to specific host features (like node FS or browser fetch, etc...):local/root. What about "integration" between client/server though? I think what I'm confused about is how do I replace the shadow development server with my own server? Is the :http-handler setting the preferred approach?app.main (entry point) requires my app.state (and uses a bunch of functions) which in turn requires my app.spec — and uses nothing from there. However I get an error like so main.js:3045 failed to load app.state.js Error: Unable to resolve spec: :base/count
at Object.cljs$spec$alpha$the_spec [as the_spec] (alpha.cljs:121)
at Function.eval [as cljs$core$IFn$_invoke$arity$5] (alpha.cljs:518)
at Function.eval [as cljs$core$IFn$_invoke$arity$4] (alpha.cljs:513)
at Object.cljs$spec$alpha$def_impl [as def_impl] (alpha.cljs:314)
at eval (state.cljs:120)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:2188)
at Object.env.evalLoad (main.js:3043)
at main.js:3261:base/count is defined in app.spec like so (s/def :base/count (complement neg-int?)) — and if I put that declaration in my app.state ns, the problem goes away.:loader-mode :eval if it makes any difference.:loader-mode :eval still works..js files for exampleshadow-cljs.edn{
"version": 2,
"builds": [
{ "src": "docs/package.json", "use": "@now/static-build" },
{ "src": "blog/package.json", "use": "@now/static-build" }
]
}(ns demo.now) (defn handler [^js req ^js res] (.end res "Hello World"))
:now-lambda
{:target :node-library
:exports-var demo.now/handler
:output-to "out/demo-now/index.js"}shadow-cljs release now-lambda cd out/demo-now now:exclusions [cljsjs/reac cljsjs/react-dom]:node-library running Google Cloud Functions, and one a browser app that communicates with those functions via Firebase. I'd also like to share some common code between them. Is there a way to specify different package.json files per build in one shadow-cljs and build these both from one shadow-cljs server run, or is it best to run two separate shadow-cljs instances?:devtools {:enabled false} (like in the above config)error: SHADOW import error /Users/thomas/Develop/take2/experiments/threshold-functions/functions/.shadow-cljs/builds/gcf/dev/out/cljs-runtime/shadow.js.shim.module$ws.js ... Error: Cannot find module 'ws'
npm install ws?:devtools {:enabled false}firebase > error: no "source-map-support" (run "npm install source-map-support --save-dev" to get it) but I think I remember a shadow config to disable source-maps:compilar-options {:source-map false} fixed that, so now it's working great! Wow, I'm so impressed with shadow-cljs Thank you!:npm-module instead of :node-library if the emulator is so picky:from-jar is supposed to filter everything where the source file is in a jar, ie. libraryom.next warning about *logger*, etc. we also execute everything from the devtools api, not the command line, if that matters, e.g. (server/start!), (shadow/watch :foo):from-jar isn’t hitting our case(ns my.ns (:require ["firebase/auth" :as fb-auth])) is showing up marked as unresolved. If not, is there a way to trick it?(:require [firebase]) and have cursive resolve it. Maybe with externs? I guess this is what cljsjs does?(:require [cljsjs.react]) without alias and use the global js/React:devtools {:preloads [some.ns]}:entries?(assoc-in [::modules/config :main :entries]
(-> '[]
(into (get config :entries []))
(into dynamically-resolved-namespaces)
(conj 'nubank.workspaces.shadow-cljs.mount))))../deploy/bin/shadow-karma-test: line 9: echo: write error: Resource temporarily unavailable, had anybody here had this problem? ideas what could be about?#shadow/env "THE_KEY" in the config:closure-defines {some.thing/foo #shadow/env "FOO"}:target :node-script is used with :modules {:main {:init-fn a.b/c}}, I saw no warnings on running shadow-cljs.edn.
2. ":after-load x.y/reload" is written in the configs while the real namespace is a.b/reload,
3. I added ["fs" :as fs] and save file, is how replaces and import fs. however it throws an error. restarting the process then it will be ok.dev and it gives me this error: WARNING: No Clojure project was detected. The refactor-nrepl middleware was not enabled. (You can mute this warning by customizing `cljr-suppress-no-project-warning'.) shadow.user> ExceptionInfo no build with id: :dev clojure.core/ex-info (core.clj:4739)WARNING: No Clojure project was detected. The refactor-nrepl middleware was not enabled. (You can mute this warning by customizing `cljr-suppress-no-project-warning'.) shadow.user> ExceptionInfo no build with id: :dev clojure.core/ex-info (core.clj:4739)
:app if you are using the default giggin configWARNING: No Clojure project was detected. The refactor-nrepl middleware was not enabled. (You can mute this warning by customizing `cljr-suppress-no-project-warning'.) shadow.user> To quit, type: :cljs/quit [:selected :app] cljs.user>
------ WARNING #5 -------------------------------------------------------------- File: xxx/animate.cljc:34:21 variable ReactTransitionGroup is undeclared --------------------------------------------------------------------------------it seems to closure optimize fine when I grep the output … but I’m worried I’m missing what its warning me about 🙂
(js/goog.exportSymbol "ReactTransitionGroup" react-transition-group) (we’re still migrating …)Raven -- compiled output: https://gist.github.com/eyston/9b60e0896bb344ffd4055637d79e6a48 — I think that sa is the goog.exportSymbol 😜exportSymbol is right thereReactTransitionGroup?(js/React.createElement
js/ReactTransitionGroup.CSSTransition
(clj->js props)
#(f (keyword %)))js/* should be fine-> Closure - Optimizing ... ------ WARNING #1 -------------------------------------------------------------- File: com/cognitect/transit.js:649:8 variable module is undeclared --------------------------------------------------------------------------------
Closure - Optimizing ... step[:widget] Build completed. (437 files, 303 compiled, 1 warnings, 75.64s) ------ WARNING #1 -------------------------------------------------------------- File: om/next.cljc:493:4 --------------------------------------------------------------------------------
.shadow-cljs/builds/<your-id>/release/shadow.externs.js contains ReactTransitionGroup.ShadowJS.prototype.* ?/** @const {ShadowJS} */ var FormData;
/** @const {ShadowJS} */ var PropTypes;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var requestAnimationFrame;
this is at the top, the rest is on ShadowJS — no ReactTransitionGroupShadowJS.prototype.CSSTransition;
/** @const {ShadowJS} */ var ReactTransitionGroup; plus the handful of others not picked up?global:ReactTransitionGroupcp: cannot stat 'PREFIX/example-deps.edn': No such file or directory
:deps config optionclj repljs/main.js. that JS is generated by shadow-cljs. it is your CLJS app's codejs/main.jslein testlein test so I don’t know what the “normal” is either 😄clojure.testERROR in (select-tag-simple) (TypeError:NaN:NaN) toggling a tag on and off works expected: (= true (gamma.state/tag-selected? selected-state tag-id1)) actual: #object[TypeError TypeError: Cannot read property 'append' of undefined]
cljs-test-display which is greatcljs-test-display for node would be awesome 😄 cljs.core and some of the google closure librarycljs.core instances on the pagecljs.core and assume it providedeval it(eval '(println "foo")) in ClojureScriptcljs.core and some of the closure libraryimmutable-js + lodash or sojQuery loaded somewhereeval?cljs.core versionscljs.core?cljs.core etc.:output-wrapper be able to ensure I don't clobber a user's application?:output-wrapper would isolate everythingnav / datafynav + datafy are protocols and sometimes on metadatatap> itnav or datafy, it sends an event back to the user's application to call nav or datafy on the entry in the atom and then send the result back to the REBL appshadow-cljs of a dependency that doesn’t exist in package.json? in my example, jquery w/ bootstrap ;/console.error messages to the devtools area, i presume that it is because *out* is mapped to console ? I am right in thinking that? And if so can i map it to something else ? I want to map out such that these debug messages are visible in a text area in the app instead of devtools console. Would it be possible to do that?console or everything goes to wherever you set *out* to. you can call (set-print-fn! (fn [foo] ....)) to control where prints goes.:devtools {:http-root "admin/public"
:http-port 1337
:after-load threshold.admin.core/reload
:preloads [fulcro.inspect.preload threshold.admin.development-preload]}
:modules {:main {:init-fn threshold.admin.core/main
:entries [threshold.admin.core]}
:worker {:devtools {:enabled false}
:entries [threshold.admin.worker.core]
:depends-on #{:main}
:web-worker true}}
#shadow/env "FOO" in the build config to access environment variables:cache-blockers to prohibit caching of files that use side-effecting macros https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cacheinit function. (defn ^:export init [some-config] ...) <script>your.ns.init({"url":"http://..."});</script><script>var MY_CONFIG = {...};</script> and then accessing js/MY_CONFIGindex.html + index-ci.html or soReferenceError: garden is not defined, but I can't figure out why. It happens while using cljs code as a regular module on webpack. The CLJS code targets :npm-module and is generated with the compile task.
The component in question uses https://github.com/matthieu-beteille/cljs-css-modules, and adding garden.core on the ns that uses it "solves" the problem.
The compiled webpack bundle contains modules for cljs-css-modules, garden and my component, as expected. cljs-css-modules contains a __webpack_require__ pointing to garden's module.
Without garden.core explicitly required, my component's module contains a __webpack_require__ to cljs-css-modules but it fails.
With garden.core require outside the ns (via a macro that outputs a require), the module gains a goog.require('garden.core') but it still fails.
With garden.core explicitly imported on the component, the webpack module gains a __webpack_require__ to the garden module, a garden=$CLJS.garden and a goog.require('garden.core'). Everything works.
What is confusing me is that cljs-css-modules imports garden.core, and my code both requires and webpack_requires cljs-css-modules. Is it expected to have to require garden again?version: 2.7.8 node: v9.11.2(deftype MockRemote [query-map error-map]
dp/IDataRemote
(query! [this query config]
(-> (p/delay 100)
(p/then
(fn []
(when (contains? error-map query)
(throw (error-map query)))
(if (contains? query-map query)
(query-map query)
(query-map :mock/default)))))))
completely failed in a release build(p/delay 100)Error: 1
at modulemanager.js:588
at $goog$module$ModuleLoadCallback$$.execute (moduleloadcallback.js:60)
at $JSCompiler_StaticMethods_callCallbacks_$$ (moduleinfo.js:324)
at $JSCompiler_StaticMethods_onError$$ (moduleinfo.js:287)
at $JSCompiler_StaticMethods_dispatchModuleLoadFailed_$$ (modulemanager.js:1261)
at $JSCompiler_StaticMethods_requeueBatchOrDispatchFailure_$$ (modulemanager.js:1193)
at $goog$module$ModuleManager$$.$APP.$JSCompiler_prototypeAlias$$.$handleLoadError_$ (modulemanager.js:1146)
at $JSCompiler_StaticMethods_evaluateCode_$$ (moduleloader.js:373)
at $goog$module$ModuleLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (moduleloader.js:256)
at $JSCompiler_StaticMethods_fireListeners$$ (eventtarget.js:284)
at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.dispatchEvent (eventtarget.js:381)
at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (bulkloader.js:168)
at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleEvent_$ (bulkloader.js:118)
at $JSCompiler_StaticMethods_fireListeners$$ (eventtarget.js:284)
at $goog$net$XhrIo$$.$APP.$JSCompiler_prototypeAlias$$.dispatchEvent (eventtarget.js:381)
at $JSCompiler_StaticMethods_onReadyStateChangeHelper_$$ (xhrio.js:867)
(p/promise
(fn [resolve _]
(js/setTimeout #(resolve "resolved") 100)))
resolved the issueresources, but is there a better way?
thxdeps.cljs with {:npm-deps {"the-dep" "version"}}npm-deps tip. regarding the css, re-com is just bundling it inside resources/public/assets/css and I think that's good enoughpublic resources@import it in my scss code but I won't be able to if it's a resourceresources/{groupId}/{artifactId}/{version}/main.css?resources/your/lib/foo.css:advanced optimization errors Uncaught ReferenceError: Oe is not defined. I tried :simple optimization, no error occurs. Is that related to the code splitting during :advanced?:advanced with shadow-cljs release your-build --pseudo-names to find out what Oe is. I always use :advanced with :modules so it should workprepend and append(function(){...}.call(this); and call a exported method:output-wrapper true:modules just assumes everything is in a global scope by defaultshadow-cljs release some-build and get source maps?:app
{:target :browser
:output-dir "./min"
:compiler-options {:source-map true}
:modules {:application {:init-fn app.core/run}}}}}:compiler-options {:source-map true}:foreign-libs in deps.cljs?:foreign-libs are intentionally not support at all. so no there is no way to use it with shadow-cljs. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjsresources), then you'll run the CLJS compilation step first. Then create the uberjar. Then deploy the uberjarFirst you need a “host” build which will be your “app” (currently limited to :browser builds).google-closure-compiler-js or rather the JS version of google-closure-compiler it might work(defmacro abc [] (do-this-in-cljs-not-clj)) e.g. (defmacro abc [x] (js/parseInt x))(defn abc [x] (js/parseInt x)) that’s fine, but (defmacro abc [x] (js/parseInt x)) it would fail off the bat since you can’t defmacro in CLJS without bootstrap anyway(t/defn append! [s #?(:clj (t/isa? java.lang.StringBuilder) :cljs (t/isa? js/StringBuffer)), x string?] #?(:clj (.append s x) :cljs (.join s x)))append! are indeed providing a js/StringBuffer or not(append! 123 "abc") would fail whereas (append! (js/StringBuffer.) "abc") would succeed, both at compile timet/dotyped, it can analyze the forms and see in (js/StringBuffer.) that it’s a constructor (`new` form), which returns a class of whatever the first argument is (in this case js/StringBuffer). The compiler can then evaluate the symbol 'js/StringBuffer to the actual classjs/StringBuffer(def str-buf #(js/StringBuffer.)) (append! (str-buf) "abc")?
str-buf which is a js/Function; it wouldn’t have any knowledge about the internals of str-buft/fn in that case(def str-buf (t/fn [] (js/StringBuffer.)))str-buf isstr-buf would be (t/ftype [> (t/isa? js/StringBuffer)]) i.e. a function that takes no args and returns a js/StringBuffer, when str-buf is called, (dotyped (append! (str-buf) "abc") would know the type(t/defn f [m (t/and t/map? my-arbitrary-predicate)] ....), then (t/dotyped (f {:a 1 :b 2})) can be checked at compile time(t/fn [m t/map?] (f m)), my-arbitrary-predicate will have to be checked at runtimejs/StringBuffer equal the symbol js/StringBuffer?)(t/defn f [x my-arbitrary-predicate] ...) and (t/dotyped (f "asd")) you could run my-arbitrary-predicate in CLJ at compile-time to figure out type-satisfaction, whereas in CLJS you’d always have to resort to runtime type checkingjs/StringBuffer in your type-checking program is the same as js/StringBuffer at runtime is only accidental'js/StringBuffer' in your type-checking program is the same as 'js/StringBuffer' at runtime is only accidental → I get what you’re saying. For instance js/StringBuffer might mutate or something, or be completely different in compilation than at runtime(def a 1) ;; nested in some other code .... (def a "foo") (defn inc-a [] (+ a 1))
;; nested in some other code .... (def a "foo")My answer is just don’t do that haha
(def a 1) and resolve that to a Number or java.lang.Integer doesn't buy you any more guarantees(t/def a 1) then the type of a would be (t/value 1) which is a lot more useful than Number or java.lang.Integerdef and it would resolve from the environmentstatic block is run as in Class/forName)(t/defn [x my-arbitrary-predicate] ...) requires that my-arbitrary-predicate will have had to have been evaluated at compile time, not just symbolically analyzed, to truly enforce itcljs.core/eval works at runtime?BACKEND=localhost npx shadow-cljs start # from repl: (shadow.cljs.devtools.api/watch :my-app) # do some development ... then release: BACKEND= npx shadow-cljs release my-app
--force-spawn but in my case I have several builds, so reusing the server would be of great benefit(defn my-release []
(-> (api/get-build-config :your-build)
(assoc-in [:closure-defines '] "foo.bar")
(api/release* {})))api being shadow.cljs.devtools.apishadow-cljs run your.util/my-release(your.util/my-release) from the REPL:release {:closure-defines {your.backend/url "foo.bar"}} will take care of everythingshadow-cljs.edn file and let that be the source of truthrun with a custom release function as you can make any edit you want. environment variables always seem very brittle to me so I don't use them everyour.app.init({"backend":"foo.bar"}) from HTMLaws cli. porting those to cljs would be an option, but the aws apis are often more tedious than the cli.now platform recently and that was pretty easynow could be an option for my use-case. I’ll have to look into that.shadow-cljs release now-lambda and cd output-dir; nowshadow-cljs watch app on OSX:verbose true
:log {:level :debug}shadow-cljs.edn configlein installlein installed code?fs-watch is used for everything file watching relatedfsnotify always correctly detects the writes as a single file change (see “Additional Details” at the bottom of the issue)"auth0-lock": "^11.13.0" and I require it via (:require [auth0-lock :refer [Auth0Lock]]). In shadow-cljs 2.3.0 Auth0Lock is an object, but in 2.7.16 it’s nil. Any idea why?shadow.js.js:82 Uncaught TypeError: Cannot read property 'lib' of undefined
at auth0.min.js:9
at auth0.min.js:9
at createCommonjsModule (auth0.min.js:9)
at auth0.min.js:9
at auth0.min.js:9
at Object.shadow$provide.module$node_modules$auth0_js$dist$auth0_min (auth0.min.js:9)
at shadow.js.jsRequire (shadow.js.js:79)
at Object.shadow$provide.module$node_modules$auth0_lock$lib$utils$cdn_utils (cdn_utils.js:8)
at shadow.js.jsRequire (shadow.js.js:79)
at Object.shadow$provide.module$node_modules$auth0_lock$lib$i18n (i18n.js:37)
:js-options {:variable-renaming :local} in your build config$ shadow-cljs clj-run my.build/release as a thing I could do, but when I do: $ shadow-cljs clj-run dev.build/main --start-server I get: $ shadow-cljs clj-run dev.build/main --start-server shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn cli version: 2.7.16 node: v10.15.0 shadow-cljs - starting via "clojure" Unknown option: "--start-server" Usage: shadow-cljs <action> <zero or more build ids> ...
cljs.core/*target* to "default" but apparently is not workingshadow-cljs clj-run dev.build/main -- --start-server?"default" by default? what is it for you? :npm-module doesn't set it explicitely at allbuild.clj file that uses hawk/watch! to reload clojure stuff (for the server) and SCSS and who knows what else 🙂chokidar to run things on file change:requireing this npm on my project: https://github.com/hexenq/kuroshiro(:require ["kuroshiro" :default Kuroshiro] brings back a nil Kuroshiro(:require ["kuroshiro" :as Kuroshiro]) returns #js {} (empty object)(Kuroshiro.) ;; => Uncaught TypeError: module$node_modules$kuroshiro$lib$index is not a constructornode_modules/kuroshiro files. maybe something got lost or so?$ shadow-cljs browser-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn version: 2.7.16 shadow-cljs - connected to server [:browser-repl] Configuring build. [:browser-repl] Compiling ... [:browser-repl] Build completed. (134 files, 35 compiled, 0 warnings, 4.25s) [6:1]~cljs.user=> (require '["kuroshiro" :as k]) nil [6:1]~cljs.user=> k #object[Kuroshiro] [6:1]~cljs.user=> (k.) #object[Kuroshiro [object Object]] [6:1]~cljs.user=>
node_modules/kuroshiro directory and if it matches what unpkg shows:default instead of :as:default is kinda of weird since npm packages can't decide how they want to package stuffsubscribe method on the client you can use(api/send-to-client! :the-build-id {:whatever :you :like 1})(env/subscribe! the-msg-handler-callback) which would be (fn [msg] ...):preload that does the subscribe2.7.17 I added (shadow.cljs.devtools.api/send-to-runtimes! build-state-or-id some-msg) for the CLJ part which you can call from a hook or the REPL or any other code(shadow.cljs.devtools.client.env/subscribe! ::some-id (fn [msg] ...))::some-id so that when code that calls subscribe! gets reloaded it overwrites the old instead of adding a second onewatch for a browser build try this in the browser consoleshadow.cljs.devtools.client.browser.compile("(prn :foo)", function(result) { console.log(result); })cljs.reader/read and get some EDN back, that reagent will happily try to render — but in this case symbols get turned into strings, while I want to look them up in my actual build.compile function in theory:js field:js "cljs.core.prn.call(null,new cljs.core.Keyword(null,"foo","foo",1268894036))"eval(js/goog.globalEval (:js ...))prn returns nilcompile("(fn [x] (+ 1 x))", ...)(shadow.browser/compile "(inc 1)"
(fn [result]
(let [src (get-in result [:actions 0 :js])
res (js/goog.globalEval src)]
(js/console.log src "=" res))
))((1) + (1)) – "=" – undefined — I would expect to see a 2 somewhere.(inc 1) with a prn, I do see 2 printed, so I think it’s something to do with JS not having expressions?(fn [] (inc 1)) that should give you back a function you can call to get the actual resultSyntaxError: Unexpected token '.'. Expected an opening '(' before a function's parameter list.(function cljs$user$cljs.user.cljs(){
return ((1) + (1));
})npm upgrade -g shadow-cljs and I did see $ npm update -g shadow-cljs /Users/orestis/.nvm/versions/node/v10.15.0/bin/shadow-cljs -> /Users/orestis/.nvm/versions/node/v10.15.0/lib/node_modules/shadow-cljs/cli/runner.js +— but when invoking shadow-cljs again I still see 2.7.16…
Error: clojure is not defined using :target :npm-module ? I'm using webpack toonpm install shadow-cljs in your project should update it there (without the -g)clojure.string (or similar clojure.*) directly without a require for itwatch)clojure.set is required somewhere before the re-frame stuff is loaded it should work(js/goog.global.eval the-code). guess globalEval doesn't like return values➜ core git:(cljs) ✗ echo "(shadow/repl :test)" | nc localhost 58218 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [10:0]~shadow.user=> [10:1]~cljs.user=> nil [10:0]~shadow.user=> % ➜ core git:(cljs) ✗ echo "(prn :x)" | nc localhost 58218 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [11:0]~shadow.user=> :x nil [11:0]~shadow.user=> %
output-dir from CLI?
something like
clj -A:shadow-cljs -m shadow.cljs.devtools.cli release prod --output-dir "resource/public" ?nc an echo it will end with closing stdin which means closing the REPL:release specific config or use clj-run though(defn release [path]
(-> (shadow/get-build-config :your-build-id)
(assoc :output-dir path)
(shadow/release* {})))shadow-cljs run your.util/release resource/publicnode require("@material/textfield/constants.js").mjs extensionproject.clj or deps.ednclj-run(defn release [path]
(-> (shadow/get-build-config :your-build-id)
(assoc :output-dir path)
(shadow/release* {})))(assoc-in [:clojure-defines 'your.ns/git-commit] the-commit)cljsjs/* files in your project?shadow-cljs clj-repl and ( "cljsjs/react.cljs")#object[java.net.URL 0x55589ef5 "jar:file:/home/jan/.m2/repository/thheller/shadow-cljsjs/0.0.16/shadow-cljsjs-0.0.16.jar!/cljsjs/react.cljs"]:target do you use? any custom :js-options?{:mybuild
{:target :browser
:modules {:main {:init-fn my-ui.common/on-js-reload}}}}}:init-fn?{:mybuild
{:target :browser
:modules {:main {:entries [your.actual.main-ns]}}
:devtools
{:after-load my-ui.common/on-js-reload}}}:init-fn to call what you are now calling at the top level instead of calling it[:app] Build completed. (1038 files, 8 compiled, 4 warnings, 11.03s)
------ WARNING #1 --------------------------------------------------------------
File: zprint/focus.cljc:100:47
--------------------------------------------------------------------------------
97 | #_(println "range-ssv: start:" start "nwpath:" nwpath)
98 | start (skip-whitespace-ssv ssv start)
99 | ssv-next (next-ssv ssv start)
100 | end (if (and ssv-next (not= start 0)) (dec ssv-next) (dec (count ssv)))]
-----------------------------------------------------^--------------------------
cljs.core/-, all arguments must be numbers, got [#{nil clj-nil} number] instead
--------------------------------------------------------------------------------
101 | #_(println "range-ssv:" [start end])
102 | [start end]))
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: com/rpl/specter/impl.cljc:786:6
--------------------------------------------------------------------------------
783 | val))
784 |
785 | (mk-late-fn-records)
786 | (mk-late-fn)))
------------^-------------------------------------------------------------------
Use of undeclared Var com.rpl.specter.impl/java
--------------------------------------------------------------------------------
787 |
788 | #?(:clj
789 | (defn static-fn-code [afn args]
790 | `(~afn
There's not much I can do about them except to open an issue on the repo or try to fix them myself. I was wondering if it made sense for some sort of option in shadow-cljs.edn for :ignore-warnings-from-namespaces or :only-show-warnings-from-this-ns-list, so I could more easily see warnings/errors from code I actually control. If there already is something like this that I'm not aware of, my apologies for the large message. Thanks for listening!:http-handler fn, and a :proxy-url, right? Because the proxy will take over.i'd prefer to the BDFL of shadow-cljs is a little presumptuous, so do what you think is best 🙂lein-tools-deps broke my shadow-cljs build.
"release" build still works
But when I use (shadow/watch :main) from repl:
[:main] Build failure: The required namespace "goog" is not available, it was required by "cljs/user.cljs".I still use
:lein {:profile "+dev,+client,+webdev"}
(slurp (io/resource "cljs/user.cljs")) ;; => (ns cljs.user)\n (it's a empty namespace, I used it long time ago, now it's empty)(io/resource "goog/base.js") look like the closure lib may be missing?#object[java.net.URL
0xb705e1b
"jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
When i slurp it, it shows a lot of jscljs/user.cljs from though? shadow-cljs doesn't ship with one?dev/cljs/user.cljs that is in my classpathThe required namespace "goog" is not available, it was required by "cljs/user.cljs".
now with (io/resource "cljs/user.cljs") ;;=> nilrm -rf .shadow .cljs ...anything-that-i-can-rm
I also moved from graalvm into JVM11(-> (Thread/currentThread)
(.getContextClassLoader)
(.getResources "goog/base.js")
(enumeration-seq))"jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"(io/resource "shadow/build.clj")?"jar:file:/home/souenzzo/.m2/repository/thheller/shadow-cljs/2.7.16/shadow-cljs-2.7.16.jar!/shadow/build.clj".shadow-cljs and restarted shadow-cljs after doing that I assume?watch a build in advanced compilation?watchshadow-cljs release your-build --pseudo-namesshadow-cljs check your-build:compiler-options {:infer-externs :auto}:auto enables it for all your sourcestrue requires you to (set! *warn-on-infer* true) for every source you want to enable it forZipException too many length or distance symbols java.util.zip.InflaterInputStream.read (InflaterInputStream.java:164)[java.util.zip.InflaterInputStream read "InflaterInputStream.java" 164]
[java.io.FilterInputStream read "FilterInputStream.java" 133]
[java.io.BufferedInputStream read1 "BufferedInputStream.java" 284]
[java.io.BufferedInputStream read "BufferedInputStream.java" 345]
[sun.nio.cs.StreamDecoder readBytes "StreamDecoder.java" 284]
[sun.nio.cs.StreamDecoder implRead "StreamDecoder.java" 326]
[sun.nio.cs.StreamDecoder read "StreamDecoder.java" 178]
[java.io.InputStreamReader read "InputStreamReader.java" 184]
[java.io.BufferedReader fill "BufferedReader.java" 161]
[java.io.BufferedReader read1 "BufferedReader.java" 212]
[java.io.BufferedReader read "BufferedReader.java" 286]
[java.io.Reader read "Reader.java" 140]
[$fn__11010 invokeStatic "io.clj" 337]
[$fn__11010 invoke "io.clj" 334]
[clojure.lang.MultiFn invoke "MultiFn.java" 238]
[$copy invokeStatic "io.clj" 406]
[$copy doInvoke "io.clj" 391]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.core$slurp invokeStatic "core.clj" 6871]
[clojure.core$slurp doInvoke "core.clj" 6862]
[clojure.lang.RestFn invoke "RestFn.java" 410]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath$fn__25207 invoke "npm_deps.clj" 164]
[clojure.core$map$fn__5587 invoke "core.clj" 2747]
[clojure.lang.LazySeq sval "LazySeq.java" 40]
[clojure.lang.LazySeq seq "LazySeq.java" 49]
[clojure.lang.Cons next "Cons.java" 39]
[clojure.lang.RT next "RT.java" 706]
[clojure.core$next__5108 invokeStatic "core.clj" 64]
[clojure.core.protocols$fn__7852 invokeStatic "protocols.clj" 169]
[clojure.core.protocols$fn__7852 invoke "protocols.clj" 124]
[clojure.core.protocols$fn__7807$G__7802__7816 invoke "protocols.clj" 19]
[clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
[clojure.core.protocols$fn__7835 invokeStatic "protocols.clj" 75]
[clojure.core.protocols$fn__7835 invoke "protocols.clj" 75]
[clojure.core.protocols$fn__7781$G__7776__7794 invoke "protocols.clj" 13]
[clojure.core$reduce invokeStatic "core.clj" 6748]
[clojure.core$into invokeStatic "core.clj" 6815]
[clojure.core$into invoke "core.clj" 6807]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invokeStatic "npm_deps.clj" 168]
[shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invoke "npm_deps.clj" 157]
[shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 204]
[shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 199]
(shadow-cljs.npm-deps/main {} nil) from my program.jar file on the classpath?.jar file on the classpath(doseq [url (-> (Thread/currentThread)
(.getContextClassLoader)
(.getResources "deps.cljs")
(enumeration-seq))]
(try
(slurp url)
(catch Exception e
(prn [:failed url e]))))jar -tvf /home/joel/.m2/repository/ventas-core/ventas-core/0.0.12-SNAPSHOT/ventas-core-0.0.12-SNAPSHOT.jarresources/public is a bad idea as a default 😉lein install, jar -tvf now shows much less files, but I get a different error nowom-next?ident? already refers to: cljs.core/ident? being replaced by: om.util/ident?
fulcrocljs.core/ident? was added not too long ago. so om.next would need to exclude it to get rid of the warningre-frame and I was trying to find alternative[2019-01-25 09:09:15.405 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/graphql-language-service-interface/dist/GraphQLLanguageService.js", :requires [{:line 149, :column 30}]} — the graphiql thing appears correctly but it’s broken in weird ways. Might the above log message have anything to do with it?customRules = void 0;
customRulesModulePath = projectConfig.extensions.customValidationRules;
if (customRulesModulePath) {
/* eslint-disable no-implicit-coercion */
rulesPath = require.resolve('' + customRulesModulePath);
if (rulesPath) {
customRules = require('' + rulesPath)(this._graphQLConfig);
}
/* eslint-enable no-implicit-coercion */
}
rangy object. Is there any way to do this with shadow-cljs? I’ve tried copying the rangy-textrange.js file in my classpath, but I can’t figure out a way to require it from CLJS. Shadow complains it can’t be found.main is rangy-core.js. Which is what I get when I do :require ["rangy" :as rangy] in shadow.rangy-textrange.js, which adds a few methods to the global rangy object.["rangy" :as rangy]
["rangy/lib/rangy-textrange"]["rangy/lib/rangy-textrange" :as rangy]:clj line thing)build namespace — starting my API server in the background, watching the filesystem and compiling SCSS etc, and now I want to be able to send some commands from the hosted cljs build to the shadow/clojure server running the watch. At what point does it make sense for me to use shadow-cljs as a library, instead of launching it via the command line?prepl business I am worried about the fact that prepl will receive way less love than nrepl (check the activity boom in the last months)...so...would nrepl still be supported for the time being by shadow?(ns foo.bar (:require ["jspdf" :as jspdf])) (jspdf.)
jspdf.min.js:formatted:1787 jsPDF PubSub Error t.existsFileInVFS is not a function TypeError: t.existsFileInVFS is not a function(js/jsPDF.).min.js it would fix the issue 😉(set! js/window.existsFileInVFS (fn [] false))jsPDF constructor)"use strict"; for some reason(defn load-global-config ([] (load-file “~/.b42/init.cljs”)) ([config-file] (load-file config-file)))I am getting an error
goog.nodeGlobalRequire is not a function. Also it seems the foreign-lib is also not supported. Could there be a possible way to to this in an electron app?.cljs at runtime unless you are using self-hosted CLJSload-file I assume you mean cljs.core/load-file which is only for self-hosted CLJS and not usable otherwise:node-script
.asar and stuff------ WARNING #1 -------------------------------------------------------------- File: loom/alg_generic.cljc:494:19 -------------------------------------------------------------------------------- 491 | offset (mod idx bits-per-long) 492 | mask (bit-set 0 offset) 493 | value (aget new-bitmap chunk) 494 | new-value (bit-or value ^Long mask)] -------------------------^------------------------------------------------------ cljs.core/bit-or, all arguments must be numbers, got [any Long] instead -------------------------------------------------------------------------------- 495 | (aset new-bitmap chunk new-value) 496 | new-bitmap)) 497 | 498 | (defn bm-get --------------------------------------------------------------------------------
:invalid-arithmetic warning in general I mean. not that particular source.<...>, all arguments must be numbers, ....check is giving me a warning that I'm not sure how to address:
helpers.cljs: 101: if (isa? (type p) clojure.lang.MapEntry)
------ WARNING #56 ------------------------------------------------------------- File: .........../helpers.cljs:101:24 Property lang never defined on clojure
cljs.core/MapEntry. clojure.lang.MapEntry does not exist in CLJS(map-entry? p)[:img {:src ...}] tag and have the clj code write directly to the source location.. is that a completely wrong way of going about things?[:iframe {:src ...}] would do the same as the :img above{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2e5d464f4a4159034d42445d6e1c0019001f16"}, :content ("[email protected]")}. One thing I tried to tweak is how warnings are handled in the console. So if you have lots of warnings in libraries you don't control they should be less annoying now.------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/wilker.lucio/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/spec/gen/alpha.cljs:35:3 -------------------------------------------------------------------------------- 32 | (apply @quick-check-ref args)) 33 | 34 | (def ^:private for-all*-ref 35 | (dynaload 'clojure.test.check.properties/for-all*)) ---------^----------------------------------------------------------------- StringIndexOutOfBoundsException: String index out of range: -1 java.lang.String.substring (String.java:1931) clojure.core/subs (core.clj:4986) clojure.core/subs (core.clj:4981)
2.7.17 works fine, 2.7.18 doesn't compile2.7.19. thanks for the report.------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: common_core/schema.cljc:121:32 Use of undeclared Var common-core.schema/clojure --------------------------------------------------------------------------------and a lot of those now ^^^ 😛
clojure.lang.... symbol------ WARNING #5 - :undeclared-var -------------------------------------------- Resource: bide/core.cljs:176:36 Use of undeclared Var bide.core/EventType --------------------------------------------------------------------------------
clojure.lang.MapEntry which I wanted to fix------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: cljs_time/internal/parse.cljs:139:27 Use of undeclared Var cljs-time.internal.parse/Interval -------------------------------------------------------------------------------- ------ WARNING #2 - :undeclared-var -------------------------------------------- Resource: cljs_time/internal/parse.cljs:340:31 Use of undeclared Var cljs-time.internal.parse/Interval -------------------------------------------------------------------------------- ------ WARNING #3 - :undeclared-var -------------------------------------------- Resource: cljs_time/coerce.cljs:29:18 Use of undeclared Var cljs-time.coerce/UtcDateTime -------------------------------------------------------------------------------- ------ WARNING #4 - :undeclared-var -------------------------------------------- Resource: common_core/schema.cljc:121:32 Use of undeclared Var common-core.schema/clojure -------------------------------------------------------------------------------- ------ WARNING #5 - :undeclared-var -------------------------------------------- Resource: common_core/schema.cljc:122:32 Use of undeclared Var common-core.schema/clojure -------------------------------------------------------------------------------- ------ WARNING #6 - :undeclared-var -------------------------------------------- Resource: pushy/core.cljs:88:39 Use of undeclared Var pushy.core/EventType --------------------------------------------------------------------------------
ReferenceError: EventType is not definedcljs-time warningscommon-core.schema/clojure. Those are probably some invalid clojure classes like clojure.lang.MapEntry was so the warnings are probably legit2.7.20cljs.spec.alpha.gen should be fixedclojure.lang.IPersistentVector
clojure.lang.IPersistentSetcljs.core/PersistentVector and Set in CLJSclojure.lang.MapEntry caused runtime errors{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7d0e151c19120a501e11170e3d4f534a534f4c"}, :content ("[email protected]")}. if you were getting "illegal reflective access" warnings on startup please give it a try and let me know if they are gone (they should be)$ shadow-cljs clj-repl shadow-cljs - config: /mnt/c/Users/thheller/code/clojure-cli/shadow-cljs.edn cli version: 2.7.20 node: v10.13.0 shadow-cljs - server version: 2.7.20 running at shadow-cljs - nREPL server started on port 54298 shadow-cljs - REPL - see (help) To quit, type: :repl/quit [1:0]~shadow.user=>
:npm-module targets?
This the output I get with after clearing the cache and node_modules:
...
[:npm] Build completed. (163 files, 104 compiled, 0 warnings, 35.70s)
shadow-cljs - config: /home/jenkins/jakarta/shadow-cljs.edn cli version: 2.7.22 node: v9.11.2
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
clojure.core/ex-info (core.clj:4739)
...
Caused by:
NoSuchFileException: .shadow-cljs/release-snapshots/npm/latest/goog.debug.error.js.map
sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:102)
sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:107)
sun.nio.fs.UnixFileSystemProvider.newByteChannel (UnixFileSystemProvider.java:214)
java.nio.file.Files.newByteChannel (Files.java:361)
java.nio.file.Files.newByteChannel (Files.java:407)
java.nio.file.Files.readAllBytes (Files.java:3152)
shadow.build.closure.SourceMapReport.getByteMap (SourceMapReport.java:57)
shadow.cljs.build-report/extract-report-data/fn--991/fn--993 (build_report.clj:126)
....
.shadow-cljs/release-snapshots/npm/latest/goog.debug.error.js is empty(when ^boolean js/goog.DEBUG (s/fdef ...)))#shadow/env with an unset var on release builds?
$> npx shadow-cljs release npm ... -> Closure - Optimizing ... Closure compilation failed with 1 errors --- goog/base.js:3 Invalid CLOSURE_DEFINES definitionThe
compile task works without issue, and setting the var to nothing or the empty string also works (e.g. $> THE_VAR= npx shadow-cljs release npm)
The config contains :closure-defines {the.ns/THE_VAR #shadow/env "THE_VAR"}
and the.nscontains a (goog-define THE_VAR)THE_VAR in development use the :dev map:dev {:closure-defines {the.ns/THE_VAR ....}}:release {:closure-defines {the.ns/THE_VAR ""}}2.7.23clojure.test.check.clojure-test/defspec work with shadow-cljs’s built-in test runner?defspec works now 😁requires outside of nss supported in shadow (or cljs, for that matter)
This (admittedly old) blog indicates that it would be possible https://anmonteiro.com/2016/10/clojurescript-require-outside-ns/.
When trying it on a cljc file, it fails with:
CompilerException: java.lang.RuntimeException: Feature should be a keyword: (require (quote [clojure.spec.alpha])), compiling:(.../spec.cljc:12:35)regardless of it being wrapped in a
#?:clj, #?:cljsor nothingns in the first place(shadow/repl :app)(shadow/nrepl-select :build-id)?(shadow.cljs.devtools.api/repl :app) in case the alias isn't setup correctlyrepl automatically calls nrepl-select when in nrepl context:node-library target to be able to build a JS version for use on the NodeJS server, and pull the library into the CLJS browser app as a normal CLJS dependency. Does that sound sensible?
The next question I have after having trying the above is: when I’m developing this library, how can I get live reloading / REPL based workflow with a :node-library target?
I’ve tried running the shadow-cljs watcher in one terminal, calling node ./dist/lib.js and then shadow-cljs cljs-repl lib to connect a CLJS repl but live reload doesn’t seem to pick up changes after file save (but I can get changes if I eval the code changes within the REPL).:devtools {:autoload true}:after-load):devtools {:autoload true} and had live reloading working with :node-script (but then this isn’t consumable as a npm dependency). Maybe I should just create a :node-script build for development and a :node-library build for release?functionA that calls functionB, update functionB and save the file, would you expect that the live reload would run the new functionB?var x = require("your-cljs.js"); x.foo();foo can't be updatedfoo calls internally can be updated normally(defn exported-fn [] "returning 1")and was just updating the string to see live reloading work. So your explanation above makes perfect sense. Easy for me to just have the exported function call others in the CLJS namespace and work from there.
shadow-cljs: call shadow.test.browser/start when the code reloads, but this doesn't seem to actually update the UI with new tests:closure-defines {cljs-test-display.core/notifications false}watch(server/start!) I get:
Execution error (NoSuchFieldError) at shadow.build.closure.JsInspector/getFileInfo (JsInspector.java:161). PARSE_RESULTS
[com.google.javascript/closure-compiler-unshaded "v20181125"] or latershadow-cljs cljs-repl frontend, but Calva says Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?
Shadow works in lein mode, so I added [cider/cider-nrepl "0.20.0"] into project.clj, then I added it into shadow-cljs.edn, no effect.
Can someone help me?{:lein true
:builds {:frontend ...}}
3. add [cider/cider-nrepl "0.20.0"] to lein (not shadow-cljs) deps
4. start shadow lein run -m shadow.cljs.devtools.cli watch frontend5. trying start repl
lein run -m shadow.cljs.devtools.cli cljs-repl frontend6. trying to connect via Calva 7. getting
This looks like a shadow-cljs coding session. Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?
shadow-cljs watch frontend and shadow-cljs cljs-repl frontendlein internally when appropriatelein to run the watch that is correctwatch) then it won't run lein and instead connect to the server processcljs-repl will not run through lein but instead connect to the previous watchwatch to start fully before running cljs-repl?lein run -m shadow.cljs.devtools.cli cljs-repl frontend this will NEVER work when launched through leincljs-repl frontend fully works from cli$ npm run shadow-cljs watch frontend ... # another terminal $ npm run shadow-cljs cljs-repl frontend >
This looks like a shadow-cljs coding session. Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?
{:lein true
:builds {:frontend
{:output-dir "resources/public/js"
:target :browser
:modules {:main {:entries [waifoo.client]}}
:asset-path "js"
:devtools {:watch-dir "resources/public/css"}}}}
css folder didn't has changes:watch-dir is incorrect and should be resources/public:asset-path should also be /js(defonce x (atom 0)) (println "RELOADING" (swap! x inc))
touch src/your/file.cljs triggers 2 reloads?No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react" in file file:/Users/thomas/.m2/repository/thheller/shadow-cljsjs/0.0.16/shadow-cljsjs-0.0.16.jar!/cljsjs/react.cljsI'm guessing this is because I don't have a node_modules in my base directory? I DO have one in my subdirectory and am using
:js-options {:node-modules-dir "client"} to tell shadow-cljs where it is.
I'm wondering what the right way is to use shadow-cljsjs. Do I need to add exclusions for deps that use cljsjs, like this?
{:deps {thheller/shadow-cljsjs {:mvn/version "0.0.16"}
fulcrologic/fulcro {:mvn/version "2.7.2"
:exclusions [cljsjs/react
cljsjs/react-dom
cljsjs/react-dom-server
:npm-deps with the default compiler optionsdoo supports coverage supports via istanbul and karma-coverage. did anybody manage to set this up with the :karma target?karma.conf.js?lein clean or the like):npm-deps feature in CLJS:npm-deps is IMHO a dead end and will never work reliably enough (given the current state of wild-west JS on npm):npm-deps and use webpack instead these days:advanced optimizations for npm dependencies but instead gained almost full compatibilitytouch src/main/some/file.cljs.graphql file you have another tool trigger the touch.graphql as uncacheable that would be enough):target :npm-module. I explained my reasoning here https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.htmllein?cljs.analyzer and stuff(diract.agent/boot! {:eval-fn ... :env compiler-env-atom}) seems to me like it would be:external-config at some point explained in the docs? I recall reading about it at some point, and it saved my bacon yesterday, but I can’t find a good explanation anywhere:external-config and the macro approaches break the assumptions made by the caching stuff so it very likely breaks caching in some way(defn release
"Build :browser release, with advanced compilation"
([] (release "local"))
([release-flag]
(-> (shadow-config/get-build! :browser)
;; note, we add ::release-flag to our build-config, we need this later.
(assoc-in [:compiler-options :external-config ::env] (read-env :release))
(shadow/release* {}))))
watch we need something to happen to on every recompile, no?goog-define-ing thingsaero so you can pull in system environment variables or keep things in the edn directlygoog-define via actual goog-define(defmacro goog-define*
"Like goog-define, but reads `k` from `env/config` at compile time "
[name k default]
`(~'goog-define ~name ~(get config k default)))
goog-define* bit when I want DCE. We also have some clj scripts which rely on the config being available in clojure-land (generating static html from hiccup, some other deploy-related tasks)<script>your.app.init(some-json-config-data);</script>index-dev.html index-staging.html index.html for prodindex.html but generated specifically for the current envapp.env/config var that is exposed to cljs:devtools false in the same config map, which needs to be a compile-time flag to keep stuff out of prod builds:preloads [your.app.dev-stuff]?(when devtools (do-more-stuff))?(cond-> routes env/devtools? (merge {.. dev routes ..}))goog-define* macro which reads from the env map at compile time(def devtools? false) would have the same effect as far as closure is concerned(def devtools? (get-config :devtools false))get-config is a macro and just emits literals you don't need extra goog-define gimmickswatch with a non-dev release-flag?prod release flag if i want my local build to talk to the prod api serversrc/app/env.cljs before starting the compile(when (:devtools static-config) ...)(ns app.env)
(def devtools? false)
(def config {:url "foo.bar"}) is easy enoughedn file where you can always look things up. and changes are picked up during recompile:cache-blockers supposed to work on first compile?:cache-blockers complete blocks all cache for the namespaces mentioned. yes it works on the first compilenpm run lets you add command line parameters after a --, which are then passed to the underlying script, eg. npm run watch -- staging. that’s actually what we have set up. i could imagine something similar for shadow, allowing parameters at the end to be passed in as command-line-args or something, but I haven’t thought a lot about that.:cache-blockers in :compile-prepare stage, and on the first compile it wasn’t recompiling everything that I added to it*command-line-args* from build hooks:compile-prepare:compile-prepare is where I am setting :external-configapp.env/configwatch logic will not trigger recompiles if you modify the config there(ns ^:dev/always app.env) to never cache it(-> build-state
(assoc ::prev-config public-config)
(update-in [:shadow.build/config :cache-blockers] (if env-changed?
#(conj % 'web3.env)
#(remove #{'web3.env} %))))
(let [output (get-in state [:output resource-id])]
;; skip compilation if output is already present from previous compile
;; always recompile files with warnings
(if (and output (not (seq (:warnings output))))
output
(maybe-compile-cljs state src)
))
seq-compile-cljs-sources uses that code, par-compile-cljs-sources calls maybe-compile-cljs directly without that output check but is not used for partial incremental compiles:external-config is fine, and we can live with recompiling everything when config changes, as that is not so often. I guess in a hyper-optimised world we would figure out how to add a particular namespace to the list of things-to-recompile from within a :compile-prepare hook.(update state :output dissoc resource-id)?shadow-cljs release app --config-hook "(your.ns/some-fn 1 2 3)" help?(your.ns/some-fn config-from-file 1 2 3) would be called whenever the config is loaded?:output it will recompile(shadow.build.data/get-source-id-by-provide state 'app.env) will you you the proper resource-id(shadow.build.data/remove-source-by-id state resource-id) instead of just removing the outputapp.env also recompile?--config-hook thing, i don’t fully follow how that fits inapp.env)app.env/config on the clojure side?:build-hooks [(app.build/load-env)
(app.build/compile-static-assets-hook)
(app.sentry/push-source-maps!)]
(defn release
"Build :browser release, with advanced compilation"
([] (release "local"))
([release-flag]
(-> (shadow/get-build-config! :browser)
;; note, we add ::release-flag to our build-config, we need this later.
(assoc ::release-flag release-flag)
(shadow/release* {})
(compile-static-assets)
(send-source-maps-to-sentry)
)))watch? granted I don't know what you do in them but probably the first thing you do is check if they should actually run?(when (= :release (:shadow.build/mode build-state)) ...)npm run watch -- staging and then it delegates to shadow’s clj-runshadow-cljs release browser --config-merge '{:some "data"}' for examplecljs.main lets you specify multiple --compile-opts and merges them togetherwrite-assets!, makes use of the :output-dir and :asset-path in the shadow build config, and in :release mode it appends content hashes to pathsgatsby or somanifest.edn for that https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifestmanifest.edn as well. i ended up writing something more general because we needed the same cache-busting stuff for generated html and css alsoindex.html et al very aggressivelyshadow-cljs is used to drive it all(System/getProperty "java.version") => "11.0.1"There is 2 ways to get
"11" in my system
{"java.specification.version" "11"
"java.vm.specification.version" "11"}
https://github.com/thheller/shadow-cljs/blob/1485cbefc62d781ca5bc1ddf3464833c75771f2e/src/main/shadow/cljs/devtools/server/npm_deps.clj#L12shadow.cljs.util/is-jar? does a simple endsWith check to see if the string is a jar.jar ¯\(ツ)/¯FileNotFoundException: /Users/anmonteiro/Documents/github/ladder/buck-out/gen/src/ladder/__common_lib__/common.jar (Is a directory)
java.util.zip.ZipFile.open (ZipFile.java:-2)
java.util.zip.ZipFile.<init> (ZipFile.java:219)
java.util.zip.ZipFile.<init> (ZipFile.java:149)
java.util.jar.JarFile.<init> (JarFile.java:166)
java.util.jar.JarFile.<init> (JarFile.java:130)
shadow.build.classpath/find-jar-resources* (classpath.clj:455)
shadow.build.classpath/find-jar-resources* (classpath.clj:452)
shadow.build.classpath/find-jar-resources (classpath.clj:579)
shadow.build.classpath/find-jar-resources (classpath.clj:553)
shadow.build.classpath/find-resources (classpath.clj:627)
shadow.build.classpath/find-resources (classpath.clj:625)
shadow.build.classpath/index-path* (classpath.clj:854)
shadow.build.classpath/index-path* (classpath.clj:851)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6827)
clojure.core/reduce (core.clj:6810)
shadow.build.classpath/index-classpath/fn--1940/fn--1941 (classpath.clj:973)
clojure.lang.Atom.swap (Atom.java:37)
clojure.core/swap! (core.clj:2352)
clojure.core/swap! (core.clj:2345)
shadow.build.classpath/index-classpath/fn--1940 (classpath.clj:973)
shadow.build.classpath/index-classpath (classpath.clj:972)
shadow.build.classpath/index-classpath (classpath.clj:967)
shadow.build.classpath/index-classpath (classpath.clj:969)
shadow.build.classpath/index-classpath (classpath.clj:967)
shadow.cljs.devtools.server.common/fn--6874 (common.clj:89)
shadow.cljs.devtools.server.common/fn--6874 (common.clj:87)
is-jar? with:
(defn is-jar? [^String name]
(let [f (java.io.File. name)]
(and
(not (.isDirectory f))
(.endsWith (str/lower-case name) ".jar"))))
.jar are actually jars not directoriesname is just "common.jar" in this caseshadow-cljs.edn to an npm dependency’s CSS such that it works in dev and in a release artifact?node-sass CLIbuck only do this for release builds? some dev features treat files in jars a bit differently and won't warn as aggressively for example.jar is never in the dep graph in 2.7.122.7.26 should fix itclasspath entry that is not a directory or jar file.so in the classpath that is neither a jar nor a directory 😛2.7.27 that just silently ignores anything but directories or regular files that end in .jar2.7.6 which reworked how symlinks are handled"slim" classifier and were getting the normal AOTed compiler on every shadow dep resolutionclojure.edn didn’t existclojure.edn didn’t exist so it would skip compilation:dependenciesshadow-cljs.edn :dependenciesbuck. kinda curious to see what it does now 🙂.shadow-cljs/builds directory around between compilescljs.core/resolve when code splitting with shadow?resolve really gives you is the var so if you want to call something from a namespace you otherwise have no access to that is one optionjs/some.ns/foo. calling (some.ns/foo) may cause a compiler warning. but (js/some.ns.foo) is fine since it doesn't try to load analyzer data for the call(.then #(code-split.c/in-c "from-a"))resolve then?resolve since produces too much code for what you really want^::ana/no-resolve 😉(defn test-fn []
(-> (loader/load "c")
(.then #(js/code_split.c.in_c "from-a"))))(loader/load 'code-split.c/in-c (fn [the-val] ...))import(...) support so that may be another solution in the futurewebpack does regarding code-splits):modules stuff would need a reworkwebpack is certainly easier to use in that regardimport(...) and let it split how it likes which is good enough for most casesReact.Suspense metalom.nextshadow.js.js:133 Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).default is not a constructor
at Object.shadow$provide.module$node_modules$recharts$lib$util$Events (Events.js:13)
at shadow.js.jsRequire (shadow.js.js:122)
at Object.shadow$provide.module$node_modules$recharts$lib$chart$generateCategoricalChart (generateCategoricalChart.js:63)
at shadow.js.jsRequire (shadow.js.js:122)
at Object.shadow$provide.module$node_modules$recharts$lib$chart$LineChart (LineChart.js:9)
at shadow.js.jsRequire (shadow.js.js:122)
at Object.shadow$provide.module$node_modules$recharts$lib$index (index.js:376)
at Object.shadow.js.jsRequire (shadow.js.js:122)
at Object.shadow.js.require (shadow.js.js:158)
at app.main.js:4cljs.core et. al. will be provided separately?cljs.core with the CLJS npm lib:asset-path as it is just blindly prepended before the file url. so you could use :release {:asset-path ""} which will end up loading :minimize-require option added in that version?goog.log logger in prod?DEBUG to true..goog.log.ENABLED"events" package is unused and just doesn't emit the code for it:closure-defines {some.goog-define/var #shadow/env "FOO"} in the configFOO env var in place of that var(goog-define THING "default value")goog-define?FOO env vars so yes thats kinda the point 🙂FOO isn’t set it won’t default to "default value"2.7.30 and now no FOO will actually use the default value instead of an empty string.:release {:closure-defines {some.goog-define/var #shadow/env "FOO"}}2.7.29. thanks for the report.Module Entry "ladder.views.api" was moved out of module ":static-pages".
It was moved to ":main" and used by #{:static-pages :main}.
requireshadow.loader is written in JS since I wanted to be able to use it without CLJS. eg. create a tiny initial loader that then loads the restcljs.loader always makes the assumption that cljs.core is in the base which I didn't want to forcestr it?id.toString() and remove : if it starts with thatcljs.core2.7.30. https://shadow-cljs.github.io/docs/UsersGuide.html#config-mergeresolve a symbol) but the result of resolve is coming up nil on and offresolve is a bad idea)resolve is on the Clojure side btw:clj reader conditional:parallel-build falseresolve in a macro to resolve a CLJ var?(defmacro lazy-load
[module-id comp-sym]
(let [comp-var (ana/resolve-var (dissoc &env :locals) comp-sym)
comp-name (with-meta (:name comp-var) {:cljs.analyzer/no-resolve true})]
`(LazyComponent. ~(get-query @(resolve comp-sym))
(fn []
;; shadow loader callback, not important right now
(-> (~(with-meta 'shadow.loader/load {:cljs.analyzer/no-resolve true})
~(name module-id))
(.then (fn []
(resolve# (cljs.core/js-obj "default" ~comp-name)))))))))
~(get-query @(resolve comp-sym))require in the NS declaration (on the Clojure side)resolve? that looks like you are trying to resolve a CLJS var using CLJ resolve?(with-meta 'shadow.loader/load {:cljs.analyzer/no-resolve true}) this also doesn't make sense to me?resolve#?resolve# is a js/Promise.resolve~(get-query @(resolve comp-sym))cljc filesrequires for all these namespace in the clj side(defui Component static om/IQuery (query [this] [:query :here]) ... (lazy-load :foo some.other.ns/foo) correct?(defmacro lazy-load
[module-id comp-sym]
{:pre [(keyword? module-id)
(qualified-symbol? comp-sym)]}
`(LazyComponent. ~(get-query @(resolve comp-sym))
(fn []
;; shadow loader callback, not important right now
(-> (shadow.loader/load ~(name module-id))
(.then (fn []
(cljs.core/js-obj "default" ~(symbol "js" (comp/munge comp-sym)))))))))not important right now:build-options {:cache-level :off}{:cache-root (str temp-dir "/.shadow-cljs")
:builds {:karma {:target :karma
:output-to (str out-dir "/test.js")
:ns-regexp (str "^(" (string/join "|" namespaces) ")$")
:build-options {:cache-level :off}
:js-options {:node-modules-dir node-dir}}}}
shadow-cljs.edn 😉 base-config (edn/read-string (slurp shadow-edn)) in hereFile: /var/lib/buildkite-agent/builds/buildkite-5dc4755b74-2mfgf-1/ladder-life/ladder/buck-out/gen/src/ladder/__views-next_cljs_cljs_classpath__/views-next_cljs_symlink_tree.jar/ladder/views_next.cljc
null
#:clojure.error{:source "ladder/views_next.cljc", :line 438, :column 32, :phase :macroexpansion, :symbol ladder.ui/lazy-load}
ExceptionInfo:
cljs.analyzer/macroexpand-1*/fn--2050 (analyzer.cljc:3792)
cljs.analyzer/macroexpand-1* (analyzer.cljc:3789)
cljs.analyzer/macroexpand-1 (analyzer.cljc:3835)
cljs.analyzer/analyze-seq (analyzer.cljc:3870)
cljs.analyzer/analyze-form (analyzer.cljc:4061)
cljs.analyzer/analyze* (analyzer.cljc:4109)
cljs.analyzer/analyze (analyzer.cljc:4129)
cljs.analyzer/analyze (analyzer.cljc:4114)
Caused by: NullPointerException: clojure.core/deref-future (core.clj:2300) clojure.core/deref (core.clj:2320) clojure.core/deref (core.clj:2306) ladder.ui/lazy-load (ui.cljc:344) ladder.ui/lazy-load (ui.cljc:336)
:compiler-options {:parallel-build false}. forgot that I added support for that not too long agocache-blockers in this case would do anything?:cache-level :jars(lazy-load :foo 'some.other/thing) and some.other/thing isn't loaded on the CLJ side(prn [:resolve (resolve comp-sym)]) in the macroresolve is nil(prn [:loading-that-namespace]) to the namespace the resolve is referencingrequire for the sym to ensurerequiring-resolve might help me hererequiring-resolve, otherwise the build time is infeasiblerequiring-resolve made the build work instantlyA / \ B C
ns forms of all namespaces, account for macros, npm dependencies, resolve all those with all the "browser" rules and stuff.shadow-cljs/builds and you get that for CI as well(defn foo [] 1) in some namespace(defn foo [] 2) all namespaces that require this will be fully recompiledrequiring-resolve in some macro and things get even more crazy 🙂 also depends on demo/test.md. https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: clojure/tools/cli.cljc:126:17 -------------------------------------------------------------------------------- 123 | (recur options (into extra-args (vec (rest args))) nil) 124 | 125 | (and (opt? opt) (nil? spec)) 126 | (throw (Exception. (str "'" opt "' is not a valid argument"))) -----------------------^-------------------------------------------------------- Use of undeclared Var clojure.tools.cli/Exception -------------------------------------------------------------------------------- 127 | 128 | (and (opt? opt) (spec :flag)) 129 | (recur ((spec :assoc-fn) options (spec :name) (flag-for opt)) 130 | extra-args -------------------------------------------------------------------------------- ------ WARNING #2 - :undeclared-var -------------------------------------------- Resource: clojure/tools/cli.cljc:228:25 -------------------------------------------------------------------------------- 225 | (when *assert* 226 | (let [unknown-keys (keys (apply dissoc map spec-keys))] 227 | (when (seq unknown-keys) 228 | (binding [*out* *err*] -------------------------------^------------------------------------------------ Use of undeclared Var clojure.tools.cli/*err* -------------------------------------------------------------------------------- 229 | (println (str "Warning: The following options to parse-opts are unrecognized: " 230 | (s/join ", " unknown-keys))))))) 231 | 232 | (select-keys map spec-keys)) --------------------------------------------------------------------------------
Exception class. I guess someone didn't actually test this much.*err*yarn shadow-cljs watch app:
[:app] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/mnt/c/Users/conan/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/ cljs/core.cljs:999:14 -------------------------------------------------------------------------------- 996 | (if (js/isFinite o) 997 | (js-mod (Math/floor o) 2147483647) 998 | (case o 999 | ##Inf --------------------^----------------------------------------------------------- No reader function for tag Inf -------------------------------------------------------------------------------- 1000 | 2146435072 1001 | ##-Inf 1002 | -1048576 1003 | 2146959360)) --------------------------------------------------------------------------------Any ideas why? I found some discussion of this error that referred to
tools.reader, but it's old and my lein deps :tree says I'm using [org.clojure/tools.reader "1.3.2"].
https://clojurians-log.clojureverse.org/shadow-cljs/2017-10-03cljs.reader/read-string actually uses tools.reader so there isn't any differenceInvariant Violation: Target container is not a DOM element. with shadow?
I do have the script tag after the root node in the body(re/render [admin-panel] (.getElementById js/document "app"))
lol, copypaste from old deps.edn code. should be "root" 😂shadow-cljs clj-repl and ( "cljs/tools/reader.cljs")[1:0]~shadow.user=> ( "cljs/tools/reader.cljs") #object[java.net.URL 0x1d579f90 "jar:file:/mnt/c/Users/conan/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar!/cljs/tools/reader.cljs"]
:lein true and :target :node-library, maybe they affect the classpath? here's my shadow-cljs.edn:
{:lein true
:builds {:app {:target :node-library
:exports {:handler conan.core/handler}
:output-dir "target"
:output-to "target/main.js"}}}
project.clj:
(defproject conan "0.1.0-SNAPSHOT"
:min-lein-version "2.7.0"
:dependencies [[com.cemerick/url "0.1.1"]
[com.taoensso/timbre "4.10.0"]
[io.nervous/kvlt "0.1.4" :exclusions [org.clojure/clojurescript]]
[org.clojure/clojure "1.10.0"]
[org.clojure/core.async "0.4.490"]
[thheller/shadow-cljs "2.7.11"]]
:source-paths ["src/cljs"])
2.7.11 with 439 is correctproject.clj.lein/profiles.cljproject.clj the deps look ok.lein/profiles.clj. didn't think of it thoughnpx shadow-cljs node-repl since I have none of you sourcescljs.core which fails for youlein and move the dependencies to shadow-cljs.edn and still run into this issue let me know:lein true and copying :dependencies to shadow-cljs.ednwatch on the library and copying the bundle over to my app's node_modules folder and restarting the (create-react-app, which wraps webpack) dev server there. It appears to work fine when I run release, but if I watch, I get Error: browser bootstrap used in incorrect target. Any reason for this or way I can get it to work? I'm using es6 modules, which I believe compile down to require calls. I tried the solution here: https://github.com/thheller/shadow-cljs/issues/376 but it's not exactly my situation and it seemed to make things worse.(boolean (:ns &env)) to detect if this macro is being used in CLJS code, but is there a way to detect, in a macro, that this macro is being called in regular browser cljs or nodejs?cljs.core/*target* (will be nodejs) for node targets:npm-module? a dev build generates many files and cannot be loaded by webpack unless you use :npm-moduleoauthjs but this has a dependency on querystring. So in a blank project, npm i querystring and then in an ns form (:require ["querystring" :as qs]) yields:
[:app] Build failure: The required JS dependency "querystring" is not available, it was required by "beta/main.cljs". Searched in:/home/dan/projects/clojure/beta/node_modules You probably need to run: npm install querystringbut
[
{:source-paths ["src"]
:dependencies []
:builds {:app {:output-dir "target/"
:asset-path "."
:target :browser
:modules {:main {:init-fn beta.main/main!}}
:devtools {:after-load beta.main/reload!
:http-root "target"
:http-port 8080}}}}
this is how i'm setting it up. have i missed something?[
node -e 'console.log(require("querystring"))'shadow-cljs installed in your project?querystring is one of those packages that needs a browser polyfill which gets installed when you install shadow-cljs in your projectnpm install shadow-cljs in your project (never rely on the global install){:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c9baa1a8ada6bee4aaa5a3ba89fbe7fee7faf8"}, :content ("[email protected]")} you can set :nrepl false and/or :socket-repl false to disable themnpm i to grab new React versions that were in my package.json and I had to restart the shadow-cljs process to get it to pick up2.7.32shadow/stop-worker and re-running shadow/watch too, was still getting errors due to not being on latest Reactshadow-cljs - nREPL server started on port 9000. There is no corresponding statement for the socket repl. The relevant bits of my shadow-cljs.edn file are :socket-repl {:port 9001}
:nrepl {:port 9000}resources/ which are exposed by my web server and which I include in a page. Is there a way to get the page to live-reload when I change the css? (preserving everything; just updating the css)[:app] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/qr-scanner/qr-scanner.min.js"]]}
ExceptionInfo: failed to convert sources
...
Caused by:
RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Source map's "sources" and "sourcesContent" lengths do not match.
com.google.javascript.jscomp.PrebuildAst.prebuild (PrebuildAst.java:79)
...
//# sourceMappingURL=qr-scanner.min.js.map from the node_modules/qr-scanner/qr-scanner.min.js filenpm installed another qr-reader and required that one, without needing to restart, reload or anything. Can any js build pipeline do that?watch with a config that’s passed in without a shadow-cljs.edn?
I want to do something like this from figwheel
(fig/start {:id "dev"
:options {:main (symbol main)
:nrepl-port 7002
:output-to "target/public/cljs-out/main.js"}
:config {:watch-dirs paths}})
I have a little code visualizer, that updates a page as you make changes, in a ‘target’ project. got it working with figwheel, but need to to get it working with shadow since most of my ui code uses shadow and figwheel doesn’t understand the string requires, etc. I was poking through the devtools api, and it seems like watch can take a map, but i’m not clear on how that ‘maps’ to whats in the normal config file I guess as a workaround I could create a separate build for it in the project that it’s looking at. but I was trying to keep it as self-contained as possiblerm -rf .shadow-cljs workedshadow-cljs.edn is also required currently.node_modules files were not picked up properly by running watch processeswatch before wiping .shadow-cljs?2.7.32 it also shouldn't be possible to get into that state while watch is running$ npx shadow-cljs server shadow-cljs - config: ...\shadow-cljs.edn cli version: 2.7.32 node: v10.15.1 shadow-cljs - socket connect failed, server process dead? shadow-cljs - HTTP server for :app available at shadow-cljs - server version: 2.7.32 running at shadow-cljs - nREPL server started on port 53349
.shadow-cljs/socket-repl.port:socket-repl {:port 12345} in the shadow-cljs.edn.shadow-cljs/socket-repl.port insteadshadow-cljs.edn(shadow.cljs.devtools.api/watch* build-config {})build-config is a map as it would appear in the shadow-cljs.edn with an extra :build-id key{:build-id :your-viewer :target :browser ...}lein deps? I’m running docker, and I want to be able to cache the dependencies, so I don’t have to download each time i shadow-cljs release in my CI pipelineshadow-cljs info will do that (assuming you have :dependencies actually in shadow-cljs.edn)shadow-cljs info still work if I used deps.edn for dependencies?clojure with some opts in that caseclojure -Stree or somethingshadow-cljs release still ends up downloading the dependencies all over again.shadow-cljs itself explicitely in your deps.edn?shadow-cljs clj-eval 1lein and deps.ednReferenceError: $cljs is not defined$CLJS is only used in development builds are you maybe trying to load a development build compiled on one machine on the other? that is never supported and should not be done.shadow-cljs watch <build-id>.
Most of the time it solves by deleting .shadow-cljs folder, target, node_modules, and trying again..shadow-cljs folder and/or the build files?.shadow-cljs so I'm kinda curious what you are doing$cljs is? Is that just because you typed the message by hand maybe? shadow--cljs has zero references for $cljs only $CLJS?lein to develop Chlorine, and now I'm trying some integration tests in the branch full-editor-tools of my repl-tooling repo (https://github.com/mauricioszabo/repl-tooling/)showdown dependency from NPM (never heard of it).electron on my UI, and saw that error on console.log 🙂Latest commit dead100 5 hours agoHEAD is now at dead100 .... was a bit confused for a second 😉shadow-cljs - connection closed!? In the inspector I get `WebSocket network error: The operation couldn’t be completed. (OSStatus error -9807.)
cljs$core$IFn$_invoke$arity$variadic — browser.cljs:25:97`Invalid certificate chain.OSStatus error -9807 since I also have no idea what this is about. it certainly is nothing from shadow-cljs (thats where the websocket connects to)>)defonce instead of def(defonce app-state (r/atom {})){:devtools {:watch-dir "<path>"}} config but it’s not working. Anyone any tips?<link rel="stylesheet" type="text/css" href="css/main.css">
2) Editing the css file at that point will trigger a refresh: shadow-cljs: load CSS css/main.css.
3) The page refreshes and the css changes are reflected in the app. The dom is also modified, the css tag now looks like this: <link rel="stylesheet" type="text/css" href="css/main.css?r=0.8158209164608885">
4) New css file edits no longer trigger refreshes.
5) After manually editing the css tag using Chrome devtools to again look like it did at step 1 refreshing again works a single time.
Could this be a bug? What is the purpose of the ?r=<number? that gets added to the css tag??r=... is used to ensure no cache is used? since it is loading files from the filesystem(go (>! fchan data)) this should absolutely be avoided. just use (async/put! fchan data) if all you care about is putting a value on a chanasync/offer!:devtools {:loader-mode :eval} in your build config if you want to reduce the number of files loaded (still fairly large though){:loader-mode :eval} helps a lot since it reduces the file numbers! 🙏2.7.33.2.7.33goog.nodeGlobalRequire it is because of a bug that needs to be fixedcider-nrepl, I get this when using shadow-cljs watch:
[2019-02-14 09:49:48.486 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
clojure.lang.Compiler.load (Compiler.java:7647)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:463)
clojure.lang.RT.load (RT.java:428)
clojure.core/load/fn--6824 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
clojure.core/load-lib/fn--6765 (core.clj:5948)
clojure.core/load-lib (core.clj:5947)
Caused by:
FileNotFoundException Could not locate nrepl/middleware/caught__init.class, nrepl/middleware/caught.clj or nrepl/middleware/caught.cljc on classpath.
clojure.lang.RT.load (RT.java:466)
clojure.lang.RT.load (RT.java:428)
clojure.core/load/fn--6824 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
clojure.core/load-lib/fn--6765 (core.clj:5948)
clojure.core/load-lib (core.clj:5947)
clojure.core/load-lib (core.clj:5928)
clojure.core/apply (core.clj:667)
clojure.core/load-libs (core.clj:5985)
caught.clj?shadow-cljs watchshadow-cljs compile works just fine, so yes, it's cider-nrepl relatedcompile doesn't start an nrepl server so it doesn't load cider.nreplnodeGlobalRequire is bad and should not be used(load-file "./some/thing.cljs")?.js files as no compilation is done.cljs files2.7.34WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by mranderson048.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval8306$fn__8307 to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of mranderson048.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval8306$fn__8307 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
2.7.35 with new logic for the built-in development HTTP servers. Old configs should still work so no changes required (unless you want to). Please let me know if something breaks in your dev setups. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http:dev-http {8701 "public"} - localhost:8701/ loads my index.html file from /public correctly, but localhost:8701/intro gives me Not found. Missing index.html.2.7.36.M-x cider-jack-in-clojurescript adds the correct -d nrepl:0.6.0 for you. The jack-in-X commands have gotten very good (in my experience) latelydeps.edn and shadow-cljs docker container folks use?<link rel="preload" ...>mm instance directly if you need(.prefetchModule shadow.loader/mm "foo") should work:advanced compiled or from HTML?(.val ^js snapshot) in the codebase, does that mean “val” will never be renamed anywhere, or only for things that the compiler thinks might have the same type as snapshot?^js hint there does not mean that val will be added to the inferred externslein when they have some other CLJ code (eg. server-side) they need to work with as welllein, tools.deps or shadow-cljs standaloneshadow-cljs.edn for CLJS and lein for CLJ completely separate. that is what I do.lein if you are not familiar with lein?:source-paths ["src"] or so in project.clj and the file located in src/foo/core.cljs (or whatever your source path is)project.clj over shadow-cljs.edn. just more complicated 😉:source-paths and :dependencies are either in shadow-cljs.edn or project.clj{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a6d5cec7c2c9d18bc5caccd5e694889e8896"}, :content ("[email protected]")}. The most significant change in this release is the bump of the Closure Library. CLJS used to update that regularly but stopped about 2 years ago. There may have been breaking changes in the Closure Library so please help testing if you use a lot of goog stuff.cider-nrepl)shadow.cljs.devtools.cljs-specs don't seem to allow destructuring like this: (defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}]).
In particular, it seems to be the combination of :or and destructuring a namespaced keyword that's the problem. The specs allow (defn foo [{:keys [quux] :or {quux :quuz}}]), for instance.
I'm on shadow-cljs v2.8.0.(defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}] this is not valid. (defn foo [{:keys [baz/quux] :or {quux :quuz}}] should be.:or path. Thanks!$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -m cljs.main
ClojureScript 1.10.520
cljs.user=> (defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}] quux)
#'cljs.user/foo
cljs.user=> (foo {})
nil
cljs.user=> (defn foo* [{:keys [baz/quux] :or {quux :quuz}}] quux)
#'cljs.user/foo*
cljs.user=> (foo* {})
:quuz
:or {baz/quux ,,,} would work, but on the other hand, I guess you could argue that quux is the name of the variable the value is bound to and therefore makes more sense.2.8.1. still unsure why this wasn't a problem previously but I can't reproduce the problem anymore/home/roman/workspace/burningswell/web/.shadow-cljs/builds/server/dev/out/cljs-runtime/goog.loader.activemodulemanager.jsgoog.loadModule(...)goog.require with one that isn't aware of goog.loadModule stuffvar asserts = goog.require("goog.asserts"); just ends up as nilgoog.require usually doesn't return anythingsrc/shadow/cljs/node_bootstrap.txt and recompilevar SHADOW_REQUIRE = function(name) {
if (goog.isInModuleLoader_()) {
return goog.module.getInternal_(name);
}
return true;
};var SHADOW_REQUIRE = function(name) {
return true;
};goog.require override is required at all anymore. maybe I can just remove that hack entirely.set-loaded!. the tool takes care of that for youshadow.loader regardless of what you require 😉shadow.loader 😉cljs.loader doesn't work with the new closure library at all yetError building classpath. Specified aliases are undeclared: [:shadow-cljs-inject["r""e""b""l""-""1""1"]] when using -A:rebl-11 or -A rebl-11 in recent shadow 2.8.1:shared:modules {:foo {:entries [] :depends-on #{:shared} :uses-foo {:entries [your.page.foo] :depends-on #{:shared :foo} ....}:modules
{:shared
{:entries []}
:foo-shared
{:entries []
:depends-on #{:shared}}
:page-a
{:entries [your.app.page-a]
:depends-on #{:shared}}
:page-b
{:entries [your.app.page-b]
:depends-on #{:shared :foo-shared}}
:page-c
{:entries [your.app.page-c]
:depends-on #{:shared :foo-shared}}
}:shared:foo-shared:entries [] is a shortcut when you don't have any specific namespaces that should be moved there./node_modules/.bin/shadow-cljs -A:rebl-11 clj-run ... is the actual command line:default true to my main module, right?:depends-on:foo-shared {:entries [cljs.core] ...} will warn you since :page-a needs cljs.core2.8.2Document used? by what?ReferenceError: Document is not defined
at /home/roman/workspace/burningswell/web/out/burningswell/server.js:2663:800(prn html) pleasehtml(set! js/Document ...) is kinda questionable and should probably be (set! js/goog.global.Document ...) but I don't see a reason why it shouldn't work now if it did work before(prn html/Document) while you are at it(set! js/goog.global.Document html/Document)shadow$loader into the browser console it prints {}shadow$loader object at the very beginning.var shadow$loader = {}var shadow$loader = {"uris": { ... }}; is emitted by shadow-cljs to make the module info available. but the 2nd var shadow$loader = {} comes from the goog.provide("shadow.loader"); call in loader.js, which unfortunatly resets this information againshadow$loader object in the beginning?cljs.analyzer namespace specially a ànalyze-file` defn in it, but while building it seems to be giving a error!Use of undeclared Var cljs.analyzer/analyze-file `analyze-file is only available in CLJ(ns reagent-movable.core
(:require [reagent.core :as r]
["react-movable" :refer [List]]))
(defn reload! []
(.. js/window -location reload))
(defonce state (r/atom (vec (map #(str "Item " %) (range 1 11)))))
(defn movable []
(let [items @state]
[:ul
(for [[idx item] (map-indexed vector items)]
^{:key idx} [:li item])]))
(defn app []
[:div
[:h1 "Movable list below"]
[movable]])
(defn ^:export ^:dev/after-load start []
(println "Mounting component...")
(r/render [app] (.getElementById js/document "app")))
(defn start
{:export true
:dev/after-load true}
[]
(println "Mounting component...")
(r/render [app] (.getElementById js/document "app")))(defn
^{:export true
:dev/after-load true}
start
[]
(println "Mounting component...")
(r/render [app] (.getElementById js/document "app")))
^:export ^:dev/after-load syntax btw. 🙂 if anyone wants to save a few keystrokes in the future.shadow-cljs as the first instinct 😛watch maybe just got into a weird situation and either stopped recompiled completely(prn (.-moduleInfoMap (loader/getModuleManager))) I get an empty map.shadow$loader should only be assigned once? do you see it reassigned again in the code somewhere?(loader/load "my-module" callback)(-> (loader/load "my-module") (.then callback))?execOnLoad maybe was changed in the new closure lib (lots changed there)var shadow$loader = {"uris":{"demo":["/js/demo.js"],"extra":["/js/extra.js"]},"infos":{"demo":[],"extra":["demo"]}};shadow$loader assignment is coming from;var $shadow$loader$ml$$ = new $goog$module$ModuleLoader$$; $shadow$loader$ml$$.$sourceUrlInjection_$ = !0; var $shadow$loader$mm$$; !$module$contents$goog$loader$activeModuleManager_moduleManager$$ && $module$contents$goog$loader$activeModuleManager_getDefault$$ && ($module$contents$goog$loader$activeModuleManager_moduleManager$$ = $module$contents$goog$loader$activeModuleManager_getDefault$$()); $shadow$loader$mm$$ = $module$contents$goog$loader$activeModuleManager_moduleManager$$; $shadow$loader$mm$$.$loader_$ = $shadow$loader$ml$$;
var shadow$loader = {}$shadow$loader:module-loader is missing from the configshadow-cljsvar $goog$module$ModuleLoader$EventType$EVALUATE_CODE$$ = new $goog$events$EventId$$("evaluateCode$0"), $goog$module$ModuleLoader$EventType$REQUEST_SUCCESS$$ = new $goog$events$EventId$$("requestSuccess$1"), $goog$module$ModuleLoader$EventType$REQUEST_ERROR$$ = new $goog$events$EventId$$("requestError$2");
function $goog$module$ModuleLoader$EvaluateCodeEvent$$() {
$goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$EVALUATE_CODE$$);
}
$goog$inherits$$($goog$module$ModuleLoader$EvaluateCodeEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$RequestSuccessEvent$$() {
$goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$REQUEST_SUCCESS$$);
}
$goog$inherits$$($goog$module$ModuleLoader$RequestSuccessEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$RequestErrorEvent$$($moduleIds$jscomp$9$$, $opt_error$jscomp$4$$) {
$goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$REQUEST_ERROR$$);
this.error = $opt_error$jscomp$4$$ || null;
}
$goog$inherits$$($goog$module$ModuleLoader$RequestErrorEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$LoadStatus$$() {
this.$responseTexts$ = this.$requestUris$ = null;
this.$loadRequested$ = !1;
this.$errorFn$ = this.$successFn$ = null;
}
;var $shadow$loader$ml$$ = new $goog$module$ModuleLoader$$;
$shadow$loader$ml$$.$sourceUrlInjection_$ = !0;
var $shadow$loader$mm$$;
!$module$contents$goog$loader$activeModuleManager_moduleManager$$ && $module$contents$goog$loader$activeModuleManager_getDefault$$ && ($module$contents$goog$loader$activeModuleManager_moduleManager$$ = $module$contents$goog$loader$activeModuleManager_getDefault$$());
$shadow$loader$mm$$ = $module$contents$goog$loader$activeModuleManager_moduleManager$$;
$shadow$loader$mm$$.$loader_$ = $shadow$loader$ml$$;
$goog$global$$.shadow$loader && function() {
$shadow$loader$mm$$.$setAllModuleInfo$($goog$global$$.shadow$loader.infos);
var $uris$jscomp$6$$ = $goog$global$$.shadow$loader.uris;
$shadow$loader$mm$$.$setModuleUris$ ? $shadow$loader$mm$$.$setModuleUris$($uris$jscomp$6$$) : ($goog$object$getKeys$$($uris$jscomp$6$$).forEach(function($key$jscomp$115$$) {
var $trusted_uris$$ = [];
$uris$jscomp$6$$[$key$jscomp$115$$].forEach(function($uris$jscomp$6$$) {
var $key$jscomp$115$$ = new $goog$html$TrustedResourceUrl$$;
$key$jscomp$115$$.$privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_$ = $uris$jscomp$6$$;
$trusted_uris$$.push($key$jscomp$115$$);
});
$uris$jscomp$6$$[$key$jscomp$115$$] = $trusted_uris$$;
}), $shadow$loader$mm$$.$setModuleTrustedUris$($uris$jscomp$6$$));
}();var shadow$loader = ... assignment at the very top of the file?var shadow$provide = {};
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
}
var shadow$loader = {"uris":{"demo":["/js/demo.js"],"extra":["/js/extra.js"]},"infos":{"demo":[],"extra":["demo"]}};shadow$loader into the actual runtime data is coming way latershadow$loader?shadow$loader = that should only find ONE occurence:module-loader true in your build config?:module-loader true from my config it breaks like yours:module-loader true in your config in the correct place:module-loader true :modules {...}~/.b42 into the classpath in shadow-cljs.edn :source-paths but i think it doesnt resolve ~as home directory.[:did-not-find <name-of-ns>] errors for namespaces that do exist. What does this error indicate?(in-ns 'foo.bar) without having done (require 'foo.bar) firstReferenceError: module$node_modules$aws_appsync$lib$index is not defined.js file in the cljsjs ns and try to require it, shadow can't find it, but moving to a different folder cljsjs-mine for example makes it work, seems like its doing special threatment for cljsjs, is that expected?cljsjs which would include all the foreign libsnpm install where i end up running node, ideally i only send a single self-contained file, much like an uberjar/workdir/.shadow-cljs/builds/{{project}}/dev/out/cljs-runtime/?release build. note the dev in the path.'/workdir/.shadow-cljs/builds/image-gen/dev/out/cljs-runtime/goog.debug.error.js'shadow-cljs release the-build and look at the output#!/usr/bin/env node
(function(){
var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/script/dev/out/cljs-runtime';injector.cljs that imports figwheel which I don't use and don't have in the classpath. I think shadow-cljs tries to compile every single cljs file on the classpath, and it fails on this one while building the :npm build.
Is this really an issue (I haven't gotten the project to work yet, so can't check)? If so, what would be the correct way of fixing it? If not, can I remove the :npm build from the shadow-cljs configuration data to remove the error message?
The issue with the second one is that it wants me to add all publicly available web resources to the classpath, including the ones that are generated in target. There are some JS files there as well and because of that, shadow-cljs spams a huge number of warnings about "provide conflict", like provide conflict for #{pathetic.core} provided by pathetic/core.cljs and {"/cljs-runtime/cljs-runtime.pathetic.core.js" #{pathetic.core}}.
I think it's possible to fix it by not adding target to the classpath and altering request handlers so that they look there. But to be honest, I have no idea whether that would work with the release uberjar.
Another potential way to fix it would be to still have target in the classpath for the server and not have it for shadow-cljs. The only issue here is that I have to write some code to create the correct set of aliases for :deps in the shadow-cljs configuration data, but I think it could be done.
But is there another way to solve this that's perhaps more preferable?injector.cljs must be required from somewhere.compile-strin bootstrapped clojurescript instead of eval-strand it returns a nullfor a string like
"(.log js/console \"HI\")"(ns demo.bootstrap-script
(:require
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.node :as boot]))
(defn print-result [{:keys [error value] :as result}]
(prn [:result result]))
(def code "(.log js/console \"HI\")")
(defonce compile-state-ref (env/default-compiler-env))
(defn compile-it []
(cljs/compile-str
compile-state-ref
code
"[test]"
{:eval cljs/js-eval
:load (partial boot/load compile-state-ref)}
print-result))
(defn main [& args]
(boot/init compile-state-ref {} compile-it))
[:result {:value "console.log(\"HI\");\n"}]kick.alpha to use figwheel. And there are no messages in the logs mentioning that if was used. Is there any way to find out what exactly has made shadow-cljs compile a particular file?shadow-cljs clj-repl then (shadow/find-resources-using-ns 'that.thing.inector)edge stuff modifies the classpath or so it may not find whatever is using it#{}.ns and nothing else#{}.:npm build that's injected automatically. And I don't see this build in the UI. Maybe I can try just copying it so it becomes an explicit build.:main build, there's no injector in the list of namespaces.:npm build{:npm
{:target :npm-module
:entries [your.main.ns]
:output-dir "node_modules/shadow-cljs"}}load-cljs-edn.:entries and their deps(reset) in the REPL. It can also help in situations where you don't want to restart everything, e.g. you need to reload some components without dropping all active connections.
But I just started using it and I've never used anything like it before, so I can't really tell you anything really useful about it.shadow-cljs.edn within the main code to make the server know about all of the resources.
Here, it's launched using the single source of truth, config.edn. It contains everything you want it to contain, and since it uses aero, you can avoid duplication entirely.
I need to restart shadow-cljs if I e.g. change a path. In some cases I had to restart it when I added something - don't really recall the details but I think it had to do something with a macros and a new namespace.
But I can make it so that shadow-cljs is not restarted if I don't want it to be restarted. And since it's all in the same JVM that's still running, it doesn't take that much time anyway.shadow-cljs.edn and hardcoded and not optional (currently)shadow-cljs.edn with the builds define like normal:kick/shadow-cljs
{:build-to-start [:foo :bar]}(shadow.cljs.devtools.server/start! (dissoc config :builds)) and (shadow.cljs.devtools.api/watch (assoc build :build-id build-id)) while feeding it the config that was preprocessed the same way you do it.shadow-cljs.edn again brings that problem of having either to copy some values or to parse shadow-cljs.edn. I'll see how it works out with the common config - maybe that's "some degree" is well within my needs.
To be honest, I have never made a CLJ app release, so I'm yet to find that out.:output-dir needs to be specified for both shadow-cljs and for the server to serve the generated files.:asset-path, I think.:output-dir? I haven't changed mine in 4 years 😛main/deps.edn is the primary source for depsshadow-cljs.edn right next to that main/deps.edn. make it use :deps {:aliases [:dev]}config.edn thing I don't understand how you build a release build then?edge repo they have bin/onejar:
#!/bin/sh
clojure -Sdeps '{:deps {pack/pack.alpha {:git/url "" :sha "0878b52b7718e4b348a500dce0b3edc5b555a4f1"}}}' -m mach.pack.alpha.one-jar "
And in the documentation it says to release the app with:
$ ../bin/onejar -A:prod --args '-m edge.main' project.jar
:advanced?edge architecture commits several sins in my viewlib.ig.yada/deps.edn
3: integrant {:mvn/version "0.6.3"}
phonebook-api/deps.edn
6: integrant/integrant {:mvn/version "0.7.0"}
edge.asciidoctor/deps.edn
4: integrant/integrant {:mvn/version "0.8.0-alpha2"}oneshot! thing(:require ["react" :as r]) in your code but don't use itreact would still be included in the build2.8.5TypeError: b.modal.modal is not a function.modal.modal?b should be a React component instance, modal a refjs/$modal.modal the Bootstrap modal functionthis.jqueryref.modal()(:require ["bootstrap"]2.8.62.8.6. the previous releases were all bad due to a bad :language-out defaultjs/localStorage at the top level and throwing an exception, but we weren't getting any kind of indication that was happening. just the promise returned by shadow.loader never resolved(-> (loader/load "extra")
(.then fn-to-call-on-load fn-to-call-on-error))console IIRC(.setSourceUrlInjection loader false)
(.setDebugMode loader true)
(set! (.-usingSourceUrlInjection_ loader) (fn [] false))
google.loader.moduleLoader.prototype.usingSourceUrlInjection_ function to always return falsescript tags to the DOMeval, not xhr var trustReason = goog.string.Const.from("generated by compiler"); ?setModuleUris not there anymore?setModuleTrustedUris now:asset-path takes care of that no?(->> (js/Object.keys old-uris)
(run! (fn [k]
(let [links (->> (gobj/get old-uris k)
(map (fn [path]
(build/static-url path)))
into-array)]
(gobj/set uris k links)))))
(gobj/set js/goog.global.shadow$modules "uris" uris)
(js/shadow.loader.mm.setModuleUris
(gobj/get goog.global.shadow$modules "uris"))
:module-loader :no-inject so it doesnt inject the shadow$modules variable:module-loader true 😛module-loader.edn file (or .json)<script>var shadow$modules = <the-json>;</script>shadow$modules var into the code (was shadow$loader previously, renamed because of a weird renaming bug)modal.modal thingminimize-require default:js-options {:minimize-require false} to disableminimize-requires is disabled in dev, and enabled in prod?--npm flag actually used? I can't find where it's handled.kick only supports figwheel. And both release build and debug watch are ran with explicitly specified :source-paths. The reason is that the output dir inside target is added to the classpath - I think just to make the server aware of the resources there during the runtime.
But when you specify {:deps true}, shadow-cljs ignores :source-paths.
I can fix it in my project by explicitly specifying a filtered list of aliases for :deps (the directories inside target are added to the classpath by dedicated aliases). But would be interesting to know if there's a better way.{:deps true} is set, yes.:source-paths once the JVM is running:source-paths in figwheel are used as inputs to the CLJS compilerserver/start! and api/watch, I'm reusing the classpath, and none of :deps, :lein, :source-paths (and probably other keys) are in effect.shadow-cljs is startedtarget to the classpath at all. Hence, I must have an additional static files handler that looks specifically under target.target? why do you need it on the classpath?edge project has the server set in such a way so that the one and only static files handlers looks for files only in the public directory inside any of the classpath paths. resources is on the classpath, so resources/public is used for some regular static files. target/dev or target/prod is also on the classpath, so target/{dev,prod}/public is used to serve some generated static files. At least, that's my understanding.-A:dev:build:dev/build where :dev/build is just {:extra-paths ["target/dev"]}.:minimize-requires false still makes it breakshadow$loader to shadow$modules so with your hack active that will break depending on which one you rewrite:language-in :ecmascript6?:language-out :ecmascript6 or higher as certain optmizations don't yet work with es6+:language-in es6+ since closure library now contains es6 code (eg the new module loader stuff):virtual?->> got me:output without compiling:release mode at all anyways:release doesn't call convert-goog only :dev doesrelease build without buck?(shadow/release* build-config {:verbose true})loader -> modules one?shadow$loader?.modal either2.8.2 is working and wasn't just a fluke?"jquery" and "bootstrap"? maybe I can reproduce something on my endb was in b.modal.modal?jquery and bootstrap(ns cljsjs.ajquery (:require ["jquery" :as jquery])) (js/goog.exportSymbol "$" jquery) (js/goog.exportSymbol "jQuery" jquery)
.modal is gone$ is being mangled so some thing?["jquery" :as jq]
["bootstrap"]
))
(js/console.warn "modal" (.-modal (jq "#app")))undefined in release:profile {:cljs... so I get a decent intellij + cursive support. I just moved the dependencies to the project file and added :lein {:profile "+cljs"} in my shadow-cljs.edn. Now i am getting the following exception:`(defproject example-app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "Eclipse Public License" :url ""}
:dependencies [
[org.clojure/clojure "1.10.0"]
;[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.520"]
;; Needed for shadowcljs if run using lein
[thheller/shadow-cljs "2.8.7"]
]
:profiles {:cljs
{:dependencies [[reagent "0.8.1"]
[re-frame "0.10.6"]
[clj-commons/secretary "1.2.4"]
[cljs-ajax "0.8.0"]
[day8.re-frame/re-frame-10x "0.3.6-react16"]
[binaryage/devtools "0.9.10"]
]
;:target-path "target/%s"
:source-paths ["src"]}}
)
lein with-profiles +cljs deps :tree[com.google.javascript/closure-compiler-unshaded "v20190121"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
Invalid configuration
-- Spec failed --------------------
{:output-dir ...,
:compiler-options ...,
:build-hooks ...,
:modules ...,
:module-hash-names ...,
:devtools ...,
:build-id ...,
:asset-path "",
^^
:target ...}
should satisfy
non-empty-string?
By why? Why can't I just write /main.js in my index.html?:asset-path "."(str asset-path "/" filename)string??:output-dir is a directory dedicated to the output of shadow-cljs{:asset-path "."}.".". otherwise I have to special case everything for empty ...shadow-cljs release your-app --pseudo-names to identify what is missing?sandi.main.view.content_STAR_sandi.main.view just after the requires then it works!!sandi.onboarding.view is one of your :entries in the modules?:onboarding {:entries [sandi.onboarding.view]
:depends-on #{:shared}}
and open your build(prn :loaded) just after the content* definition?prn is shown after the errors are reported.(def x sandi.main.view/content*) after the requires then I can see it loads with no errors.sandi.onboarding.view/content is being called before sandi.onboarding.view/content* is loaded.on-load function for that module is called before we try to resolve sandi.onboarding.view/content*.on-load is called before trying to resolve view for that module.on-load?(-> (loader/load (name module-id))
(.then #(on-load! module)
#(on-error module)))
module?on-load! is called a flag is set that allows the view in the module to be resolved.Uncaught TypeError: Cannot read property 'view' of undefined
at sandi$onboarding$view$content (/dist/cljs-runtime/sandi.onboarding.view.js:16)
at Object.G__95768__1 (cljs.core.js:3993)
at Object.G__95768 [as call] (cljs.core.js:4166)
at reagent.impl.component.js:130
at Object.reagent$impl$component$wrap_render [as wrap_render] (reagent.impl.component.js:153)
at Object.reagent$impl$component$do_render [as do_render] (reagent.impl.component.js:201)
at day8.re_frame_10x.js:105
at Object.reagent$ratom$in_context [as in_context] (reagent.ratom.js:61)
at Object.reagent$ratom$deref_capture [as deref_capture] (reagent.ratom.js:70)
at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (reagent.ratom.js:1485)
re-frame-10x in that trace?(def chrome-72-hack sandi.view.main/content*) at the top of each module view namespace, and I think I'm right in saying it'll be DCE in release (not that it matters all that much).(js/console.log sandi.view.main/content*) instead and use it as normal?(.-token js-object) is munged and doesn't work anymore, is my only choice to use aget?(.-token ^js js-object)agetaget, your worst enemyUncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class but when I click on the browser exception bidi.js:276 it point's to HTML file.
Bidi is a indirect dep from fulcro and it's on 2.1.5
I have no idea from where it error come from.goog.i18n.bidi<meta charset="utf-8"> or Content-Type: text/html; charset=utf-8 if you control the server side{:source-paths ["src/cljs"]
:dependencies [[binaryage/devtools "0.9.10"]]
:nrepl {:port 9000}
:builds {:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js/main.js"
:modules {:main {:init-fn exp.core/init!}}
:compiler-options {:infer-externs :auto}
:devtools {:http-root "public"
:http-port 3449
:http-handler shadow.http.push-state/handle
:after-load exp.core/mount-components}}}}:asset-path "/js/main.js" is wrong:asset-path "/js":output-dir as <module-id>.js, so main.js in your case9630 that handles the live reload3449 is just a completely static webserver for serving files3000:web-worker true. But when importing the class into a worker I get
Uncaught ReferenceError: $jscomp is not definedWhich seems to be part of the closure runtime. Importing the class that I extend into the worker does work. I'm not sure how to fix it, maybe I can include something manually/pass flags to closure to make this work. Any ideas?
:modules where one uses :web-worker true?$jscomp is used by the closure lib for its polyfills:target :browser
...
:modules {:shared {:entries []}
:worker-shared {:entries []
:depends-on #{:shared}}
:app {:entries [app.client]
:depends-on #{:web-shared}}
:filter-worker {:entries [app.filter-worker]
:depends-on #{:worker-shared}
:web-worker true}}
I have a .js file that imports a class from the a node_modules lib and extends it. This works when importing that JS file in :app module, but it doesn't work when importing in the :filter-worker.shared.js? it should contain /** @const */ var $jscomp = $jscomp || {}; right at the top?importScripts("shared.js") right at the top? + worker-shared.js?filter-worker.js doesn't contain any importScripts?importScripts is only for release modeweb-worker if you want to try fixing it:goog-base true in my module seems to have fixed it!2.8.10 has somebody started seeing the following?
[:az] Build failure: The required JS dependency "bufferutil" is not available, it was required by "node_modules/ws/lib/BufferUtil.js". Searched in:/home/arichiardi/git/laputa/scrutinize-fn/node_modules You probably need to run: npm install bufferutil See:
You probably need to run: npm install utf-8-validate
:keep-as-require #{"ws"}wstry {
const bufferUtil = require('bufferutil');
const bu = bufferUtil.BufferUtil || bufferUtil;
module.exports = {
mask(source, mask, output, offset, length) {
if (length < 48) _mask(source, mask, output, offset, length);
else bu.mask(source, mask, output, offset, length);
},
unmask(buffer, mask) {
if (buffer.length < 32) _unmask(buffer, mask);
else bu.unmask(buffer, mask);
},
concat
};
} catch (e) /* istanbul ignore next */ {
module.exports = { concat, mask: _mask, unmask: _unmask };
}:keep-as-require #{"ws"}ws in your release build you can safely ignore that:devtools {:enabled false}:release {:js-options {:js-provider :shadow}} would also be best probably:output-feature-set support :no-transpile?:output-feature-set :es-next will basically keep everything as is:no-transpile never worked:es8 will try that next [com.google.javascript/closure-compiler-unshaded "v20190215"]:es8 to keep generators/async/await as is"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
...
function hydrateFrameMembersAsync(args) {
return (agg, val) => __awaiter(this, void 0, void 0, function* () {
const doc = yield agg;
const docWrapper = support.createDocumentWrapper(doc, args.triggerContext || {});
return Object.assign({}, doc, { [val.name]: yield hydrateDocumentMemberAsync(docWrapper, args.eventData, val.definition, args.lookups, args.pointer) });
});
}:es8?--allow_method_call_decomposing GCC option?:es6?bidi.js:276 Uncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class
at new RegExp (<anonymous>)
at bidi.js:276
from goog.i18n.bidi ?hud.cljs:301 reload-failed TypeError: r is not a function
<meta charset="utf-8"> to your HTML<Dropzone onDrop={this.onDrop}>
{({getRootProps, getInputProps, isDragActive}) => {
return (
<div
{...getRootProps()}
weird..Consumer componentshx/f much. using defnc will create react components for you:no-transpile in that case above would still try to transpile? there is no way to say "please don't touch this JS"?:no-transpile doesn't mean anything at all. if you set :output-feature-set :es-next it will leave all features the GCC supports as they are. it will not "transpile" them. features it does not support will still break. we always NEED to process the code and at least change the require/import/exports. so no there is no "please don't touch this JS" option. if you output "standard" javascript :es-next is as close as you'll ever get to :no-transpile.(defn pending-button [{:keys [:pending? :pending-text] :as opts
:or {:pending-text "Sending..."}} & children]
(...))
-- Spec failed --------------------
(... [{:keys [:pending? :pending-text],
:as opts,
:or {:pending-text "Sending..."}} ... ...] ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
or
should satisfy
vector?
-- Relevant specs -------
:shadow.cljs.devtools.cljs-specs/param-list:
:pending-text should be pending-text (in the :or section):keys section, its also more idiomatic to use symbols there 😉Clojure 1.10.0
user=> (defn x [{:keys [:foo] :or {:foo 1}}])
Syntax error macroexpanding clojure.core/defn at (REPL:1:1).
{:keys [:foo], :or {:foo 1}} - failed: vector? at: [:fn-tail :arity-n :bodies :params] spec: :clojure.core.specs.alpha/param-list
({:keys [:foo], :or {:foo 1}}) - failed: Extra input at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-listcljs.user=> (defn x [{:keys [:foo] :or {:foo 1}}] foo)
#'cljs.user/x
cljs.user=> (x {})
nilcljs.user=> (defn x [{:keys [:foo] :or {foo 1}}] foo)
#'cljs.user/x
cljs.user=> (x {})
1(r/createElement rn/View #js {} (r/createElement rn/Text #js {} "helloaa"))
I can require (without use) fulcro.client.primitives with no errors
But when I require (without use) fulcro.client it thows undefined is not a object (evaluating 'goog.loader.activeModuleManager.setDefault')
it thows in goog.module.modulemanager.js:674:32
I'm using shadow-cljs + :target :npm-modulefulcro.client.mutations requires cljs.loader but doesn't use itgoog.loader.activeModuleManager namespace doesn't seem to work correctly in react-native but it shouldn't be required anywayscljs.loader require removed:target :react-native nice!:target :npm-module. tnkx @thheller
I will try to move into target react-native. I'm (intentionally) not using expo so it may be a little different.:target :react-nativejs/... calls and :require namespaces:infer-externs :auto on though as it isn't 100% https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externsPromise?:es3for example?:output-feature-set. the :language-out is sort of deprecated. https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_optionsjs/Promise from CLJS it won't be polyfilled in developmentreleaseoutput-feature-set?:es5ECMAScript® 2015 was that es5 or es6? naming is confusing 😛:compiler-options {:rewrite-polyfills true}2.8.11 fixes the goog.loader issue on react-native and it should now load properly without errors. can't actually use it due to metro but at least it won't break when loading.shadow.loader.init work for the CDN use case I mentioned?:module-loader-init false in the config an manually call shadow.loader.init(""), so only the prefix:module-hash-names?:fn-invoke-direct true be weird here?shadow.loader.initshadow$modules var manually?shadow.loader.init?.shadow-cljs/builds/<your-build-id>/release directory which you probably don't docljs.core.assoc will be assigned the same short name in between buildsxT in one and fY in annothershadow.lazyshadow.lazy addition is very similar to what we domodule-b was compiled against module-a where cljs.core.assoc was named xT. Another build however assigned xT to cljs.core.conj. Now the module-b is suddenly calling cljs.core.conj in places where it expects to call cljs.core.assoc. Obviously breaking in horrific ways.undefined is not an object (evaluating 'M.h')shadow-cljs release your-build --pseudo-names and check what that is?cst$sym$... doesn’t existcst$sym names at all?cst$sym$$props__auto__NNN for surejs->clj on random JSON data?:output-wrapper? https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper:output-wrapper explicitly? replaces something from the build:output-wrapper…..js->clj at all?js->clj where, for example?js->clj has this problem with misidentified fast-path protocolsjs->clj on JSON data that has short property names with numeric values. eg. {"x":4}js->clj in some places, but I don’t think they’d be in this code pathjs->clj for JSON data 😛:pseudo-names which probably rules this out since the issue can't really happen with thatshadow-cljs check your-build? It might provide a cluecognitect.transit to read JSON data?check as a library?(shadow.cljs.devtools.api/check :build-id)?release build and runs the GCC type checker over it:js-options {:minimize-require false}npm ls lazy-cache shows a prompt module that Im using, wondering if I should remove it...ns foo.bar required "xyz" but didn't use it(defn get-manifest
[id]
(-> (shadow/get-build-config id)
:output-dir
(str "/manifest.edn")))
Or maybe return manifest from (shadow/release :id)(-> (shadow/get-build-config id) (shadow/release* {}) (extract-whatever-info-you-need))release* returns the full build state after compilation which contains everything the manifest contains?release doesn't return anything on purpose since its meant to be used from the REPL(or (::closure/modules state)
(:build-modules state))release builds will have the :shadow.build.closure/modules datafailed to load module$node_modules$grommet$components$Box$Box), in looking at the node_modules layout it ‘seems’ like it should be ok. For example, there’s a node_modules/grommet/components/Box/Box.js
During the compile, there’s one info/warning [2019-02-28 21:06:26.501 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/grommet/components/hocs.js", :requires [{:line 41, :column 11}]}
In hocs.js theres some node code, that return require(.. is line 41
if (process.env.NODE_ENV !== 'production') {
doc = function doc(component) {
return require("./" + component + "/doc").doc;
}; // eslint-disable-line
}
lein that folks are using? I have found https://hub.docker.com/r/urbanslug/shadow-cljs but the link to github seems brokenglobal.WebSocket = require('ws');
require('es6-promise').polyfill();
require('isomorphic-fetch');
(set! js/goog.global.Thing ...)(:require ["ws" :as ws]) (set! js/goog.global.WebSocket ws)airsonic-ui.components.*, where '*' means several different namespaces already existing. I create airsonic-ui.components.sortable.views, the namespace cannot be required. shadow-cljs warns me that it doesn't exist. I move airsonic-ui.components.sortable.views up to airsonic-ui.components.sortable, it's found. Any idea what might be going on here?.subs .views nested namespaces aren't that common for me{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "abd8c3cacfc4dc86c8c7c1d8eb998593859a98"}, :content ("[email protected]")}:modules, well maybe. do you set :language-out in your config?:language-out I don’t think?:feature-set :es5"use strict"; in front of each module:language-out :ecmascript5 does adjust the feature set but it also disables strict mode:output-feature-set which I previously assumed:compiler-options {:language-out :ecmascript5} solves your problem:output-wrapper true the :language-out probably won't actually fix your problem since :output-wrapper works with strict modewebpack https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html:modules properly which will hopefully make it a bit clearer why the "double-bundle" appraoch using webpack is bad 🙂shadow-cljs 😉shadow-cljs was kinda built for exactly the scenario I setup 😉isLoaded error when i call lazy/loaded? here. i am printing + js/logging the loadable above, so it itself is not undefinedlazy/load on the loadable, I get the error “Unknown module: app”:app is definitely one of my modules:module-loader true in your config?:module-loader true is not usedUncaught ReferenceError: $spark_web$views$account$index$index$$ is not defined. this is happening after the module loads, which I verified by adding a logging statement via :append.
I can see in the source of the account module that it is defining that thing, function $spark_web$views$account$index$index$$($var_args$jscomp$814$$) {...}, but it isn’t being set on the window object.
if I manually add this line below it, window.$spark_web$views$account$index$index$$ = $spark_web$views$account$index$index$$;, then it loads correctly.:output-wrapper false, didn’t seem to have an effect:compiler-options {:language-out :ecmascript5} in your build config. I'll finish a release later that adds that default back.function declared in the module files isn't visible globally"use strict"; when they shouldn't:output-wrapper true though:compiler-optionsfalse won't work. true should.false when using multiple modulesdeps.edn dependencies whilst this issue is still open: https://github.com/thheller/shadow-cljs/issues/362? I’m sure I’ve read something somewhere about triggering a download of dependencies for deps projects, but can’t seem to find it.shadow-cljs to your deps.edn and use clj to download the deps. clj -Stree or soYou probably need to run: npm install querystringcaused by a dependency:
node_modules/url/url.jsAnd I'm not sure how I can troubleshoot it. I installed
querystring, but the problem is not going away. querystring has a regular index.js which seems to be the top level module.:js-options {:resolve {"querystring" {:target :npm
:require "querystring/index.js"}}}
shadow-cljs to your package.json.(require 'some.other.ns) then (in-ns 'some.other.ns)shadow.lazy but it's not actually used anywhere. Also, demo.util/lazy-component is used but there's no implementation. Is this an exercise for the reader or will there be any addition to the article? I saw the code splitting example in your examples repo but it's very simplistic and doesn't have anything about lazy loading components.[nREPL] Starting server via /usr/bin/npx shadow-cljs -d nrepl:0.5.3 -d cider/piggieback:0.3.10 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.20.0 server...nrepl and cider-nrepl not too long ago and I believe nrepl 0.6.0 is required nownrepl.middleware.caught ns is part of nrepl now and wasn't previously[nrepl "0.6.0"] in your deps as wellgoog.DEBUG which is a built-in closure-define which will be false in release builds:preloads if you want to add namespace you'd rather not use in a release build. https://shadow-cljs.github.io/docs/UsersGuide.html#_preloadsyour.app.logging-dev namespace and include it via :preloadsshadow-cljs release your-app --pseudo-names^js hints whenever it warns about something.caught is getting renamed when it shouldn't but it seems to be something in promesa:simple optimizations for node:compiler-options {:optimizations :simple}(:require ["that-package" :as x]) in your ns[2019-03-05 00:14:50.420 - WARNING] :shadow.cljs.devtools.server/nrepl-ex CompilerException java.io.FileNotFoundException: Could not locate nrepl/middleware/caught__init.class or nrepl/middleware/caught.clj on classpath., compiling:(cider/nrepl.clj:1:1)
shadow-cljs 2.8.14ncu -a which bumps all my npm deps, including shadow, so not a problem for me. Namespace "goog.debug.Error" already declared. errors from goog.provide. I keep getting these errors even after I refresh the browser. Killing the shadow process and compiling from scratch, then it works again. Namespace "goog.debug.Error" already declared. errors from goog.provide. I keep getting these errors even after I refresh the browser. Killing the shadow process and compiling from scratch, then it works again.:browser build(shadow/stop-worker :live) and then (shadow/watch :live). it will load successfully, then break again soon after a bit of editing. i don’t have to do anything with the :bootstrap build.shadow-cljs watch live trusted bootstrap with however you add the -A:release to thatnpm install fails with a gigantic wall of text>
$ shadow-cljs -A:release watch live trusted bootstrap
shadow-cljs - config: /mnt/c/Users/thheller/code/oss/maria/editor/shadow-cljs.edn cli version: 2.8.14 node: v10.13.0
shadow-cljs - starting via "clojure"
Downloading: appliedscience/js-interop/0.1.11/js-interop-0.1.11.pom from
Error building classpath. Manifest type not detected when finding deps for lark/tools in coordinate {:git/url "", :sha "113b9f6f8d8ff7a3c35864fb5f50c20be61c729e", :deps/root "tools"}------ WARNING #1 - :undeclared-var --------------------------------------------
File: /mnt/c/Users/thheller/code/oss/maria/editor/src/maria/live/source_lookups.cljs:117:40
--------------------------------------------------------------------------------
114 | (defn var-source
115 | "Look up the source code corresponding to a var's metadata"
116 | [{{meta-file :file :as meta} :meta file :file name :name :as the-var} cb]
117 | (if-let [logged-source (some-> (get @live-eval/evaluated-sources-by-filename meta-file)
----------------------------------------------^---------------------------------
Use of undeclared Var lark.eval/evaluated-sources-by-filename
--------------------------------------------------------------------------------
118 | (source-of-top-level-form the-var))]
119 | (cb {:value logged-source})
120 |
121 | (if-let [source-name (some-> (namespace name)
--------------------------------------------------------------------------------
`05bc43a10e8a72ba552cc87fd2794eb9db6f06c7:async-require true this isn't required anymore. it is detected at runtime.{:deps true
:dev-http {8000 "public"}
:builds {:browser {:target :browser
:modules {:app {:entries [shadow-ex.core]}}
:output-dir "public/compiled"
:asset-path "/compiled"}
:bootstrap {:target :bootstrap
:output-dir "public/js/compiled/bootstrap"
:entries [shadow-ex.core]
:exclude [cljs.js]}}}
:foreign-libs in my figwheel config. How do I translate that to shadow-cljs?no "source-map-support" (run "npm install source-map-support --save-dev" to get it) when source-map-support is installed….carbon-react, so these are the steps I did:
- yarn add react react-dom create-react-class carbon-react
- yarn
Then I used its components:
(ns carbon-example.dashboard.views
(:require ["carbon-react/lib/components/app-wrapper" :as AppWrapper]
["carbon-react/lib/components/navigation-bar" :as NavigationBar]
[re-frame.core :as rf]))
(defn- navbar
[]
(fn []
[:> NavigationBar]))
(defn panel
[]
(fn []
[:> AppWrapper
[navbar]]))
But shadow-cljs compile carbon-example doesn't work:
shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn cli version: 2.8.24 node: v8.15.1 [:carbon-example] Compiling ... The required JS dependency "core-js/modules/es7.symbol.async-iterator" is not available, it was required by "node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js". Searched in:/home/manuel/7bridges/code/carbon-example/node_modules You probably need to run: npm install core-js/modules/es7.symbol.async-iterator See:
shadow-cljs.edn file:
{:builds
{:carbon-example {:asset-path "/js"
:modules {:main {:entries [carbon-example.core]}}
:output-dir "resources/public/js"
:target :browser}}
:dependencies [,,,]
:dev-http {8020 "resources/public/"}
:devtools {:http-root "resources/public"
:http-port 8020}
:nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]
:port 8777}
:source-paths ["src"]}
npm WARN
npm install carbon-reactnpm ls, the problem seems to be:
├─┬An old version of
core-js.carbon-react depends on "core-js": "^2.6.3",{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "284b475a4d05425b6819061a061f"}, :content ("[email protected]")} installedcore-js to you deps with the proper versionyarn add
- shadow-cljs compile carbon-example
Now I get:
shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn cli version: 2.8.24 node: v8.15.1
[:carbon-example] Compiling ...
failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js
{:relative-to #object[java.io.File 0x6164b3a2 "/home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js"], :entry "../../utils/helpers/tags"}
ExceptionInfo: failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8cffe4ede8e3fba1efe0e6ffccbea2b4a2beb9"}, :content ("[email protected]")}- run: HASH=$(sed 's/.*:output-name \"main\.\([a-zA-Z0-9]*\)\.js\".*/\1/' public/js/manifest.edn)
- run: echo $HASH
- run: sed -n "s|\"/js\/main\.js\"|main.$HASH\.js\"|g" public/index.html
if anyone has a better idea:build-hooks or clj-run.:node-library targets could be made single-file or am i imagining things?node_modules. cant tell if there was ever a final decision about allowing the source files to basically just be concatenated or if that introduced edge cases to the point of not being worthwhilenode_modules in the future. thanks a million for the guidance as always @thheller:compiler-options {:language-out :ecmascript3} and it should add the closure polyfill for that:compiler-options {:closure-injected-libs #{"util/assign"}}:output-feature-set:language-out is probably betterrelease builds so if you are testing with development builds that may not worknode_modules/@babel/runtime/package.json"^7.3.4":compiler-options
{:rewrite-polyfills true
:language-out :ecmascript3}release mode(ns
(:require
["react-bootstrap" :as bs]
))
(defn init []
(js/console.log js/Object js/Object.assign)):compiler-options set.assign error if not;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:dev-http
{9005 "public"}
:builds
{:app {:target :browser
:modules {:main {:init-fn }}
:compiler-options
{:rewrite-polyfills true
:language-out :ecmascript3}
}}}shadow-cljs release appcompile or watchrelease as that is currently the only thing that can potentially work:js-options {:rewrite-polyfills true} + the :compiler-options:js-options
{:rewrite-polyfills true}
:compiler-options
{:language-out :ecmascript3
:rewrite-polyfills true
:infer-externs :auto}Object.assign in the CLJS sources which caused the polyfills to be added(defn ^:dev/after-load render []
(react-dom/render
(r/createElement r/Fragment nil
(r/createElement "div" nil "content 1")
(r/createElement "div" nil "content 2"))
(js/document.getElementById "main")))shadow-cljs watch app{:source-paths
["src"]
:dependencies [[binaryage/devtools "0.9.7"]
[cider/cider-nrepl "0.20.0"]
[datascript "0.18.2"]
[posh "0.5.5"]
[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.520"]
[org.clojure/core.async "0.4.490"]
[reagent "0.8.1"]]
;; set an nrepl port for connection to a REPL.
:nrepl {:port 8777}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:main
{:entries [rectangles.core]}}
:devtools
;; before live-reloading any code call this function
{:before-load rectangles.core/stop
;; after live-reloading finishes call this function
:after-load rectangles.core/start
;; serve the public directory over http at port 8700
:http-root "public"
:http-port 8700
:preloads [devtools.preload]}
}}}
shadow-cljs - config: /Users/d4hines/repos/rectangles/shadow-cljs.edn cli version: 2.8.25 node: v8.12.0 shadow-cljs - connected to server shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (207 files, 1 compiled, 0 warnings, 5.02s)
shadow-cljs - connected to server:> usage? As in [:> :div props child0 child1]
thanks!shadow-cljs - config: /home/circleci/repo/shadow-cljs.edn cli version: 2.8.25 node: v10.15.3 shadow-cljs - updating dependencies shadow-cljs - dependencies updated [:test] Compiling ... >
:jvm-opts ["-Xmx2G"] (limiting the JVM to max 2gig ram); "main.js" is the name for the bundle entry
:modules {:main {:entries [<snip>.]
:init-fn <snip>.
:service-worker {:entries [<snip>.viewer.service-worker]
:depends-on #{:main}
;:web-worker true
}}service-worker.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined at service-worker.js:1 in the console in Chrome.;:web-worker true this needs to be true, otherwise things aren't loadable in a worker env:web-worker true I get uncaught ReferenceError: importScripts is not definedimportScripts should be supported? https://www.w3.org/TR/service-workers-1/#importscriptsservice-worker.js. it should start with importScripts("main.js"):modules
{:shared
{:entries []}
:main
{:init-fn <snip>.!
:depends-on #{:shared}}
:service-worker
{:entries [<snip>.viewer.service-worker]
:depends-on #{:shared}
:web-worker true
}}clojure.core/load and clojure.core/load-file, but not available in cljs. So I’m wondering if this is possible via shadow-cljs.eval, you have to include iteval. Does it still only support browser though? I’ll need to use it on nodejs to load local files.shadow.cljs.bootstrap.node ns instead of the browser one(ns demo.bootstrap-script
(:require
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.node :as boot]))
(defn print-result [{:keys [error value] :as result}]
(prn [:result result]))
(def code "(prn ::foo) (+ 1 2)")
(defonce compile-state-ref (env/default-compiler-env))
(defn compile-it []
(cljs/eval-str
compile-state-ref
code
"[test]"
{:eval cljs/js-eval
:load (partial boot/load compile-state-ref)}
print-result))
(defn main [& args]
(boot/init compile-state-ref {} compile-it)):bootstrap-script-host
{:target :node-script
:main demo.bootstrap-script/main
:output-to "out/demo-bootstrap/script.js"
:compiler-options
{:optimizations :simple}
:devtools
{:enabled false}}
:bootstrap-script-support
{:target :bootstrap
:output-dir "out/demo-bootstrap/bootstrap"
:exclude #{cljs.js}
:entries [cljs.js demo.macro]
:macros []
:js-options
{:js-provider :require}}{:deps {:aliases [:dev :test]}
:builds ...} If I am using deps.edn and define multiple aliases, which one is used for development and which one is used for release build? For example, if I have cider-nrepl in the dev alias, will it get included in release build? From my experiment, it looks like shadow-cljs is doing the right thing, but would like to know how.shadow-cljs release uses the same classpath as for developmentcider-nrepl is a Clojure dep so there's no way it will end up in your release 😉:repos
{"s3-private-snapshot" {:url ""}
"s3-private-release" {:url ""}}
:repositories not :repos though. same as in lein. this is the lib used for that https://github.com/s3-wagon-private/s3-wagon-private:dev-http
{8081
{:root "public"
:proxy-url ""}}:8080 and serves everything BUT the static filescache-control: private, no-cache header:9630, nothing to do with the dev http serverUncaught ReferenceError: regeneratorRuntime is not defined message in the browser console.
I'm using the npm workbox-precaching package (in a service worker) and the error is occurring in one of the source files this uses (`node_modules/workbox-core/_private/quota.mjs`). It seems that this file (that uses async/`await`) is getting transpiled to ES5 and the transpiled version is expecting a global regeneratorRuntime to be defined:
var executeQuotaErrorCallbacks = function () {
var _ref = global.shadow.js.babel.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback;
return regeneratorRuntime.wrap(function _callee$(_context) {
Has anyone come across this before?regeneratorRuntime (https://raw.githubusercontent.com/facebook/regenerator/master/packages/regenerator-runtime/runtime.js) to my worker.js file that shadow-cljs generates. Is there a mechanism in shadow-cljs that will allow me to prepend some JS to a module?node_modules/workbox-precaching/dist/workbox-precaching.prod.js. which doesn't work either but for different reasons?(:require ["workbox-precaching/precacheAndRoute.mjs" :refer (precacheAndRoute)]) currently which is causing the regeneratorRuntime error. I don't seem to have a dist dir in node_modules/workbox-precaching{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6b1c041900090413461b190e080a080302050c2b5f4559455b"}, :content ("[email protected]")}.mjs directly will skip the prod file`
"workbox-precaching": "^4.1.1",
"workbox-routing": "^4.2.0",
"workbox-strategies": "^4.2.0"npm install'd themworkbox-precaching working with shadow-cljs previously? Perhaps I just need to figure out why I'm missing the 'dist' versions?dist files don't work either so don't worry about itregenerator references?node_modules filesasync/await as they are as server workers support that:compiler-options {:output-feature-set :es7} (or whatever async/await was)node_modules since it goes through some naive babel processing firstregenerator-runtime/runtime.js verbatim to the start of my generated worker js bundle does fix it for me in this instancedev.clj:
(defn start [] (shadow.server/start!) (shadow/watch :app) (start-app)) (defn stop [] (app/stop) (shadow.server/stop!))However, my understanding is that restarting the shadow-cljs server should only be necessary if dependencies change. Is that correct? In other words, it would be better to start the shadow-cljs server via
npx shadow-cljs server app and then just start/stop the shadow-cljs watcher in the start and stop functions?stop! stops all running watch processes an in turn kills all REPL state/connectionsstop!lein repl :headless, then connect to the nREPL with your IDE, and then run (start). This way (stop) doesn't kill the REPL.cljs repl? Couldn’t find anything in the docs.localhost from Android.No such namespace: jsThe instructions that got me there: 0. Configure
shadow-deps.clj:
{:source-paths ["src"]
:dependencies []
:nrepl {:port 3333}
:builds
{:app {:target :node-script
:main demo.script/main
:output-to "out/demo-script/script.js"
:output-dir "public/js"
:asset-path "/js"
:modules
{:main
{:entries [demo.script]}}}}}
1. shadow-cljs node-repl app:
cli version: 2.8.26 node: v10.9.0 shadow-cljs - server version: 2.8.26 running at shadow-cljs - nREPL server started on port 3333 [0:0]~cljs.user=>2. Connect to the Remote Configuration nREPL port 3333 in Cursive, open REPL and see this message:
Connecting to remote nREPL server... Clojure 1.10.03. Evaluate
(shadow/repl :app) in the REPL
(shadow/repl :app) To quit, type: :cljs/quit => [:selected :app]4. Evaluate
(js/console.log "working?")
5. Receive the error
Any idea how to solve this?(shadow.cljs.devtools.api/node-repl)After evaluating that expression I don't get the error anymore, so I guess the instruction #3 should be replaced with this, in the instruction list I've described above.
shadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code).(shadow/repl :app) is not possible unless a watch for app is runningshadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code).
I now understand that there are multiple ways to start up a Node.js process:
- On terminal: shadow-cljs node-repl
- On terminal: node out/demo-scripts/script.js
- In a REPL at shadow.cljs ns: (shadow.cljs.devtools.api/node-repl)
Therefore the quote on the shadow-proto-starter link I gave above is a bit misleading in instructing to use the third option without providing context on the other options available.
2.
> (shadow/repl :app) is not possible unless a watch for app is running
On the steps that I had followed above, this command was absent, so I can see why (shadow/repl :app) failed for me.
At this point, having watch compile my main namespace on changes isn't actually doing anything for me aside from spitting warnings:
(process.on "SIGINT" on-signal-interruption) Use of undeclared Var demo.script/process (process.getuid) Use of undeclared Var demo.script/processI was also trying to setup
:devtools config to work, but didn't get a lot of success there out of the box, so i'm gonna let it go for now.
So right now I don't have a good reason to have watch running, so I'm going to avoid that and just connect to a Node.js process and re-evaluate the namespace i'm working on upon changing the file. I also have start, stop functions that do some I/O for me which I have to do before and after re-evaluation.
Moving forward I might want to set that up with the :before-load and :after-load build hooks. When I decide to try do that, and am stuck again I'll post a minimal reproduction to try and pinpoint the problem I ran into.(process.on ...) is not valid code. that should be (js/process.on ...)node-repl or browser-repl. These are not coupled to a specific build.:builds:main function, hot-reload, etc)node out/demo-scripts/script.js this doesn't start a node REPL. that starts a build REPL, your build just happens to be running in node. so yes it is running a node REPL but that is not the same thing as node-replnode-repl(process.on ...) is not valid code. that should be (js/process.on ...)
Hmm I can see that the build compiler doesn't warn about js/process. however the evaluation seems to work just fine when I don't use js/ for process object:
process.version => "v10.9.0" js/process.version => "v10.9.0"> I know its confusing ... Yep! very confusing 🙂 > so basically if you want hot-reload use a build and REPL into that > here is a minimal setup if you want to try Thanks! it's so useful to have this setup. *UPDATE*: The
:devtools configs for :before-load-async and :after-load are working for me!
Very nice... my workflow is now so much easier with performing some start / stop functions that do some IO (right now for me it's mounting some directory on start and unmounting it on stop, but the same could work for other things like starting up a server and stopping it). I would like to write about this sometimeprocess.version works it should be avoided since it won't work in different contexts. if you want to use "global" node variables like process you should use them via js/process.fetch and object.assign in order to work with older versions of safari. Im using https://polyfill.io.fetch and object.assign I was able to resolve with a polyfill. After that I was able to load the app at least. I have more issues with css after which I stopped working on this. I'm going to talk to the project owner tomorrow and discuss whether or not it's worth investing more time in this issue.
I'm also not sure if the issue is with cljs or an npm lib as I don't have source maps setup and I was investigating the issue with advanced compilation with http://browserstack.com. However I'm pretty sure it's an npm library though, I'm not doing fetch or object.assign with js interop or anything.:prepend as mentioned in the issue that orestis linked?let instead of var directly in the index.html file that I didn't know about at the time so I guess I assumed it wasn't working. I'll remove the polyfill now and give that a try.Object.assignperformance.now that I forgot to mention. I didn't find that here though: https://cljs.github.io/api/compiler-options/rewrite-polyfills, so I'm not sure if shadow could help me there.init() call.2.8.28 I added a new :js-options {:babel-preset-config {:targets {:safari 7}}} which lets you configure babel to inject certain polyfills into JS code:js-options {:babel-preset-config {:targets {:safari 7 :ie 11}}} and :compiler-options {:rewrite-polyfills true :output-feature-set :es3} to my shadow-cljs and neither safari 7 nor ie 11 seem to have any polyfills. ie Is missing Promise and safari is missing Object.assign.:compiler-options.shadow-cljs/babel-worker/babel-worker.js file?babel-worker directory.shadow-cljs/socket-repl.port file:node-tests target. But somehow, when I import clojure.test or cljs.test, it seems that cljs.test/assert-expr is missing. Is this a known issue?cljs.test in clojure?(ns paprika.collection-test
(:require [clojure.test :refer [deftest testing is assert-expr] :include-macros true]
[paprika.collection :as coll]))
1 | (ns paprika.collection-test -------^------------------------------------------------------------------------ Invalid :refer, var cljs.test/assert-expr does not exist -------------------------------------------------------------------------------- 2 | (:require [clojure.test :refer [deftest testing is assert-expr] :include-macros true] 3 | [paprika.collection :as coll])) 4 |
:refer that?assert-expr to extend clojure.test: https://github.com/nubank/matcher-combinatorscljs/test.cljs exists as well as cljs/test.cljccljs/test.cljs and imports cljs/test.cljc as macroscljs/test.cljs + the macros defined in cljs/test.cljcassert-expr is not a macro its not visible as it wouldn't be usable anywayslein-cljsbuild, and it does compile there. Is shadow-cljs stricter than lein-cljsbuild?failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.classpath/resource "com/wsscode/pathom/viz/d3-attribute-graph.js"] [:shadow.build.classpath/resource "com/wsscode/pathom/viz/detect-element-size.js"] [:shadow.build.classpath/resource "com/wsscode/pathom/viz/d3-trace.js"]]}
ExceptionInfo: failed to convert sources
shadow.build.closure/convert-sources*/fn--12072 (closure.clj:1434)
shadow.build.closure/convert-sources* (closure.clj:1404)
shadow.build.closure/convert-sources* (closure.clj:1292)
shadow.build.closure/convert-sources (closure.clj:1621)
shadow.build.closure/convert-sources (closure.clj:1549)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1016)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1009)
shadow.build.compiler/compile-all (compiler.clj:1264)
shadow.build.compiler/compile-all (compiler.clj:1128)
shadow.build.api/compile-sources (api.clj:252)
shadow.build.api/compile-sources (api.clj:244)
shadow.build/compile (build.clj:373)
shadow.build/compile (build.clj:364)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:293)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:279)
shadow.cljs.devtools.server.worker.impl/eval14932/fn--14934 (impl.clj:640)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14646/fn--14647/fn--14655 (util.clj:293)
shadow.cljs.devtools.server.util/server-thread/fn--14646/fn--14647 (util.clj:292)
shadow.cljs.devtools.server.util/server-thread/fn--14646 (util.clj:265)
java.lang.Thread.run (Thread.java:748)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
INTERNAL COMPILER ERROR.
Please report this problem.
Unexpected module type: SCRIPT
Node(NAME d3): com/wsscode/pathom/viz/d3-attribute-graph.js:8:14
const svg = d3.select(element)
Parent(GETPROP): com/wsscode/pathom/viz/d3-attribute-graph.js:8:14
const svg = d3.select(element)
Node(SCRIPT): com/wsscode/pathom/viz/d3-attribute-graph.js:1:0
import * as d3 from "/node_modules/d3/dist/d3.node.js";
Parent(ROOT): [source unknown]
you know how to go around that?import * as d3 from "/node_modules/d3/dist/d3.node.js"; just import ... from "d3";?import * as d3 from "d3";require and module.exports?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e485e4247"}, :content ("[email protected]")}. the entire situation currently is a bit messy since the JS world can't decide how to do ESM->CommonJS interop properly/Development/third-part/fulcro-inspect/shells/chrome Error Could not load file 'out/cljs-runtime/goog.i18n.bidi.js' for content script. It isn't UTF-8 encoded
:compiler-options {:closure-output-charset "ASCII"} but that defaults to utf-8 so no idea why it would complain<meta charset="utf-8"> or content-type header:compiler-options {:closure-output-charset "US-ASCII"} beforeASCII, but none worked2.7.6$ file out/demo-browser/public/js/cljs-runtime/goog.i18n.bidi.js out/demo-browser/public/js/cljs-runtime/goog.i18n.bidi.js: UTF-8 Unicode text, with very long lines
/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-zÀ-ÖØ-öø-ʸ̀-ऀ-"string.js:58 Uncaught TypeError: Cannot read property 'startsWith' of undefined
at string.js:58
(anonymous) @ string.js:58
util.js:92 Uncaught TypeError: Cannot read property 'contains' of undefined
at Object.goog.labs.userAgent.util.matchUserAgent (util.js:92)
at Object.goog.labs.userAgent.browser.matchOpera_ (browser.js:44)
at useragent.js:126
goog.labs.userAgent.util.matchUserAgent @ util.js:92
goog.labs.userAgent.browser.matchOpera_ @ browser.js:44
(anonymous) @ useragent.js:126
util.cljs:187 Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
util.js:92 Uncaught TypeError: Cannot read property 'contains' of undefined
at Object.goog.labs.userAgent.util.matchUserAgent (util.js:92)
at Object.goog.labs.userAgent.browser.matchChrome_ (browser.js:125)
at devtools$formatters$available_QMARK_ (formatters.cljs:17)
at devtools$core$is_feature_available_QMARK_ (core.cljs:17)
at util.cljs:246
at Object.devtools$util$install_feature_BANG_ [as install_feature_BANG_] (util.cljs:246)
at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:51)
at Function.cljs$core$IFn$_invoke$arity$0 (core.cljs:44)
at preload.cljs:11
goog.labs.userAgent.util.matchUserAgent @ util.js:92
goog.labs.userAgent.browser.matchChrome_ @ browser.js:125
devtools$formatters$available_QMARK_ @ formatters.cljs:17
devtools$core$is_feature_available_QMARK_ @ core.cljs:17
(anonymous) @ util.cljs:246
devtools$util$install_feature_BANG_ @ util.cljs:246
(anonymous) @ core.cljs:51
(anonymous) @ core.cljs:44
(anonymous) @ preload.cljs:11
browserevent.js:248 Uncaught TypeError: goog.debug.freeze is not a function
at browserevent.js:248
(anonymous) @ browserevent.js:248
string.cljs:227 Uncaught TypeError: goog.string.isEmptySafe is not a function
at Object.clojure$string$blank_QMARK_ [as blank_QMARK_] (string.cljs:227)
at Object.cljs$spec$alpha$fn_sym [as fn_sym] (alpha.cljs:124)
at alpha.cljs:154
at Function.G__50065__1 [as cljs$core$IFn$_invoke$arity$1] (alpha.cljs:154)
at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:132)
at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:160)
at Object.cljs$spec$alpha$with_gen [as with_gen] (alpha.cljs:217)
at primitives.cljc:497/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8- which looks betternode_modules, .shadow-cljs and build targets, but doesn't seem to fix2.8.28 with :closure-output-charset "US-ASCII". that should now be properly applied everywhererelease buildsstartsWith error, I make sure that I clear:
- .shadow-cljs
- any build output
and rebuild. if that doesn’t work, do it a second time 😛cljs-runtime dir of that build and send it to me?startsWith error anytime we switched branches that used diff shadow-cljs versions (one 2.7.x, one 2.8.x)2.8.28/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-zÀ-ÖØ-öø-ʸ̀-ऀ-" + "Ⰰ-\ud801\ud804-\ud839\ud83c-\udbff" + "豈-︀--";
/** @private @type {string} */ goog.i18n.bidi.rtlChars_ = "֑-ۯۺ-ࣿ\ud802-\ud803\ud83a-\ud83b" + "יִ-﷿ﹰ-ﻼ";
/** @private @type {RegExp} */ goog.i18n.bidi.htmlSkipReg_ = /<[^>]*>|&[^;]+;/g;:compiler-options {:closure-output-charset "US-ASCII"} and do a clean compile or whatever?rm -rf .shadow-cljs/ shells/chrome/out/ shells/chrome/js/ and then compilewilkerlucio:fulcro-inspect wilker.lucio$ rm -rf .shadow-cljs/ shells/chrome/out/ shells/chrome/js/ wilkerlucio:fulcro-inspect wilker.lucio$ npm run dev-chrome -- -A:local/pathom:local/pathom-viz >
shadow-cljs - server version: 2.8.28 running at ?index-explorer now it will be a mirror of what I haveError building classpath. Could not find artifact com.wsscode:pathom:jar:2.2.13 in central ()
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.wsscode:pathom:jar:2.2.13 in central ()
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:422)Error building classpath. Could not find artifact com.wsscode:pathom-viz:jar:1.0.5 in central () org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.wsscode:pathom-viz:jar:1.0.5 in central ()
[:chrome-devtool] Build failure: The required namespace "com.wsscode.pathom.viz.index-explorer" is not available, it was required by "fulcro/inspect/ui_parser.cljs". [:workspaces] Build failure: The required namespace "com.wsscode.pathom.viz.index-explorer" is not available, it was required by "fulcro/inspect/ui_parser.cljs".
startsWith issues againcljs-runtime/goog.string.js file? is it empty? cljs-runtime/goog.string.string.js, that contains things/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0900-\u1fff" + "\u200e\u2c00-\ud801\ud804-\ud839\ud83c-\udbff" + "\uf900-\ufb1c\ufe00-\ufe6f\ufefd-\uffff"goog.i18n.bidi.js I get when I bump fulcro-inspect master to 2.8.28goog.string.internal ns is just missingmain.js is just outdatedgoog.string.internal.js file definitely exists. the main.js just isn't loading itmain.js not getting written properlyshadow-cljs cleanup command?lein where the first question always is did you run lein clean?main.js gets outdated with what is in cljs-runtime since it is written after those files are writtenmain.js is always written, blindly .. there is no check if it exists or notSHADOW_ENV.load({}, ["goog.debug.error.js","goog.dom.nodetype.js","goog.string.string.js",main.jsSHADOW_ENV.load({}, ["goog.debug.error.js","goog.dom.nodetype.js","goog.asserts.asserts.js","goog.reflect.reflect.js","goog.math.long.js","goog.math.integer.js","goog.string.internal.js","goog.string.string.js"internal.js loading before string.jsmain.js just looks outdated. I just don't know how that could happen2.7.xfulcro-inspect master)main.js file open in an editor?shadow-cljs writes the new one, editor overwrites it with the state it has?spit deals with exceptionsshadow-cljs.edn? Like :local/root does in deps.edn, I mean.deps.edn:source-paths manually too but nothing like :local/root without deps.ednshadow-cljs.edn file i have :source-paths [ "dev" "src" "test" ] - in the dev directory, i have company/repl.cljs, and add :repl-init-ns company.repl - when i then load the page, i get a 500 error with the message clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "company/repl.cljs"] {:resource-id [:shadow.build.classpath/resource "company/repl.cljs"]. I've also tried just putting user.cljs in there, but get the same error. Is there something obvious I'm missing? to start the repl, i'm running shadow-cljs cljs-repl my-project-id.shadow-cljs watch your-build I presume?watch terminalApr 08, 2019 10:16:42 AM io.undertow.server.Connectors executeRootHandler
ERROR: UT005071: Undertow request failed HttpServerExchange{ POST /worker/files/sif/4ef2910a-fa9c-4a38-b142-fcbfbc831193/34c60217-4ac5-46a3-b75c-7567c23309ca request {Accept=[*/*], Accept-Language=[en-US,en;q=0.9], Accept-Encoding=[gzip, deflate], Origin=[], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36], Connection=[keep-alive], Content-Length=[427], content-type=[application/edn; charset=UTF-8], Referer=[], Host=[]} response {Cache-Control=[private, no-cache]}}
clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "company/repl.cljs"] {:resource-id [:shadow.build.classpath/resource "company/repl.cljs"]}company.repl namespace probably isn't included by any other means right?:preloadssource-path would somehow imply it was required:repl-init-ns not being part of the build:devtools {:preloads [company.repl]} for your build:depencencies and :source-paths set in my project.clj and :lein true set at the top level of my shadow-cljs config. receiving the error Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:67:5).. I’ve stripped down everything in my project.clj to be absolutely bare bones with just dependencies and src-paths, yet still encountering this errorlein deps :tree[com.google.javascript/closure-compiler-unshaded "v20190325"] dependencycljsbuild or figwheel plugin running they might be adding older versions of that depnode_modules?:resolve config completelyimport/export ESM or require/module.exports commonjs?auth and see what's in thereshadow-cljs browser-repl(require '["/path/to/file.js" :as x])(prn x):source-paths ["src"] and the file at src/js/oauth2.js it would be (require '["/js/oauth2.js" :as x])(js/console.dir x) is sometimes better than (prn x) so maybe try that tooprn thenshadow-cljs node-repl since this is node stuffrequireshadow-cljs node-repl then (require '["/server/oauth2.js" :as x]) (js/console.dir x) nothing elsex?export { authorize, listFiles, oAuth2Client } instead.[“./oauth2” :default oauth] and then oauth/listFiles etcmodule.exports?require or exports or module.exports reference before that?shadow-cljs repo's readme and also with the minimal-shadow-cljs-browser i get the following error in the browser:
bidi.js:276 Uncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class
at new RegExp (<anonymous>)
at bidi.js:276
any ideas? 🙂<meta charset="utf-8"> to your html:node-script as a build target where as the docs refer to :node-library. which one am i after?:node-library2.8.29 that fixes the broken commonjs interop. so it should be working correctly now, no need for :default:defaultimport/export that is finedeps.cljs file with {:npm-deps {"whatever" "version"}} in the libshadow-cljs watch app, and open my browser, then connect via a CIDER repl, that there are two distinct contexts. For example, I have an atom defined with defonce - in the browser, it has one value, but at the REPL, it ahs another. Is there a way to unify these two contexts?shadow-cljs cljs-repl app would give you the REPL into the browsershadow-cljs (`2.8.29`), I am getting this on shadow-cljs watch:
/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:3497
!0,Hg.Ya="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717",Hg.Hb=function(b){return Vb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717")};return new Hg(a,oe)$
function Oi(a){try{var b=a[0];return b.l?b.l(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].qb(null),b;throw c;}}function Pi(a,b){b=Hi(b,Ni(function(c){a[2]=c;a[1]=4;return Oi(a)}));return z(b)?(
a[2]=H(b),a[1]=4,vh):null}
^
TypeError: Invalid value used as weak map key
at WeakMap.set (native)
at d (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1790:192)
at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:282
at Array.map (<anonymous>)
at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:259
at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1700:229
at presets (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1794:267)
at z (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1826:376)
at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1825:87
at e.buildRootChain (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1830:93)
(:require ["react-dates" :as rd]) then in reagent [:> rd/Thing {:foo "bar"} ...]:on-dates-change #(println "on date change")?:chrome-extension target, I’m not sure how to setup my background script{:target :chrome-extension
:extension-dir "extension"
:manifest-file "extension/manifest.edn"
:outputs
{:devtools {:output-type :chrome/shared
:init-fn punk.ui.chrome.devtools/init!}
:background {:output-type :chrome/shared
:init-fn punk.ui.chrome.background/init!}
:panel {:output-type :chrome/shared
:init-fn punk.ui.chrome.panel/init!}
}}
:background {:persistent false
:scripts ["out/background.js"]}
:background {:output-type :chrome/background:chrome-extension yet?(defn init! [] (log "bg init"))
:background {:output-type :chrome/background
:init-fn punk.ui.chrome.background/init!}
:type :chrome/background take an :init-fn or something else?:entries not actually sureshared.js or bg-shared.js?background.js atm:background {:persistent false
:scripts ["out/background.js"]}
:chrome/background takes care of itshadow/build/targets/chrome-extension.clj file.shadow-cljs and it started working 😞startsWith error, I’ll zip up my builds folder and send it your wayCLOSURE_BASE_PATH output by a browser compilation? I’d like it to output a relative path but it’s prepending a /, making it an absolute path and breaking dep resolution:asset-path in your config:browser target fine(ns punk.ui.encode (:require [cljs.reader :as reader])) (defn write [x] (prn-str x)) (defn read [x] (reader/read-string x))
background.jspunk.ui.encode[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
File: /Users/d4hines/repos/rectangles/src/rectangles/view.cljs:14:20
--------------------------------------------------------------------------------
11 | (prn fps-div)
12 | (add-watch fps :fps
13 | (fn [k r o n]
14 | (set! (.-innerHtml fps-div (str "<p>" n "<p>")))))
--------------------------^-----------------------------------------------------
Error in phase :compilation
dot prop access with args
{:form (. fps-div -innerHtml (str "<p>" n "<p>"))}
ExceptionInfo: dot prop access with args
(set! (.-innerHtml fps-div) (str "<p>" n "<p>"))(def fps-div (. js/document -getElementById "fps"))(def fps-div (.getElementById js/document "fps"))(. fps-div innerHtml (str “<p>” n “<p>”)) for proper syntax. but also, I’m not sure you can call node.innerHtml as a function?(gobj/set (.getElementById js/document "fps") "innerHtml" (str "<p>" n "<p>"))gobj => goog.object.shadow-cljs is a git ignored directory in your projects? just a guess but maybe git messes with the .shadow-cljs dir when switching branches? probably not but who knows 😛console.log(fs) in the oauth2.js file?require properly:browser-test does?"(foo)" vs (foo) (an actual list with foo symbol)with-let macro, complaining that the vars referenced in the output of that macro are undeclared. Any possible causes come to mind?public/* are already filteredout/*?out, just target, which I've been rm -rfing after the failed builds to make a clean slate. There are other possible complications w/ my build setup. I'm using lein for my deps + source-paths because some of my deps are stored in a private s3 bucket. My shadow-cljs config file is pretty simple though:
{:lein {:profile "+dev-client"}
:builds {:app {:output-dir "target/admin/client/public/js/compiled/"
:asset-path "/"
:target :browser
:modules {:main {:entries [kc.admin.user]}}
}}}/out/goog/labs/useragent/engine.js on the classpath, which can be in a jar. doesn't need to be one of YOUR pathsshadow-cljs clj-repl then ( "the/path/it-reports-in-the-error")/)2.4.24. Here is a repo with a minimal configuration where I still get the issue: https://github.com/CalebMacdonaldBlack/shadow-cljs-issue-2.8.29[org.clojure/clojurescript "1.10.520"][com.google.javascript/closure-compiler-unshaded "v20190325"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
shadow-cljs pom and import pom.xml to create projectlein just fine ... just need to deal with the dependency conflicts yourselfproject.clj and move deps to shadow-cljs.edn. I then removed clojure and clojurescript dependencies from the deps and I don't need the closure compiler stuff either.:socket-repl {:port 9000} does not seem to be it..shadow-cljs/socket-repl.port file to see the port the socket repl is opened onshadow-cljs node-repl app does not create that file, or open a socket repl. What am I missing?node-repl does not take a build argument. it just starts a generic node repl.npx create-cljs-project foo-test cd foo-test configure :socket-repl {:port 9000} in shadow-cljs.edn and then npx shadow-cljs node-replshadow-cljs server instead)shadow-cljs server gives:
shadow-cljs - server version: 2.8.29 running at shadow-cljs - nREPL server started on port 59717
.shadow-cljs/socket-repl.port file to verify that):chrome-extension, can I build a content script without it showing up in manifest.json?:chrome/content-inject not :chrome/content-script probably?:chrome/single-filedefrecord I am using the ^:export tag on the method, but I can’t seem to resolve it through :exports in shadow-cljs.edn any clues?deftype definition when I needed to require it from the defprotocol definition:plugins just takes a vector of symbolsdemo.dummy-plugin/plugin which is just a map:start should be a function. :stop should be a function that will be called with whatever :start returned when the server shuts down:start, return the process handle and kill it in :stop:build-hooks are indeed not a good fit for something like sass since sass compilation is independent of CLJSrun-p from npm. https://github.com/mysticatea/npm-run-all/blob/HEAD/docs/run-p.mdshadow.cljs.devtools.server.fs-watch(fs-watch/start
{}
[(io/file "some" "dir")]
["scss"]
(fn [updates]
(prn [:scss-updates updates])
)){} is config, which you don't really need[...] is an array or java file instances (eg. via )["scss"] is the file extensions to watch(fs-watch/stop what-start-returned) alsonode-test target? When I try to connect to a REPL, I'm getting "No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code."shadow-cljs node-repl (require 'your.ns) (your.ns/the-test)cljs.test methods to run them (eg. (cljs.test/run-tests) for all:autorun", so I though I could use it to run a REPL:autorun does:autorun executes the tests the a watch build completes. the node process running the tests will still exit. the shadow-cljs process however continues.:node-script targets I usually run with :devtools {:enabled false} since I want them to exit when they "complete":node-script I need a :mainfunction - my tests namespaces are not included on the :main namespace:devtools {:preloads [your.test-ns]}:preloads. Great to know! I'll check it. Thanks 🙂(require 'your.test-ns) at the REPL?:node-scripts are servers(require 'your.test-ns :reload) again if you make changes:depends-on to :depends-on [:config] and :start (fn [config] ...)shadow-cljs.edn content:sass/config {:foo :bar} or soThe required namespace "cljsjs.marked" is not available, it was required by "devcards/util/markdown.cljs". The namespace was provided via :foreign-libs which is not supported. Please refer to fo more information.I’m guessing this is devcards not specifying this correctly in deps.cljs. any work arounds?
:shadow.build/config in the build state (passed into the hooks)(shadow.cljs.devtools.server.runtime/get-instance!):your.plugin-ns/plugin key:start{:proxy
{:host "localhost"
:port 8099}}shadow-cljs.edn? I changed how the global config is handled so that might not be working anymore?:target to :npm-module and :runtime to :node, but after shadow-cljs watch lib and shadow-cljs node-repl I still get "No application has connected to the REPL server" when I try to evaluate forms over cider from Vimbin component to it that I can set as :main and run, but primarily I want to architect this as a library, and hope to have the normal clojure repl experience evaluating forms and executing tests.shadow-cljs watch lib and node-repl are completely unrelated:main is not a thing for :npm-modulerequire('./dist/whatever.core' not sufficient to load the compiled code?:npm-module its a bit trickier:node-library instead.js files you do the require in you also require("./dist/shadow.cljs.devtools.client.node"):node-library but must be done manually for :npm-module:npm-module is intended to be part of the projectshadow-cljs node-repl:node-repl build id when selecting a REPL instead of :lib:node-library but I’ll also give the :node-repl thing a shotreact-swipeable-views with shadow-cljs. When I go with yarn add react-swipeable-views it fails on the app start, giving me could not find module-entry: @babel/runtime/helpers/builtin/interopRequireDefault - most probably because that’s ES6 module. @thheller any clue on this one? I don’t want to use cljsjs lib for that.node_modules/react-swipeable-view/package.json@babel/runtime and which one is installed in node_modules/@babel/runtime/package.jsonnode_modules/@babel/runtime/helpers/builtin/interopRequireDefault.js does not existnode_modules/@babel/runtime/helpers/interopRequireDefault.js does, so just without the builtin path. guess the path changed somewhere :js-options {:js-provider :shadow :keep-native-requires true} is what you need`try {
const bufferUtil = require('bufferutil');
module.exports = Object.assign({ concat }, bufferUtil.BufferUtil || bufferUtil);
} catch (e) / istanbul ignore next / {ws package?:keep-as-require #{"ws"} for developmentshadow-cljs assuming you are using watch or compile?:keep-as-require #{"ws"} then you should be fine[org.clojure/clojurescript "1.10.520"] [com.google.javascript/closure-compiler-unshaded "v20190325"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
lein command:lein ... in shadow-cljs.edn the JVM is launched using lein:lein {:profiles ["foo"]} in your config?:profile is not a thing:lein is a true-ish thing in shadow-cljs.edndeps.edn:lein {:profile "+cljs"} means that when you run shadow-cljs watch thinglein run -m shadow.cljs.devtools.cli watch thingupdate-in [:dependencies] conj shadow-cljs or whatever the exact thing isshadow-cljslein normally it is better to add the shadow-cljs dependency manuallylein version do you have?shadow-cljs run some.lib/ancientancient wouldn't need that at all(slurp "shadow-cljs.edn") and get :depdendencies yeah:devtools but yes they are all always startedshadow-cljs compile foo while the server instance is runningClosure compilation failed with 1 errors --- node_modules/vega-lite/build/vega-lite.js:8535 This code cannot be converted from ES6. extending native class: Array
(ns cljsjs.vega-lite (:require ["vega-lite" :as vega-lite])) (js/goog.exportSymbol "VegaLite" vega-lite)), I’m not sure where to start.
:compiler-options {:output-feature-set :es6} fixes it?:js-options {:language-out :ecmascript6}:output-feature-set instead, should be more reliable:require ["lein for that since shadow-cljs doesn't have anything built-in for that yetdeps.edn with :local/root:source-paths directly:source-paths ["src/main" "../other-lib/src/main"]deps.edn https://clojure.org/guides/deps_and_cli#_using_local_librariesdeps.edn file next to shadow-cljs.ednconst parse = require('csv-parse/lib/sync') how does this translate as a :require ?(:require [csv-parse :as csv]) ... (def parse-csv (-> csv .-lib .-sync)) but .-lib is undefined.shadow-cljs folder so hold off on deleting that 😬shadow-cljs from npm/`node` without a global installation? e.g. in some directory where i’ve just npm install’d with a package that declares shadow-cljs as a dependency. running shadow-cljs ... is showing shadow-cljs: command not foundbin key in package.json, which makes me think that should workshadow-cljs?npx shadow-cljs should workshadow-cljs should always be in devDependencies thoughdevDependency. apologiesnpx, i think thats probably what I’m looking forbuild.sh was failing. Didn’t want to redundantly install it globally. I feel pretty good about the npx addition, I think that’s the secret sauce../node_modules/.bin/shadow-cljs directly toonpxnpx was just the stuff. Huge appreciation for you @thheller!:dev/after-load hook to trigger a re-renderhx that will just return a react element?hx/f right?(hx.react/f [:div "asdf"])hxf = "hiccup transform" 😅 kinda got lost along the wayf function one you wanted to rename recently?react x 3,449,728 ops/sec ±2.64% (93 runs sampled) reagent x 398,044 ops/sec ±1.78% (93 runs sampled) shadow x 1,851,920 ops/sec ±3.58% (94 runs sampled) hx x 50,539 ops/sec ±1.04% (89 runs sampled)
NODE_ENV=production 😛react x 284,902 ops/sec ±0.31% (97 runs sampled) reagent x 173,311 ops/sec ±1.83% (93 runs sampled) shadow x 269,805 ops/sec ±1.73% (94 runs sampled) hx x 42,893 ops/sec ±1.29% (91 runs sampled) rum x 244,721 ops/sec ±0.58% (96 runs sampled)
:advanced compiled code I'm amazed at the optimizations closure doesreact x 281,008 ops/sec ±1.15% (96 runs sampled) reagent x 170,642 ops/sec ±1.75% (93 runs sampled) shadow x 269,498 ops/sec ±1.78% (96 runs sampled) hx x 41,602 ops/sec ±1.26% (92 runs sampled) rum x 244,612 ops/sec ±0.27% (97 runs sampled) fulcro-dom x 262,460 ops/sec ±1.40% (95 runs sampled)
(fulcro-dom/div :.card ...) variant only seems to run interpreted and is much slower than {:className "card"}.fulcro.client.dom in the test. don't know about the localized stuffreact x 87,861 ops/sec ±1.61% (89 runs sampled) reagent x 51,563 ops/sec ±2.03% (91 runs sampled) shadow x 98,100 ops/sec ±0.11% (95 runs sampled) hx x 6,055 ops/sec ±9.97% (94 runs sampled) rum x 80,311 ops/sec ±0.33% (94 runs sampled) fulcro-dom x 29,496 ops/sec ±1.83% (87 runs sampled)
map being slower than reduce{} propsreact x 109,719 ops/sec ±0.73% (93 runs sampled) reagent x 51,251 ops/sec ±2.37% (91 runs sampled) shadow x 97,151 ops/sec ±0.12% (97 runs sampled) hx x 6,039 ops/sec ±11.34% (94 runs sampled) rum x 80,007 ops/sec ±0.91% (94 runs sampled) fulcro-dom x 83,931 ops/sec ±1.78% (92 runs sampled)
path-meta, the client parser, integrate basis-t calcs into db->tree, eliminate the need to render from root. So, one of my complex apps can take 80ms to render a refresh…I think that’ll turn into something under 10.useFulcro hook working that lets you use a plain function as a fulcro componentuseState doesn’t accidentally collide with other staterender function so if you aren't careful about allocation you end up allocating way too much garbage(react/useState {:my {:initial "state"}})def outside to safe the allocation just makes the code uglyuseState as .forceUpdate is okshadow.cljs.devtools.server.nrepl04/... middleware for things to work, and the documentation just mentions the old version https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server.nrepl04 directlyCaused by: java.lang.RuntimeException: could not find a non empty configuration file to load. looked in the classpath (as a "resource") and on a file system via "conf" system property
foo/shadow-cljs.edn and a bar/shadow-cljs.edn, and want bar to depend on foo.
If this was leiningen, I'd go into foo and do lein install, then that would copy the artifact to my local maven cache, and I would depend on it from bar normally.
Is there a shadow-cljs equivalent?foo doesn't add any deps you can just do :source-paths ["src/main" "../foo/src/main"] in shadow-cljs.edn of barlein install in foo and just using the dep in bar also works fineshadow-cljs install equivalent 😛foo has npm dependencies, and I do lein install the resulting jar won't include those deps or any reference to them :(deps.cljs with {:npm-deps {"the-lib" "version"}} to foofoo's package.json?Caused by: java.lang.RuntimeException: could not start [#'admin.config/env] this is beyond the scope of shadow-cljs, I'll just create a index.html, confirm if the paths are correct, then you can ask for lein question on different channel(r/render [#'page] (.getElementById js/document "app"))deps.edn or project.clj:deps or :lein in shadow-cljs.edn the :source-paths and :dependencies there will have no effect at alldeps.edn or project.clj?:source-paths from project.clj as welllein-tools-deps works though but you are currently setting :source-paths in 3 places which is just confusinglein-tools-deps docs.:dev
{:compiler-options {:closure-warnings {:global-this :off}
:source-map true
:optimizations :none
:pretty-print true}}
:release
{:compiler-options {:optimizations :advanced
:pretty-print false
:closure-warnings
{:externs-validation :off
:non-standard-jsdoc :off}}}:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}{:deps {:aliases [:cljs]}
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}
:modules {:app {:entries [admin.core]}}
:devtools {:after-load admin.core/mount-components}}}}resources/public/js/app.js is the file shadow-cljs will create/js/app.js:devtools {:after-load admin.core/mount-components} to call mount-components?:modules {:app {:init-fn admin.core/mount-components}}init! fn:modules {:app {:init-fn admin.core/init!}}{:deps {:aliases [:cljs]}
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:closure-warnings
{:global-this :off
:externs-validation :off
:non-standard-jsdoc :off}}
:modules {:app {:init-fn admin.core/init!}}}}}
;; admin.core js
(defn ^:dev/after-load mount-components []
(rf/clear-subscription-cache!)
(r/render [#'page] (.getElementById js/document "app")))^:dev/after-load tells the devtools to call that function after loading code. I think its cleaner there than in the build configshadow/release to get e.g. readable names?(shadow/release :thing {:debug true}) works 😄--pseudo-names would be :pseudo-names true:debug is pseudo-names + source-maps{:type :shadow.build.closure/invalid-closure-warning, :key :non-standard-jsdoc, :level :off, :shadow.build.log/level :warn} this means you can remove :non-standard-jsdoc from the build config:lein true in your config shadow-cljs watch app literally runs lein run -m shadow.cljs.devtools.cli watch appshadow-cljs watch app and that internally just calls lein run -m shadow.cljs.devtools.cli watch app for youlein yourself. its just what is done internally.lein. netlify just enables maven caching if it finds the project.cljdeps.edn?Executable 'clojure' not found on system path.
deps.edn yetlein isn't used to do anything other than caching depscurl -O
chmod +x linux-install-1.10.0.442.sh
install_dir=/opt/buildhome/clojure
mkdir -p ${install_dir}
./linux-install-1.10.0.442.sh --prefix ${install_dir}
echo "Installing Clojure to ${install_dir}/bin"
export PATH="${install_dir}/bin":$PATH
deps.edn and maybe shadow-cljs.edn even::grid::ns/my-name and :my.ns/my-namens is aliased to something2.8.14:my-ns/my-name works::/grid is not a valid keyword. ::ns/my-name is valid if you have a (:require [some.thing :as ns]) otherwise it is not. :my.ns/my-name is always valid.::grid is always always dependend on ns, so (ns foo.bar) ::grid makes :foo.bar/grid::ns/grid and :my.ns/grid both throw invalid keyword errors:my-ns/grid works fine, seems it doesn’t like dots or auto resolving:my.ns/grid throws? that sounds questionable?39 | (grid/grid :match true :uikit-hl.width/1-1-s true :uikit/width-1-1-s true :uikit/child-width-1-1-s true :uikit/child-width-1-3-m true; :class [:uk-grid-collapse] -----------------------------------------------------^-------------------------- app/ui.cljs [line 39, col 47] Invalid keyword: :uikit-hl.width/1-1-s. --------------------------------------------------------------------------------
:uikit-hl.width/1-1-s is invalid because of that(keyword 1) returns nil::2 worksuser> :a/1
RuntimeException Invalid token: :a/1 clojure.lang.Util.runtimeException (Util.java:221)
cljs.user> :a/1
clojure.lang.ExceptionInfo: [line 1, col 5] Invalid keyword: :a/1. {:type :reader-exception, :ex-kind :reader-error, :file nil, :line 1, :col 5}
:2regeneratorRuntime global variable without any indication where that is supposed to come from["react-native-storage/src/storage" :refer (Storage)]:js-options {:babel-preset-config {:targets {:chrome 74}}}class ... extends definitions(-> get-db-result (prom/then (fn [x] (fn-send-to-repl x))))
project.clj seems to have the correct ones, its safe to pull from there?[org.clojure/clojurescript "1.10.439"]
[com.google.javascript/closure-compiler-unshaded "v20181125"]project.clj is probably the best sourcedeps.edn doesn't work for shadow-cljs because there are java sources that need to be compiled:maven {:proxy ...} in ~/.shadow-cljs/config.edn> shadow-cljs compile app shadow-cljs - config: /Users/hch429/side-projects/clojurescript/my-web-app/shadow-cljs.edn cli version: 2.8.32 node: v10.12.0 shadow-cljs - updating dependencies shadow-cljs - dependency update failed - Failed to collect dependencies at quil:quil:jar:3.0.0
------ WARNING #1 - :invalid-arithmetic ----------------------------------------
...
--------------------------------------------------------------------------------
32 | (let [formatted-points (misc/cents->display points)]
33 | (if (pos? points)
34 | (str "+ " formatted-points)
35 | (str "- " (- formatted-points)))))
-----------------------^--------------------------------------------------------
cljs.core/-, all arguments must be numbers, got [#{string clj-nil}] instead
--------------------------------------------------------------------------------
Is there a different way to get a negative version of a number other than that?-. why are you doing that?formatted-points is a str out of misc/cents->display, so calling - on it is wrongnpx shadow-cljs watch frontendI get:
shadow-cljs - starting via "clojure" Executable 'clojure' not found on system path.I'm not sure where to start, any thoughts?
:deps true in your shadow-cljs.edn:deps true?:deps trueThe required namespace "applied-science.js-interop" is not available, it was required by "gespensterfelder.cljs"
shadow-cljs.edn file.
the author has elected to tell shadow-cljs, “Hey don’t bother managing my dependencies for me. Instead, use my system’s clojure installation and feed it the deps.edn file in my project to download and provide dependencies for me.”clojure on your system. if you have brew setup, it’s as easy as brew install clojure
2. use this shadow-cljs.edn file instead: https://gist.github.com/Lokeh/e8e1ec026e1021f1b1818efd79d7cbef:dependencies key + value in the shadow-cljs.edn file based on the deps.edn in the repo you posted: https://github.com/jackrusher/gespensterfelder/blob/master/deps.edn[2019-04-23 11:34:14.200 - INFO] :shadow.build.classpath/jar-cache-write-ex - {:file #object[java.io.File 0x31ab3dc7 ".shadow-cljs/jar-manifest/1555996365252-java-io-0.1.13.jar.manifest"]}
NoSuchMethodError com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
cognitect.transit/writer (transit.clj:157)
cognitect.transit/writer (transit.clj:139)
shadow.build.cache/write-stream (cache.clj:9)
shadow.build.cache/write-stream (cache.clj:8)
shadow.build.cache/write-file (cache.clj:26)
shadow.build.cache/write-file (cache.clj:24)
shadow.build.classpath/find-jar-resources/fn--10810 (classpath.clj:558)
shadow.build.classpath/find-jar-resources (classpath.clj:557)
shadow.build.classpath/find-jar-resources (classpath.clj:528)
shadow.build.classpath/find-resources (classpath.clj:608)
shadow.build.classpath/find-resources (classpath.clj:600)
shadow.build.classpath/index-path* (classpath.clj:839)
Tons and tons of them. Probably one for every dep I have.2.8.33:lein or :deps in shadow-cljs.edn? look like there maybe a dependency conflict on the transit dep?:deps{:aliases {:cljs {:override-deps {com.google.guava/guava {:mvn/version "27.1-jre"}
org.clojure/tools.reader {:mvn/version "1.3.2"}
org.clojure/core.async {:mvn/version "0.4.490"}
com.cognitect/transit-java {:mvn/version "0.8.337"}}
:extra-paths ["src/app" "src/web"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.32"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20190325"}
ch.qos.logback/logback-classic {:mvn/version "1.3.0-alpha4"}
org.clojure/google-closure-library {:mvn/version "0.0-20190213-2033d5d9"}
org.clojure/clojurescript {:mvn/version "1.10.520"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
[com.cognitect/transit-clj "0.8.313"]:module-hash-names?manifest.edn next to main-<sha>.js
You can use it do get the names(-> (shadow/get-config :the-build) (shadow/compile* {}) (:shadow.build/info)):sources vector which has what they provided and requiredproject.clj and starting using only shadow-cljs.edn for my project. Since then, whenever I create a new test deftest I need to delete .shadow-cljs and restart shadow-cljs otherwise my new test is not detected. Any idea what's up with that? I'm using karma for my tests..shadow-cljs folder and for the record DON'T delete the folderX Compilation failed. means, in regards to an imported npm project (`@ionic/react`)?errors in file: /Users/robin/Code/my-project/node_modules/@ionic/core/dist/esm/es5/ionic.core.jsimport which is not currently supported[:main] Build failure:
The required JS dependency "reakit/styled" is not available, it was required by "node_modules/fannypack/lib/styled/index.js".
Searched in:/Users/erichkoliphant/Dropbox/projects/fannypack-app/node_modules
You probably need to run:
npm install reakit/styled
...
; the call in in the index.js file that's causing the issue
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var selector = require('./selector.js');
var space = require('./space.js');
var styled = require('reakit/styled');
Not exactly sure which flavor of JS weirdness is causing this particular issue ["reakit" :refer (styled)] in my code with no problemnode_modules/reakit/package.json version and see if that matches the version fannypack expects["reakit" :refer (styled)] is not require("reakit/styled"). it would be ["reakit/styled" :as styled]:local/root then you need deps.edn for that[io.monetashi/yesod "0.1.1"] in :dependencies:deps in your shadow-cljs.edn config then :dependencies and :source-paths in shadow-cljs.edn have no effectdeps.edn that will have no effect. you need to tell shadow-cljs to actually use it.:deps true or :deps {:aliases [:cljs]} or so if you want to use a deps.edn profile.shadow-cljs: websocket error – Event Selected Element <html>…</html>
shadow-cljs watch test and a :autorun true should allow for test to run automatically no? After rebuid:target :node-test for the :test build config yesshadow-cljs watch testshadow-cljs server instance runningwatch dev running and a watch testwatch devshadow-cljs watch dev test to run two targets in one process;; remove :dev alias on production deploy
:deps {:aliases [:dev]}shadow-cljs -A:dev watch dev test also conditionally sets the alias:autorun process is directed to the wrong outputdev and testsemantic-ui-react compiles and loads fine for me so some more details are required:P[:main] Compiling ...
/Users/tonykay/owsy/gondola-client/.shadow-cljs/babel-worker/babel-worker.js:3497
!0,Hg.Ya="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717",Hg.Hb=function(b){return Vb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717")};return new Hg(a,oe)}function Oi(a){try{var b=a[0];return b.l?b.l(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].qb(null),b;throw c;}}function Pi(a,b){b=Hi(b,Ni(function(c){a[2]=c;a[1]=4;return Oi(a)}));return z(b)?(a[2]=H(b),a[1]=4,vh):null}
^
TypeError: Invalid value used as weak map key
at WeakMap.set (<anonymous>)
at d (/Users/tonykay/owsy/gondola-client/.shadow-cljs/babel-worker/babel-worker.js:1790:192)
babel failed?
{:file "/Users/tonykay/owsy/gondola-client/node_modules/semantic-ui-react/dist/es/lib/AutoControlledComponent.js"}
{
"dependencies": {
"keycloak-js": "^4.8.3",
"element-resize-detector": "^1.1.14",
"intl-messageformat": "^2.2.0",
"karma": "^4.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cljs-test": "^0.1.0",
"lodash": "^4.17.11",
"natives": "^1.1.6",
"raven-js": "^3.25.2",
"react": "^16.4.1",
"react-autocomplete": "^1.8.1",
"react-dom": "^16.4.1",
"react-icons": "^2.2.7",
"react-number-format": "^4.0.5",
"react-transition-group": "^2.2.1",
"reakit": "^0.11.2",
"semantic-ui": "^2.3.1",
"semantic-ui-react": "^0.85.0",
"shadow-cljs": "2.8.26",
"showdown": "^1.8.6"
}
}
:devtools {:enabled false} if you want your process to exit when done.------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/semantic-ui-react/dist/es/lib/AutoControlledComponent.js:269:2 JSDoc annotations are not supported on return. --------------------------------------------------------------------------------
:js-options {:babel-preset-config {:safari 11}} fixes it. checking why it fails without config.shadow-cljs watch all your builds--all switch or so. listing all the build ids may be tedious 😉:js-options {:babel-preset-config {}} also fixes it ... I guess TypeError: Invalid value used as weak map key is the equiv of a NullPointerException2.8.34shadow-cljs watch browser and shadow-cljs watch test in parallel, and since they both try to use the same port for nREPL, one of them will complainshadow-cljs watch browser test in one processshadow-cljs watch browser and shadow-cljs watch test at the same time manuallyshadow-cljs server to let the server startshadow-cljs watch browser testreact-pose (https://popmotion.io/pose/learn/popmotion-get-started/) with reagent through shadow-cljs 🙂
This might actually be a reagent question, but I thought I would start here
Basically, the example says to do const Box = posed.div();and this is what I do in cljs
(:require ["react-pose" :default posed]) (def box (.div posed))but then I cannot render this and I have tried the following ways:
[:> box] [box] (reagent/as-element [:> box]
[:> box] should be what you needenv.cljs:191 error when calling lifecycle function one.core/start TypeError: Cannot convert a Symbol value to a string
one.core/start?prn in there?(defn start []
(reagent/render-component [hello-world]
(. js/document (getElementById "app"))))
(defn hello-world [] [:> box])
(def box (.div posed))(def box (.div posed #js {}))react-spring as well, but since their new version is using hooks, it makes it difficultshadow-cljs.edn 😄 ?> var x = require("shadow-cljs/demo.foo");
{ Error: Cannot find module 'shadow-cljs/demo.foo'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
:npm-module docs are a bit light and could definitely be improved{:source-paths ["lambda-src"]
:builds {:aws {:target :node-library
:exports {:handler ingest-events.aws/handler}
:output-to "ingest-events/index.js"
:js-options {:js-provider :shadow
:keep-native-requires true}
:release {:compiler-options {:source-map true
:optimizations :simple}}}}}
index.js exposing the handler onlyexports-var but not much of a difference{:local/root "source-libs/io.monetashi.yesod"} option while in development.deps.cljs with {:npm-deps {"the-dep" "version"}}checkouts and something called lein voom. Worked ok, until it didn't. Whenever you write an article explaining your way I would be very interested 🙂checkouts 😉:source-paths ["src/main" "../the-other-lib/src/main"]deps.edn at all because my main projects (work and shadow-cljs) have .java sources which deps.edn doesn't deal withcheckouts approach to be honest since it is not committed to version controldeps.edn you only get what deps.edn provideslein it would workshadow-cljs. I quite like what I've seen of it so far, and it seems less magic to me than what I've tried in the past, although there's still lots I don't understand.
I am now trying to convert a project using lein, figwheel, cljsbuild etc. to shadow-cljs, but I'm running into an error that I have not been able to figure out.
I am using historian and I get the following error from the historian code when I try to compile:
> Use of undeclared Var historian.core/off-the-record
where off-THE-RECORD is a macro.
This works fine using lein, so I'm not sure what's wrong.
I've tried a few things, but I'm not really sure where to look.
Any ideas?
https://github.com/wodin/shadow-historian-testlein?.cljc files are tricky about about 90% of the libs I looked it do it "wrong"(ns historian.core
{:doc "Manage states for your atoms. (Easy undo/redo)"
:author "Frozenlock"
:quote "The present is the least important time we live in. --Alan Kay"}
#?(:cljs (:require-macros [historian.core :refer (off-the-record)]))):require-macros [historian.core] themselvesrequire-macros but was not able to get it to work.
Thanks for the info.Quick Start section and everything looks to be working with the exception of nothing showing in the browser’s console logUse of undeclared Var garray/clonepackage.json?react in your package.json already it should not attempt to install react from deps.cljs?:dev/after-load hook that will re-render your page https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks(defn ^:dev/after-load init [] ...)package.json not in the same directory as shadow-cljs.edn?npm install react react-dom create-react-class manually to get latest versionshadow-cljs - dependencies updated NPM dependency "react" has installed version "^16.8.6" "16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.8.6" "16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs NPM dependency "create-react-class" has installed version "^15.6.3" "15.6.2" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs running: npm install --save
{
"name": "deps-cljs-test",
"version": "0.0.1",
"private": true,
"devDependencies": {
"shadow-cljs": "2.8.35"
},
"dependencies": {
"create-react-class": "^15.6.3",
"highlight.js": "^9.12.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-flip-move": "^3.0.1",
"react-highlight.js": "^1.0.7"
}
}$ shadow-cljs server shadow-cljs - config: /mnt/c/Users/thheller/tmp/deps-cljs-test/shadow-cljs.edn cli version: 2.8.35 node: v10.13.0 NPM dependency "react" has installed version "^16.8.6" "16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.8.6" "16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs NPM dependency "create-react-class" has installed version "^15.6.3" "15.6.2" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs [2019-04-29 20:50:58.607 - WARNING] TCP Port 9630 in use. [2019-04-29 20:50:58.612 - WARNING] TCP Port 9631 in use. [2019-04-29 20:50:58.617 - WARNING] TCP Port 9632 in use. shadow-cljs - server version: 2.8.35 running at shadow-cljs - nREPL server started on port 57985
running: npm install --save + react etc then that is a bug“errorMessage”: “Cannot find module ‘xmlhttprequest’” did you try npm install xmlhttprequest?"Cannot find module 'xhr2'" this is the message node gives if node_modules/xhr2 doesn't existxmlhttprequest.js files but that wouldn't work with cljs-http since it does a "dynamic" (js/require "xmlhttprequest") which this wouldn't covernode_modules is the more reliable option for now:> syntax for importing and wrapping existing React components? Our UI team has a nice set of elements that I would like to reuse.node_modules though2.8.36./assets/app/js
- deployed on server: /some-path/assets/app/js
before we were doing something silly: had it configured to be ../assets/app/js
this worked until we added a child route 😛 /some-path/foo/bar breaks it
any advice?/some-path?:asset-path "/assets/app/js" :release {:asset-path "/some-path/assets/js"}?shadow-cljs release app --config-merge '{:asset-path "somewhere/else"}':after-reload hooks are configured:widget {:target :browser
:dev {:output-dir "resources/static/js/widget"
:asset-path "/static/js/widget"}
:release {:output-dir "widget"}
:devtools {:after-load ladder.reconciler/live-reload!
:watch-dir "resources"}
:modules {:main {:entries [ladder.widget.ui]
:init-fn ladder.widget.ui/run}}}
ladder.reconciler ns is actually included in the build?shadow-cljs could successfully be compiled by the GraalVM compiler?shadow-cljs appcds command to the create archiveshadow-cljs -A:dev -A:nrepl this works with clj. It only takes the last from what I can deduce. Is there some trick to get them both to load?shadow-cljs -A:dev:nrepl should work:devtools {:loader-mode :eval} in the build configcompile not watch to create the audio buildcljs-http and xhr2: https://github.com/r0man/cljs-http/issues/94#issuecomment-426442569cljs-repl, node-replnode-repl seems like what I want but I don't understand what "It has access to all your code via the usual means." in the docs means.shadow-cljs node-repl and then (require '["aws-sdk" :as aws]) should get you started without any watchnode-repl is fine[0:0]~cljs.user=> (require '["aws-sdk" :as aws])
repl/require failed { Error: ENOENT: no such file or directory, open '/Users/elinaeher/clubhouse/backend/salesforce-lambda/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$aws_sdk.js'
npm i aws-sdk in the local directory/Users/elinaeher/clubhouse/backend/salesforce-lambda is that your project directory?/Users/elinaeher/clubhouse/backend/salesforce-lambda/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime directory? it should have a bunch of .js files?shadow.js.shim.module$aws_sdk.js well that would be the only onecljs, goog, shadow, or clojure$?M-x cider-connect-sibling-cljs I have no clue what that doesshadow-cljs node-repl separately and select the :node-repl build in cider(shadow.cljs.devtools.api/node-repl) in the cider CLJ REPLcider-connect-sibling-cljs he wants, but cider-connect-cljs
https://cider.readthedocs.io/en/latest/clojurescript/#using-shadow-cljs$ shadow-cljs watch app shadow-cljs - config: /Users/elinaeher/clubhouse/backend/salesforce-lambda/shadow-cljs.edn cli version: 2.8.36 node: v8.11.3 shadow-cljs - server version: 2.8.36 running at shadow-cljs - nREPL server started on port 61441 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (44 files, 2 compiled, 0 warnings, 1.24s)
$ shadow-cljs cljs-repl app shadow-cljs - config: /Users/elinaeher/clubhouse/backend/salesforce-lambda/shadow-cljs.edn cli version: 2.8.36 node: v11.12.0 shadow-cljs - connected to server [1:1]~cljs.user=> (require '["aws-sdk" :as aws]) No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. [1:1]~cljs.user=>
watch doesn't manage your node process. so you need to run node <the-output-to>.js manuallynodemon). However if you want more of a REPL-driven development you can keep the process going and shadow will reload the namespaces for you. Am I right @thheller? Hopefully 😃node doesn't reload anything. you can tell shadow-cljs to reload via the hooksshadow-cljs node-repl
2. wait for nREPL server started on port <x>
3. In Emacs, M-x cider-connect and do localhost, port <x>
4. Once in the CLJ REPL, run (shadow/repl :node-repl)cider-jack-in-cljs per the link that @emoarmy posted, and run node target/main.js separately, it does work and CIDER does pick on it being a CLJS REPL. Thank you for your help, everyone.penguin.linux.test as a host instead of localhost for websocket connections. Is there setting that I can use to change the websocket host with shadow-cljs? it should be using that host as well?react-native target? https://github.com/IgorBelyayev/React-Native-Local-Resource(js/require "./my_resource.txt")js/require right(js/require "../my_resource.txt") or sohttps:// but tries to connect the primary server's websocket using ws://, which causes a mixed content error. Is there a way to get a wss:// scheme without telling shadow to handle the SSL itself (because it's already behind a secure proxy)?:devtools-url parameter we can get things to work but it's a little impractical in the context of every developer having their own URL and reading this configuration from the environment before starting shadow-cljs.
We were wondering if it might make sense to default to wss:// if the devtools are loaded on a page that already uses https://? This would cover our use case without additional configuration and might be a reasonable default? Could be this breaks something else of course but just wanted to give a bit more context on the situation. that'll fail if shadow-cljs has no ssl configuredhttps:// is used but with out the devtools-url Shadow will try to use ws:// which causes "insecure content" errors.
Does this clarify things a bit more? it'll connect to :devtools-url?hosts entry and use a hostname isntead of ip?hosts suggestion. Not 100% if relevant but we'd have an instance of this application for every coworker, each with a different public URL that'll fail if shadow-cljs has no ssl configured
I think my thinking here is: if shadow is loaded on an https:// page — wouldn't it make sense to assume the websocket connection should also use wss://. In fact in most browsers it just won't work otherwise due to insecure content restrictions, I think?:devtools-url is for .. it tells it where to connect to insteadlocalhost? becomes wouldn't answer the websockets since that has no ssl configured or whatever that is, ie. port 443 forwards port 443 AND 9630 to someone elses machine? as wellfoo and bar are running the same shadow-cljs build?foo and bar might be shadow-cljs builds on two different machines (i.e. people's computers):devtools-url is a problem in the first place?devtools-url for each machine (arguably could be much worse):force-ssl option so it just uses wss(when ssl ,,,) somehow so that it also takes the document's protocol into account{:js-provider :shadow} working and hitting a few weirdo deps issuesrequire to throw an error but shadow insists the lib must be installed:keep-as-require #{"crypto"} (in :js-options):keep-as-require shouldn't do anything since its already in that setcrypto.randomBytes?:keep-native-requires true in :js-options:keep-native-requires it works like the browser which wouldn't have access to node built-ins so they need to be bundled too:js-provider :shadow and post process the file with something like https://github.com/zeit/nccwatch is running:devtools-url since the default browser logic won't work https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support:devtools-url "" or whatever your ip isdocument.body.innerHTML 🙂shadow-cljs cljs-repl to connect. Hurray! 🎉react-devtools, ha!Uncaught TypeError: process.nextTick is not a function.
I know next to nothing about JS/node/etc, so I might be wrong, but from what I gather, process is a node global that exposes that function, and shadow does mock part of that global which it then passes to the library when it's required: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js#L55
It does, however not mock or polyfill nextTick.
So my question is: Can I monkey-patch shadow.js.process? How?
Or can I somehow replace the whole process thing with a polyfill from webpack/browserify or similar? (I think the library is designed to run with webpack)process is out of date(gobj/set shadow.js/process "nextTick" js/goog.async.nextTick) or sogoog.async.nextTick and shadow.js in the namespace that does thatSHADOW_ENV.evalLoad("shadow.animate.js", true , "goog.provide [...] (from the file compiled with :devtools {:loader-mode :eval}). I’m not sure how to get more details about this error, I have gotten this by changing console.log to add its argument to document.body.innerHTML… Does this ring any bells? Any hints?console.warn("failed to load", path, e);e ispath is the first parameter to evalLoad; e is empty… (`JSON.stringify(arguments)` yields {"0":"failed to load","1":"audio.engine.js","2":{}})try {
goog.globalEval(code);
} catch (e) {
console.warn("failed to load", path, e);
}injectedJavaScript), I could not call them directly on Android. As a work-around I assigned them to the document (e.g. document.play = play) and then called document.play(), that worked…goog.globalEval(code); with just eval(code);if (!COMPILED && goog.defineClass.SEAL_CLASS_INSTANCES). I’ll tinker a bit with it.
I gotta do some family stuff, can’t delay anymore 😕 I’ll try later.try {
goog.globalEval(code);
} catch (e) {
console.warn("failed to load", path, e);
}(ns popper-example.core
(:require [reagent.core :as r]
["react-popper" :as rp]
[applied-science.js-interop :as j]))
(defn popper-example []
[:> rp/Manager
[:> rp/Reference
(fn [props]
(let [ref (j/get props :ref)]
(r/as-element [:button {:type "button" :ref ref}
"Reference element"])))]
[:> rp/Popper {:placement "right"}
(fn [props]
(let [{:keys [ref style placement arrowProps]} (j/lookup props)]
(r/as-element [:div {:ref ref :style style :data-placement placement}
"Popper element"
[:div {:ref (j/get arrowProps :ref)
:style (j/get arrowProps :style)}]])))]])
(r/render [popper-example] (.getElementById js/document "app"))
$ npm install --save-dev shadow-cljs $ npm install -g shadow-cljs
shadow-cljs ... instead of npx shadow-cljs ...(defn start
{:dev/after-load true}
[]
(render-root (r/as-element [root])))(defn root []
[:> rn/View {:style (.-container styles)}
[:> rn/Text {:style (.-title styles)} "Hello!"]
[:> rn/Image {:source splash-img :style {:width 200 :height 200}}]])shadow-render(defprotocol IConstruct (as-managed [this env])) (defprotocol IManageNodes (dom-insert [this parent anchor]) (dom-first [this])) (defprotocol IUpdatable (supports? [this next]) (dom-sync! [this next]))
(react/useState {:hello "world"}) deeply offend me(def init-state {:hello "world"}) and (react/useState init-state)inputs arrayuseValue hook that handles clojure equality for things like deps, but in practice I haven’t used it. https://github.com/Lokeh/hx/blob/master/src/hx/hooks.cljs#L108[:div.card {:on-click [::inc]} foo](useEffect foo [{:bar "baz"}])(let [ev-handler (react/useMemo #(handle-some-event clojure-data) #js [clojure-data])] ...)clojure-data is actually identical?useState or a callback functionidentical? works great. the latter case, there’s useCallback (gross but it’s a solution)const props = useSpring({opacity: 1, from: {opacity: 0}}) already sucknpm install handsontable @handsontable/react` and get the following errors
[:app] Build failure: The required JS dependency "core-js/library/fn/object/get-prototype-of" is not available, it was required by "node_modules/babel-runtime/core-js/object/get-prototype-of.js". Searched in:..../webapp/node_modules You probably need to run: npm install core-js/library/fn/object/get-prototype-of See:Did someone face the same problem ?
core-js libnode_modules/core-js/package.jsonnode_modules/@handsontable/react/package.json depends oncore-js version that the table thing wants to your own package.json dependenciesnode_modules/core-js/package.json is actually the correct version you wantnode_modules/core-js mattersbabel-runtime too[:app] Build failure: The required JS dependency "core-js/modules/es.object.get-own-property-descriptor" is not available, it was required by "node_modules/handsontable/commonjs/index.js". Searched in:/..../webapp/node_modules You probably need to run: npm install core-js/modules/es.object.get-own-property-descriptor See:`
mkdir my-app npm init npm i -D shadow-cljs npx shadow-cljs initOpen up the
shadow-cljs.edn file in Emacs, then add a basic build for whatever platform I need. e.g. a browser build: https://shadow-cljs.github.io/docs/UsersGuide.html#target-browsernpm i react react-dom create-react-classshadow-cljs server), and have my build running (using node target/output.js), I can connect and interact with the REPL with CIDER. However, all output (e.g. from println) goes to the node process instead of the REPL. Is there any way I can force output to go to the REPL for debugging?const Portis = require('@portis/web3');
->>
(:require ["@portis/web3" :as Portis])
["@portis/web3/es" :default Portis] it works"browser": "umd/index.js", https://docs.npmjs.com/files/package.json#browserbrowser or main. You can configure it to use module instead but that has .. issues .../es version works just use thatshadow-cljs.edn I have :exports-var foo/handler and :output-to foo.js
My source file is src/foo.cljs which defines a single-segment namespace foo.
My package.json contains "name": "foo".
To deploy the lambda I zip up foo.js, node_modules, and package.json into foo.zip.
In AWS my lambda is configured with the handler foo.handler.
However, when I run it I see this in the Cloudwatch logs:
START RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc Version: $LATEST
Unable to import module 'foo': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at /var/task/foo.js:522:273
at shadow$umd$export (/var/task/foo.js:5:22)
at Object.<anonymous> (/var/task/foo.js:9:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
END RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc
REPORT RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc Duration: 33.06 ms Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 76 MB
What am I missing?foo.js. So it's something in the contents of the compiled output that is wrong.:exports {:handler foo/handler}:exports-var would be :exports-var foo/exports and then in (ns foo) (def exports #js {:handler handler})(js/require "foo")?:preloads, here’s my config:
{:deps true
:nrepl {:port 9000
:middleware [cider.nrepl/cider-middleware
cider.piggieback/wrap-cljs-repl]}
:builds
{:stories {:target :npm-module
:module-loader true
:output-dir "out/stories"
:devtools {:preloads [some.namespace.i.want.loaded.first]}}}}
println in it which I assume I should see when the page loads:preloads are not supported for :npm-module. shadow-cljs can't tell which namespace you are going to load so it can't tell which namespace it has to load before that.storybook/config.js file.babelrc into the output dir so it doesn't process with babel at allout dir.storybook dir https://github.com/shadow-cljs/examples/blob/master/cljs-storybook/.storybook/.babelrc.storybook/webpack.config.js with the following:
module.exports = async ({ config }) => {
config.module.rules = [];
return config;
};
binaryage/devtools to work. According to the shadow-cljs user manual, if I understand correctly, all it should take is adding the dependency. It isn’t installed then though in my react-native target, and when I try to force it (`(devtools/install!)`) it says it is not installing under advanced builds. But I’m just running watch, so that should not be an advanced build, right? Any ideas?devtools/install that I have in there. 🤔:browser target. I'm not sure if react-native even supports it at allinstall or reference the devtools at all ... just add :devtools {:preloads [devtools.preload]}:advanced, but I think I may have to look up in the cljs-devtools sources what kind of check they are doing for that.devtools.version namespace is not present in your case, advanced build check assumes it gets mungedmetro actually processes all the sources before they get loadedreact-native target doesn't support preloads at alljs.js:133 Uncaught ReferenceError: regeneratorRuntime is not defined
at rete.common.js:418
at rete.common.js:415
at Object.shadow$provide.module$node_modules$rete$build$rete_common (rete.common.js:396)
at Object.shadow.js.jsRequire (js.js:122)
at Object.shadow.js.require (js.js:158)
at com.wsscode.wise.client.ui.rete.core.js:5, I guess it may be some webpack polyfill, not sure, is there any way around it?lein-install?deps.edn, its local deps support works with shadowlein-shadow is a 3rd party project I have no control over and no it does not read that config:dependencies listed there?project.cljshadow-cljs cmd. you only lose functionality by moving to lein-shadow and gain absolutely nothing (IMHO):dependencies would that bloat my production build?:dependencies have no affect on the build size:browser targets always check the build reports https://shadow-cljs.github.io/docs/UsersGuide.html#_build_reportrelease build. no need to compile it yourselfrelease builds yesrelease first will actually make the build report faster(shadow/release) to tell it to use simple/none optimizations?release cache:none is not possible. otherwise just set the usual :compile-options {:optimizations :simple}(shadow/release {:compile-options {:optimizations :simple}}) ?release options and not in the config itself use (shadow/release :build-id {:config-merge [{:compiler-options ...}]}):compiler-options {:source-map true}:foreign-libs which shadow-cljs doesn't support:externs ["datascript/externs.js"] in your :compiler-options:refer (That Icon) then that has no effect(:require ["@fortawesome/free-solid-svg-icons" :as solid-icons]) solid-icons/faCircle
["@fortawesome/free-solid-svg-icons" :as solid-icons] only that matters. there is no DCE for npm packages(:require ["@fortawesome/free-solid-svg-icons" :as solid-icons])it imports an
index.js file. If I were to do this:
(:require ["@fortawesome/free-solid-svg-icons/faCoffee" :as fa-coffee])it'd import
faCoffee.js?["@fortawesome/free-solid-svg-icons/faCoffee.js" :as fa-coffee] also works if you want to be sure 😉faCoffee.js only contains one icon:closure------ WARNING #9 -------------------------------------------------------------- File: node_modules/react-dom/cjs/react-dom.production.min.js:176:316 unreachable code --------------------------------------------------------------------------------
class. do you have an actual example where this fails? which class?Rete.Control isn't an actual ES6 class if you used the npm version?var Control =
/*#__PURE__*/
function () {
function Control(key) {
_classCallCheck(this, Control);
_defineProperty(this, "key", void 0);
_defineProperty(this, "data", {});
_defineProperty(this, "parent", null);
if (this.constructor === Control) throw new TypeError('Can not construct abstract class');
if (!key) throw new Error('The key parameter is missing in super() of Control ');
this.key = key;
}
_createClass(Control, [{
key: "getNode",
value: function getNode() {
if (this.parent === null) throw new Error('Control isn\'t added to Node/Input');
if (this.parent instanceof Node) return this.parent;
if (!this.parent.node) throw new Error('Control hasn\'t be added to Input or Node');
return this.parent.node;
}
}, {
key: "getData",
value: function getData(key) {
return this.getNode().data[key];
}
}, {
key: "putData",
value: function putData(key, data) {
this.getNode().data[key] = data;
}
}]);
return Control;
}();
<script src=""></script>
<script src=""></script>
<script src=""></script>class in that packageReflect way with a rewritten class like that it won't workrete package only contains babel-rewritten codebuild/rete.esm.js file but thats still rewritten by babel and not ES6 code.min usage as well, also suggesting usage of ES6 classeasafunction _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}Reflect.setPrototypeOf(B.prototype, A.prototype) and stufffunction _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
(fp/defsc ReteEditor
[this {::keys []}]
{:pre-merge (fn [{:keys [current-normalized data-tree]}]
(merge {::editor-id (random-uuid)} current-normalized data-tree))
:ident [::editor-id ::editor-id]
:query [::editor-id]
:componentDidMount (fn []
(go-catch
(let [container (gobj/get this "editorContainer")
editor (js/Rete.NodeEditor. "(def NumControl
(js-class
{::extends js/Rete.Control
::constructor (fn [emitter key readonly]
(let [this (js-this)]
(.call js/Rete.Control this key)
(gobj/set this "render" "react")
(gobj/set this "component" ReactNumControl)
(gobj/set this "props" {:emitter emitter :ikey key :readonly readonly})))}))(defn js-class [{::keys [constructor] :as definition}]
(let [c (or constructor (fn []))
proto (gobj/get c "prototype")]
(doseq [[k v] (dissoc definition ::constructor)]
(case k
::extends
(goog/inherits c v)
(gobj/set proto (name k) v)))
c))num-comp (new NumComponent)(defn NumComponent
{:jsdoc ["@constructor"]}
[]
(this-as this
(.call (js/Object.getPrototypeOf NumComponent) this "Number")
this))
(set! NumComponent -prototype
(js/Object.create r/Component.prototype
#js {:constructor
#js {:value NumComponent
:writeable true
:configurable true}
:builder
#js {:value
(fn [node]
(this-as this
;; do stuff
))}
:worker
#js {:value
(fn [node inputs outputs]
;; do stuff
)}}))
(js/Object.setPrototypeOf NumComponent r/Component)["regenerator-runtime/runtime"]
["rete" :as r].name seems to get assigned properlyUncaught TypeError: Object.getPrototypeOf(...).call is not a functionnew ns.NumComponent() on the console(.call (gobj/get (js/Object.getPrototypeOf NumComponent) "constructor") this "Number")(.call (gobj/get (js/Object.getPrototypeOf NumComponent) "constructor") this "Number") works, the way I'm seeing it, the constructor in NumComponent is a js value, which contains a value to NumComponent, how does that line figures the parent constructor and call it? its some JS magic going on inside?project.clj and use lein though[chromex] an error occurred during the call to chromex.ext.tabs/execute-script: Could not load file 'out/content-script.js' for content script. It isn't UTF-8 encoded.INTERNAL COMPILER ERROR :slightly_frowning_face:
I created a minimal reproduction in this repository: https://github.com/Dept24c/viz-min
The README has instructions on how to reproduce the error. Can anyone help me with this?(:require) in your ns formINTERNAL COMPILER ERROR typically is a closure ocmpiler issue:closure-output-charset to "US-ASCII"Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: qualified-keyword? in this context, compiling:(shadow/jvm_log.clj:74:10) when running shadow-cljs watch app? Specifically in regards to this issue: https://github.com/reagent-project/reagent-template/issues/166:lein true and the project.clj has clojure 1.10 specified so unless that's changed I'm not sure why shadow-cljs would start with a different version of clojure:main in [:builds :browser :modules] in the shadow-cljs.ednmain.js accordinglyfull.render.js file ... which is huge ... 1,9mb ...cljsjs package.
formerly when using cljsjs we had
(:require [cljsjs.fuse])
(.search
(js/Fuse.
js-coll
fuse-options)
query)
which in the past worked but when we changed it too
(:require ["fuse" :as fuse])
(.search
(js/Fuse.
js-coll
fuse-options)
query)
I've been getting the following error
ReferenceError: Fuse is not defined
at eval (eval at <anonymous> (), <anonymous>:3:1)
Any ideas of the issue?fuse instead of js/Fusejs/Fuse is accessing a global which doesn't exist. so just use the name you created via :as fuse instead.:as to :default to use it, depends on how the module is been exportedTypeError: Cannot call a class as a function
at e$jscomp$1 ()
When trying to create an object(new Fuse) or (Fuse.))(fuse. ...) not (fuse ...)shadow-cljs, but wanted to rule it out since it only happens in development.shadow-cljs, but since it's only in our dev environment and doesn not occur for QA or production builds I wanted to see if you've ever seen crashing like this. If not, don't worry about it, as it's most likely not our problem. :+1:lein new shadow-cljs your-project +reagent while prototyping with material-ui. It seems to happen whenever there's a very specific unknown error rendering components.material-ui is not yet in place in our production app where we see the most crashesgoog.require if a lot of memory is being used by the tab and crashing the browser if it tries to reference the required module. Some evidence to support this is that in the Chrome logs, it says (93)] mach_vm_read(0x7ffee0423000, 0x2000): (os/kern) invalid address (1) when the crash happens, and it seems like the crash happens after a GC happens, since when I monitor the JS memory usage, it goes up, then goes down, then crashes/Applications/Google\ Chrome --js-flags="--no-flush_bytecode" and let me know if you still run into this issue?:loader-mode :eval in our shadow-cljs configshadow-cljs compile vs watch? don't think that the websocket would be causing issues but who knows:optimizations :simple with a release build maybe?--js-flags="--no-flush_bytecode" flag. I’ll try a compiled version with simple optimizations now.:simple is pretty much the same as :advacned as far as the npm packages are concernedgoog.require’s cache of the node modules getting garbage collected somehow?Executable 'java' not found on system path..
I’ve added the heroku/[ruby nodejs java] buildpacks but I’m still missing the proper incantations. Anyone else run into this? Any resources or tips would be much appreciated. Thank you! :+1:rlwrap shadow-cljs cljs-repl app to connect to my app (running under react-native android alongside the Metro bundler I get a mysterious websocket error message. I feel like this wasn't always happening but remain unsure on the cause.shadow-cljs watch app --verbose and it'll tell you which IP it usedshadow-cljs watch app --config-merge '{:local-ip "123.123.123.123"}' or :local-ip ... directly in the build config"no source by provide: " exception info once the REPL appears to have connected.yarn run v1.12.3
$ rlwrap shadow-cljs cljs-repl app
shadow-cljs - config: /home/tom/dev/trm/rn-rf-shadow/shadow-cljs.edn cli version: 2.8.8 node: v8.15.0
shadow-cljs - connected to server
[4:1]~scout.dev-preloads=> (foo)
[:result {:type :repl/error, :ex #error {
:cause "no source by provide: scout.dev-preloads"
:data {:provide scout.dev-preloads}
:via
[{:type clojure.lang.ExceptionInfo
:message "no source by provide: scout.dev-preloads"
:data {:provide scout.dev-preloads}
:at [shadow.build.data$get_source_id_by_provide invokeStatic "data.clj" 182]}]
:trace
[[shadow.build.data$get_source_id_by_provide invokeStatic "data.clj" 182]
[shadow.build.data$get_source_id_by_provide invoke "data.clj" 179]
[shadow.build.data$get_source_by_provide invokeStatic "data.clj" 185]
[shadow.build.data$get_source_by_provide invoke "data.clj" 184]
[shadow.cljs.repl$process_read_result$fn__12538$fn__12539 invoke "repl.clj" 431]
[shadow.cljs.repl$process_read_result$fn__12538 invoke "repl.clj" 407]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 405]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 381]
[shadow.cljs.devtools.server.worker.impl$fn__13210 invokeStatic "impl.clj" 784]
[shadow.cljs.devtools.server.worker.impl$fn__13210 invoke "impl.clj" 745]
[clojure.lang.MultiFn invoke "MultiFn.java" 234]
[shadow.cljs.devtools.server.util$server_thread$fn__12888$fn__12889$fn__12897 invoke "util.clj" 292]
[shadow.cljs.devtools.server.util$server_thread$fn__12888$fn__12889 invoke "util.clj" 291]
[shadow.cljs.devtools.server.util$server_thread$fn__12888 invoke "util.clj" 264]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 748]]}}]
[4:1]~scout.dev-preloads=>
:repl-init-ns scout.dev-preloads whithout repeating said ns into the :preloads?:preloads doesn't currently work for :react-native{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8af9e2ebeee5fda7e9e6e0f9cab8a4b2a4b9bd"}, :content ("[email protected]")}. that should fix the :preloads related REPL issuescout.dev-preloads in both :repl-init-ns and :preloads, and after restoring it to the :preloads vector I can execute (foo 1 2) correctly from that namespace after the REPL connects. This looks very promising.sourcesContent array:maven {:repositories {...}} in shadow-cljs.edn//# sourceMappingURL=app.components.button.js.map I'd want it to be //# sourceMappingURL=build/app.components.button.js.map or smth, maybe it doesn't make sense?app.components.button.js.map is in the same directly as app.components.button.jsbuild/ is?sourceMappingURL are quite simple to webpack should find it properlyasync.map(missingSources, there should never be missing sources?map there?metro before.js file was loaded by the runtimemetro development servershadow-cljs.edn:
:dependencies [[binaryage/devtools "0.9.10"]
[cider/cider-nrepl "0.21.1"]
[cider/piggieback "0.4.1"]
[reagent "0.8.0"]]:Piggieback :app to get my vim-fireplace repl connection switched to cljsThe required namespace "cljsjs.prop-types" is not available, I think last times this has been fixed by just installing the appropriate npm package but the error sticks around(r/render [main-view] (.getElementById js/document "app")) again in that function and reagent.core/force-update-all, but the changes don’t seem to appear in the browser. Sorry if it’s more of a reagent question.(re-frame.core/clear-subscription-cache!) or so (in the after-load)r/render(defn ^:dev/after-load start
[]
(r/render [app]
(.getElementById js/document "app")))
(defn ^:export init
[]
(router/start!)
(rf/dispatch-sync [:initialise-db])
(start)):release portion of my shadow-cljs project and have noticed that the released artifacts are trying to connect to . I'm not sure why this is required and if not was wondering how to disable this, any ideas?release'd files to a different location than the dev's, however, I can take a look at the caching, that might be the issue{:main {:entries [foo.core]}
:service-worker {:entries [foo.sw]
:depends-on #{:main}
:web-worker true}}
kinda "works" because there is reload notification in a browser when code in foo.sw is updated. Of course nothing happens because service-worker.js is not included in a page. But at least there is a hope to hook into (defn handle-message [{:keys [type] :as msg}] or smth like that and run unregister/register code for service-worker. msg map has all info to get to know when foo.sw is recompiled.resources/public/js/extension and set the output-dir for the background script in resources/public/js/extension/background.
Compilation works, then I add the extension to chrome targeting resources/public/js/extension (where my extension manifest is).
The trouble is that now chrome is looking for the modules with /resources/ as root rather than resources/public/js/extension
So how can i ask shadowcljs (or maybe the clojurescript compiler?) to root the js lookup in resources/public/js/extension` ? but i want it to try loading .... which of course doesn't work, how can i tell it to use my already running server at ?:devtools-url "" in :devtools key of shadow-cljs.edn:output-type :chrome/page-action for the module[0:0]~cljs.user=> (eval '(+ 1 2)) Error: cljs.core/*eval* not bound
eval in CLJS requires using the self-hosted compiler. shadow-cljs does support building everything you need for that but doesn't run it itself. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html(def ...) formsVar creation via actual Var calls will not work even in self-hosted CLJS since there are no vars at runtime(crazy-macro foo {:a Int}) creates a var like foo-a. the problem is i want it to also support
(crazy-macro bar (merge foo {:b Int})) which means i need the evaluated version of the map.cljc file?.cljc is kinda mind bending when it comes to macros and stuff so I would recommend avoiding it as much as possible#?(:cljs (defmacro...) :clj (defmacro...)
&env#?(:clj (defmacro foo [& args] (if (:ns &env) :cljs :clj)))(foo 123) used in CLJS will end up just returning :cljs:clj if called in CLJ(ns the.ns #?(:cljs (:require-macros [the.ns]))) self-require for macrosthe.ns completely skip worrying about macros and just use them as you would in CLJ(ns (:require [the.ns :as x])) (x/foo) worksbinaryage/devtools selectively in some of my :browser targets?:devtools {:console-support false}(require '["@material-ui/core" :as x]) and it seems like toolbar is empty. Anyone with any tips on how I can "find the bug"?(require '["@material-ui/core/Toolbar" :as raw-Toolbaw])
Then
(def Toolbar (.-default raw-Toolbar))toolbar supposed to be? your example only defines x? ["@material-ui/core/Toolbar" :default tool-bar]. I installed material-ui with npm and got it working. The other material ui components that I require looks like this #Object[WithStyles] but Toolbar is just empty #js {}.shadow-cljs.edn files with shadow-cljs release app. They are run one after the other too:default, you should probably try :as tool-bar instead. :default is currently in a weird situation. https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports:jvm-opts ["-Xmx3G"] into your shadow-cljs.edn(:require
["@material-ui/core" :as mui]))
(defn header []
[:> mui/AppBar {:position "static"
:color "primary"
:style {:background-color "#43a047"}}
[:> mui/Toolbar
[:> mui/Typography {:variant "h6"
:color "inherit"}
"BH"]
[:> mui/Button {:color "inherit"} "Login"]]])
(defn app []
[:div
[header]])
["@material-ui/core/Button" :default button]
["@material-ui/core/Switch" :default switch]
["@material-ui/core/Textfield" :default textfield]
["@material-ui/core/FormControl" :default form-control]
["@material-ui/core/FormControlLabel" :default form-control-label]
["@material-ui/core/InputLabel" :default input-label]
["@material-ui/core/Typography" :default typography]
["@material-ui/core/Select" :default select]
["@material-ui/core/MenuItem" :default menu-item]
["@material-ui/core/Dialog" :default dialog]
["@material-ui/core/DialogTitle" :default dialog-title]
["@material-ui/core/Paper" :default paper]
["@material-ui/core/styles" :rename {withStyles with-styles}]
["@material-ui/icons/Add" :default add]module$node_modules$$material_ui$core$Paper$Paper(:require ["@material-ui/core/AppBar" :default AppBar])
(:require
["@material-ui/core/AppBar" :default app-bar]
["@material-ui/core/Toolbar" :default tool-bar]
["@material-ui/core/Button" :default button]
["@material-ui/core/Typography" :default typography]
["@material-ui/core/Menu" :default menu]
[reagent.core :as r]))
(defn header []
[:> app-bar {:position "static"
:color "primary"}
[:> tool-bar
[:> typography {:variant "h6"
:color "inherit"}
"App-Title"]]])
(defn app []
[:div
[header]])
updated to this[com.google.javascript/closure-compiler-unshaded "v20190325"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]😄 ...
shadow-cljs release and I'm not sure what is causing it. shadow-cljs watch still works fine.lein with-profiles +cljs deps :tree[com.google.javascript/closure-compiler-unshaded "v20190325"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
[thheller/shadow-cljs "2.8.36"]
[com.bhauman/cljs-test-display "0.1.1"]
[com.cognitect/transit-clj "0.8.313"]
[com.cognitect/transit-cljs "0.8.256"]
[com.google.javascript/closure-compiler-unshaded "v20190325"]
[com.wsscode/pathom "2.2.7" :exclusions [[org.clojure/data.json] [fulcrologic/fulcro] [camel-snake-kebab]]]
[com.wsscode/spec-inspec "1.0.0-alpha2"]
[edn-query-language/eql "0.0.3"]
[thheller/shadow-cljs "2.8.36"] -> [org.clojure/google-closure-library "0.0-20190213-2033d5d9"] -> [org.clojure/google-closure-library-third-party "0.0-20190213-2033d5d9"]
:modules config? the exception looks like something isn't quite right with the modules:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:build-hooks [(gsv.api.mutations/recalc)]
:modules {:shared {:entries []}
:web-shared {:entries []
:depends-on #{:shared}}
:worker-shared {:entries []
:depends-on #{:shared}}
:app {:entries [gsv.client]
:depends-on #{:web-shared}}
:fetch-worker {:entries [gsv.fetch-worker]
:depends-on #{:worker-shared}
:web-worker true}
:filter-worker {:entries [gsv.filter-worker]
:depends-on #{:worker-shared}
:web-worker true}}
:shared at the very leasttargetModule is null which shouldn't really happen/**
* Finds the deepest common dependency of two modules, including the
* modules themselves.
*
* @param m1 A module in this graph
* @param m2 A module in this graph
* @return The deepest common dep of {@code m1} and {@code m2}, or null if
* they have no common dependencies
*/
public JSModule getDeepestCommonDependencyInclusive(:shared dependeny to all :modules maybe?:app {:entries [gsv.client] :depends-on #{:web-shared :shared}}src/ and tests under test/ and I added them both to source-paths but yarn shadow-cljs compile test just doesn't find the test namespace under test/. All seems to work fine and the test namespace is found when I move the test namespace under src. Here's my shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths ["src" "test"]
:deps true
:builds
{:flex-cli {:target :node-script
:output-to "target/main.js"
:main sharetribe.flex-cli.core/main}
:test {:target :node-test
:output-to "target/tests.js"
:autorun true}}}
And when I run yarn shadow-cljs compile test it doesn't find any tests:
➜ flex-cli git:(master) ✗ yarn shadow-cljs compile test yarn run v1.9.4 warning package.json: No license field $ /Users/mikko/Documents/Projects/sharetribe/flex-cli/node_modules/.bin/shadow-cljs compile test shadow-cljs - config: /Users/mikko/Documents/Projects/sharetribe/flex-cli/shadow-cljs.edn cli version: 2.8.37 node: v10.11.0 shadow-cljs - starting via "clojure" [:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (27 files, 1 compiled, 0 warnings, 1,63s) ✨ Done in 10.35s.The test file under
test/sharetribe/flex-cli/hello_world_test.cljs looks like this:
(ns sharetribe.flex-cli.hello-world-test (:require [cljs.test :refer-macros [deftest is]])) (deftest failing (is (= "hello" "world")))So what I'm expecting is that the
yarn shadow-cljs compile test would find and run the test which should fail. What I actually see is that the compile doesn't find the test.
Any tips what am I doing wrong or how to debug further? Thanks!:deps true was the reason here. Turning it to false fix it and now the test is found.:paths in deps.edn:deps true the :source-paths from shadow-cljs.edn do not apply and only use the ones defined in deps.ednshadow-cljs check app to get some insights into which externs are missingcheck isn't super useful because of the noise it reportstick/core.cljc ns:compiler-options {:output-feature-set :es8} or :es2018-Sdeps when using :deps true?shadow-cljs compile app is the same as clj -m shadow.cljs.devtools.cli compile appclj -Sdeps ... -m shadow.... worksnet::ERR_INSUFFICIENT_RESOURCES. Developing a project with material-ui.:compiler-options {:optimizations :advanced} is doing the trick for release, but seems to have no effect on dev.blah.bleh.integration.core-test
blah.bleh.unit.core-testfor some reason the regex is not working and all tests are being ran. Any help appreciated
:loader-mode :eval seems to have done the trick, as per: https://clojureverse.org/t/any-chance-we-could-reduce-the-bundle-size-in-development/3690/2(:require [reagent.core :as r :refer [atom]]
["@material-ui/core" :as mui]
["@material-ui/core/styles" :refer [createMuiTheme]]
["@material-ui/core/colors" :as mui-colors]
["@material-ui/styles" :as mui-styles]
["@material-ui/icons" :as mui-icons]
["@material-ui/system" :as mui-system]):react-native target doesindex.js or so?index.js you require("./foo/your.app")?if (process.env.NODE_ENV == "development") { require("./foo/shadow.cljs.devtools.client.react-native"); }:runtime :react-native:npm-module just doesn't have clearly defined entries so it can't add :preloads:react-native target btw:npm-module in development):npm-module build with a generated index.jsindex.js directlyindex.js for haul and require("./foo/index.js") from thereshadow.user> (shadow.cljs.devtools.api/nrepl-select :app) To quit, type: :cljs/quit [:selected :app] cljs.user> :a REPL command timed out. cljs.user> :a REPL command timed out.it connects, but times out, never actually used the nrepl with metro/vanilla-react-native so I don't know what to expect 🙂
react-native log-ios or whatever that command was called2019-05-22 20:35:35.535 10517-11493/com.hlolli W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{:type :repl/invoke, :name \"<eval>\", :js \"new cljs.core.Keyword(null,\\\"a\\\",\\\"a\\\",-2123407586)\", :source \":a\", :source-map-json \"{\\\"version\\\":3,\\n \\\"file\\\":\\\"<eval>\\\",\\n \\\"sources\\\":[\\\"<eval>\\\"],\\n \\\"lineCount\\\":1,\\n \\\"mappings\\\":\\\"\\\",\\n \\\"names\\\":[],\\n \\\"sourcesContent\\\":[\\\":a\\\"]}\\n\", :warnings [], :id 2}","type":"text","id":2}])
demo to work with msys2?:react-native target works seems to be the only one thats reliable enough. the re-natal/figwheel-bridge approach also works ok-ish but the problem I found with that is that initialization becomes async. so you have to render a temporary "app is loading" component and then swap in the real one once it is loadedreact-native-navigation as far as I understand it(:require ["./multisig-abi.json" :as multisig-abi]) ?JSON.parse from javascript would help? It would give you a js object which you can pass through js->clj if needed.def/my/local/lib.js which requires /my/local/dep.js is preloaded onto . when /my/local/lib.js tries to load /my/local/dep.js, it does so as .
apologies if that’s a bit confusing. please let me know if so and I can clarify. if anyone has any ideas for how to solve this besides just programming w/ advanced mode turned on, I’m all ears:single-file bundle option for node scripts but I think he ran into some blockers:devtools {:loader-mode :eval} which creates a single file. you'll need to use the :target :browser though since :node-script isn't really the correct target for webviews. see https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518Cursive for development and have been trying to integrate it with shadow-cljs. I have followed the instructions to connect to the nrepl port via a remote repl. I am able to do this succesfully, however when the repl is spun up and I try to run js/alert I get an error. Any ideas?:app build(shadow/repl :app)shadow-cljs.edn. You can run shadow-cljs pom to generate a pom.xml and import that using the IntelliJ.shadow-cljs pom manually, but that's it. The re-import will happen automatically.(js/goog.globalEval ...) though(js/eval ...) never gets JIT optimized so it runs substantially slower. js/goog.globalEval should be okthheller/shadow-cljs {:mvn/version "2.8.37"} in deps.edn file when using shadow-cljs with Clojure Deps and CLI? I am using npx shadow-cljs watch main command for compilation.ring-core but excludes clj-time[ring/ring-core "1.7.1"
:exclusions
;; used by cookie middleware which we don't use
[clj-time]]cookies.clj which is probably from ringclj -Stree:cljs (or so) alias:dev alias. with CLJS and binaryage/devtools.clj-time dep manuallydefonce to prevent declaring multiple times. The second time it will reuse the same atom. Might also fix the starting multiple go-loops. Something else to watch out for is having functions executed instead of only defined. So reloading will just update functions and nothing else.defonce a try. Not sure I follow the bit about functions executed vs defined on "reload" (does "reload" mean browser reload? or save in editor? or both?)(start-loop "foo" "bar") somewhere but then you start a new loop each time the code reloads. So you want to either start it by some action, or in some file that is not reloaded.cider-connect-sibling-cljs?npx shadow-cljs watch main?
Because I have already running this command in another shell before runnning cider-connect-sibling-cljs.react-native and/or metro do not support loading code dynamicallyrequire so no cljs :modules would not work for thatSHADOW import error /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/app/cljs-runtime/app.server.js
/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539
throw new TypeError('Line must be greater than or equal to 1, got '
^
TypeError: Line must be greater than or equal to 1, got null
at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539:13)
at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:604:22)
at mapSourcePosition (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:199:42)
at wrapCallSite (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:343:20)
at /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:378:26
at Array.map (<anonymous>)
at Function.prepareStackTrace (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:377:24)
at process.emit (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:431:52)
at process._fatalException (internal/process/execution.js:123:25)
Maximum call stack exceeded:compiler-options {:source-map false} disables them(:require ["mqtt/dist/mqtt" :as mqtt]) insteadprocess comes from in browser buildsprocess.nextTick doesn't existprocess in browser buildslein new luminus demo-app +kee-frame +shadow-cljs
when running lein shadow watch app throws:
------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/pk/.m2/repository/thheller/shadow-cljs/2.8.37/shadow-cljs-2.8.37.jar!/shadow/cljs/devtools/client/hud.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.cljs.devtools.client.hud -------^------------------------------------------------------------------------ Invalid :refer, var cljs.core.async/go does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [shadow.dom :as dom] 4 | [shadow.xhr :as xhr] 5 | [shadow.animate :as anim] --------------------------------------------------------------------------------the error happens deep inside shadow-cljs lib. I'm new to clojure so I'm not sure how to approach this - do I have any chance of debugging this or should I just try different lib/versions?
[org.clojure/core.async "0.4.490"] or higher[kee-frame "0.3.3" :exclusions [metosin/reitit-core org.clojure/core.async]] [org.clojure/core.async "0.4.490"]and it worked! Thank you!!
[org.clojure/clojurescript "1.10.520" :scope "provided"] in generated project.clj which, according to https://clojurescript.org/ , is the current version.shadow-cljs - failed to load 15 shadow-cljs - failed to load 20 SCRIPT5009: 'Set' is undefined SCRIPT5009: '<primary ns>' is undefinedCan’t be sure if this is specific to Shadow or not and haven’t done much digging quite yet, but curious if anyone has seen this.
failed to load <#> console warnings{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d4a7bcb5b0bba3f9b7b8bea794e6faecfae7e3"}, :content ("[email protected]")}Set is only supported in IE11 and above:deps true does this mean the clj and cljs sides are sharing the same dependencies?:cljs alias or so in deps.edn or you could just keep CLJS deps in shadow-cljs.edn:deps {:aliases [:cljs]} and a :cljs alias in deps.edn is OK if you want to keep all dependencies in one place[dali "0.7.4"] library, including it in the dependencies causes the error
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source) at shadow.build.classpath$pom_info_for_jar.invokeStatic(classpath.clj:355) at shadow.build.classpath$pom_info_for_jar.invoke(classpath.clj:346) at shadow.build.classpath$find_jar_resources_STAR_.invokeStatic(classpath.clj:439) at shadow.build.classpath$find_jar_resources_STAR_.invoke(classpath.clj:427) at shadow.build.classpath$find_jar_resources.invokeStatic(classpath.clj:554) at shadow.build.classpath$find_jar_resources.invoke(classpath.clj:528) at shadow.build.classpath$find_resources.invokeStatic(classpath.clj:608) at shadow.build.classpath$find_resources.invoke(classpath.clj:600) at shadow.build.classpath$index_path_STAR_.invokeStatic(classpath.clj:839) at shadow.build.classpath$index_path_STAR_.invoke(classpath.clj:836) at clojure.lang.PersistentVector.reduce(PersistentVector.java:343) ....
xerces/xercesImpl {:mvn/version "2.12.0"} to the deps list fixed the startup - although I haven't tried using the librarydali and the error still came upError in phase :compile-syntax-check FileNotFoundException: Could not locate clojure/core/match__init.class, clojure/core/match.clj or clojure/core/match.cljc on classpath.
core.match is in your deps.edn?(start) fn which is in my source paths, but I’m unable to resolve the symbol{:source-paths ["dev/server" "src/client"]
:deps {:aliases [:dev]}
:nrepl {:port 9000}
:builds {:main {:target :browser
:output-dir "resources/public/generated/js/dev"
:asset-path "/generated/js/dev"
:modules {:main {:entries [admin.core]}}
:devtools {:http-port 3000
:preloads [devtools.preload
fulcro.inspect.preload]}}}}
(ns user)dev/server/user.clj2.8.38. should work nowError: Error downloading
process.nextTick is not a function
at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)
TypeError: process.nextTick is not a function
at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
at new Promise (<anonymous>)
at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)
Error: Error downloading
process.nextTick is not a function
at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)
TypeError: process.nextTick is not a function
at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
at new Promise (<anonymous>)
at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)
:preloads already deal with thatns-a/A , ns-b/b, ..... ns-z/Z.ns-a to ns-z.cljs files from your config and just compile that file normally:modules {:app {:init-fn webman.core/init :entries [webman.page.foo webman.page.bar]}}(ns webman.page.foo (:require [some.registry :as reg])) (reg/add-page ::foo {:bla "blubb"}):app entries ?:configure stage, right ?(ns app.main (:require [foo.bar])) with all the namespaces you are trying to dynamically addclj-run feature to generate it so shadow-cljs run webman.generate path/to/config.edn path/to/output.cljsclj directly. no need to involve shadow-cljsUse of undeclared Var cljs.core/destructure-map on compiles today?[datascript.transit :as dst] the namespace compiles fine, but when i try to make use of it, it says datascript.transit is null... which it is : (log js/datascript.transit) indeed is null, while (log js/datascript) has the whole datascript namespaces showing2.8.39If your project uses React 16 and Reagent 0.8.0-alpha2 (or higher) then you will need to add the qualifier -react16 to the version, e.g. [day8.re-frame/re-frame-10x "VERSION-react16"]
shadow-cljs.edn
... :dependencies [[day8.re-frame/re-frame-10x "0.4.0-react16"]] ...
cli version: 2.8.37 node: v12.3.1 shadow-cljs - updating dependencies shadow-cljs - dependency update failed - Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central () DependencyResolutionException Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central () org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:355) sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:498) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28) cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:806) cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:707) clojure.core/apply (core.clj:657) clojure.core/apply (core.clj:652) cemerick.pomegranate.aether/resolve-dependencies (aether.clj:815)
re-frame-10x. If I ignore the -react16 qualifier I can see the re-frame-10x panel but it is not reflecting the info in the app-db, it is just emptyutil and stream.util and stream are among the packages that have automatic browser polyfills so I'm not exactly sure what you are asking?:js-options {:js-provider :shadow
:resolve
{"process"
{:target :global
:global "window.process"}
"util"
{:target :global
:global "window.util"}
"stream"
{:target :global
:global "window.stream"}
"buffer"
{:target :global
:global "window.buffer"}
"string_decoder"
{:target :global
:global "window.string_decoder"}
"events"
{:target :global
:global "window.events"}
"crypto"
{:target :global
:global "window.crypto"}
"querystring"
{:target :global
:global "window.querystring"}
"url"
{:target :global
:global "window.url"}}}
:resolve completely and tell me the error you get 😛C:\Users\Devo\source\repos\compiler_repro>npx shadow-cljs compile main shadow-cljs - config: C:\Users\Devo\source\repos\compiler_repro\shadow-cljs.edn cli version: 2.8.39 node: v10.5.0 WARNING: The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility. [:main] Compiling ... The required JS dependency "process" is not available, it was required by "node_modules/prop-types/checkPropTypes.js". Searched in:C:\Users\Devo\source\repos\compiler_repro\node_modules You probably need to run: npm install process See:
shadow-cljs dependency in the projectshadow-cljs in your package.jsonnode-libs-browser dep which is missing here[:main] Compiling ... Closure compilation failed with 1 errors --- node_modules/n3/lib/N3DataFactory.js:45 Multiple classes cannot share the same name.
ReferenceError: $cljs$cst$keyword$pro_SLASH_review$$ is not definedthe
:pro/review keyword is also used in another module. if I rename that keyword (in the other module), then this error goes away and I get the same error with another similarly-used keyword.:depends-on, do you have to list all the transitive dependencies?:depends-on of my root module:depends-on yesnode script.js it gives following error. I've puppeteer in package.json and installed with npm install.script.js? ie. /home/maverick/Desktop/automat/node_modules/puppeteer?Error: Cannot find module 'puppeteer' thats the node error for missing packagespuppeteer-core but was requiring puppeteer.leinUncaught Error: browser bootstrap used in incorrect target(js/console.log "foo") any one know what causes this error?2.8.39? geom library from here: https://github.com/thi-ng/geom
I have added {:mvn/version "0.0.908"} in my deps.edn and just included [thi.ng.geom.webgl.core :as gl] in require section of one of my cljs file.
I get the following compilation error:
Status X Compilation failed. ------ ERROR ------------------------------------------------------------------- File: jar:file:/home/user/.m2/repository/thi/ng/geom-webgl/0.0.908/geom-webgl-0.0.908.jar!/thi/ng/geom/webgl/core.cljs:628:40 -------------------------------------------------------------------------------- 625 | (let [ctx (.getContext canvas (first ids) attribs)] 626 | (set! (.-onselectstart canvas) (constantly false)) 627 | (if ctx ctx (recur (next ids)))) 628 | (catch js/Error e (recur (next ids))))))] ----------------------------------------------^--------------------------------- Error in phase :compilation Can't recur here at line 628 thi/ng/geom/webgl/core.cljs -------------------------------------------------------------------------------- 629 | (or ctx (err/unsupported! "WebGL not available"))))) 630 | (defn clear-color-buffer 631 | [^WebGLRenderingContext gl r g b a] 632 | (.clearColor gl r g b a) --------------------------------------------------------------------------------
WARNING in ./cljs-out/cljs-lib.js 70:56-63
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./calva/nrepl/jack-in.ts
@ ./calva/extension.ts
(`jack-in.ts`) is the first place where the cljs-lib is imported)
Then the extension fails to load with the following message: Activating extension 'betterthantomorrow.calva' failed: ENOENT: no such file or directory, open '/.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/goog.debug.error.js'.I’m a bit stumped on what could be going on here. Anyone else with an idea?
shadow-cljs release, (e.g. compile or watch). With release things are dandy.:npm-module target. But that has proven not to work for Calva builds. (Or, at least, didn’t work last time I tried it.):npm-module. no other way around it(ns app.common.CenteredContainer
(:require
[reagent.core :as r]
["@material-ui/core/Grid" :default Grid]
))
(defn centered-container
[props & children]
[:> Grid (merge {:container true
:spacing 0
:direction "column"
:alignItems "center"
:justify "center"
:style {:minHeight "80vh"}} props)
children])
(def CenteredContainer (r/reactify-component centered-container))
And I get this error in the Cursive CLJS REPL:
Syntax error macroexpanding clojure.core/ns at (CenteredContainer.cljs:1:1). ((:require [reagent.core :as r] ["@material-ui/core/Grid" :default Grid])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-formWhen I remove the Material-UI require, I can then send forms to the REPL just fine, but if I have it, I get the above error. Using VS Code Calva I can interact with the in-editor REPL just fine. Maybe this is a question for #cursive ? Thought I'd try here though since it sounds like this might be specific to Shadow CLJS? Thanks!
ns in a CLJ REPL rather than a CLJS REPL(shadow/repl :your-build-id). that will also automatically switch the select box(shadow/repl :your-build-id):socket-repl {:port 1234} in shadow-cljs.ednshadow.loader.mm.moduleInfoMap is it emptySHADOW_ENV.load({}, ["book.demos.dynamic_ui_main.js","shadow.module.ui-main.append.js"]);
shadow.loader before it was initiated:init-fn as intended it won't be a problemYou only need to add :module-loader true to your build config. The loader will always be injected into the default module (the one everything else depends on).
:init-fn which ensures that doesn't happen(shadow.loader/init "") manually wherever your init happens?@font-faceThe required JS dependency "process" is not available, it was required by "node_modules/prop-types/checkPropTypes.js".The peculiar thing is that in an old project,
prop-types is also used by some library, but it works fine.if (process.env.NODE_ENV !== 'production') {.
I think process.env is available only for nodejs targets, not for browser targets. And yet the old project somehow works.shadow-cljs in the project.shadow-cljs as a dev dependency?node_modules, ran npm i --production=true, and finally shadow-cljs release main.
It gave me the same error about missing process.npm i --production=truenpm i --production=trueproduction=true is only for runtime for node apps, nothing that requires building will ever work with thatnpm i --production=true
lein yada-yada-yada. Or via the code, in my case: juxt/kick.apha - we've talked about it some time ago.
> having shadow-cljs installed in the project was pretty much ALWAYS required
So ideally, we should have 3 scopes instead of just prod and dev: running in production, running in development, building. And the shadow-cljs dependency would fit only in the building scope, right?process)shadow-cljs as a dev dependency doesn't mean that it's useful only during the development.
So in my case, I'll probably just move it to the main list of dependencies, to make the dev list contain only the things that are not even supposed to be downloaded for the production build.shadow-cljs release is still a development thing. only the output is a production thing.shadow-cljs release is still a development thing
So the production image building process is considered a development step? And "production" is only "running the production build"?
See, that's why the three hypothetical scopes are still somewhat useful. I guess it's just profiles in terms of lein/`deps.edn`, but AFAIK package.json doesn't support anything like it.
I just remembered another point towards not downloading dev dependencies during the production build. Apart from the saved space, it's also a safeguard against including something dev in the production env.deps.edn you can't build an uberjar without some kind of dev dependencynode_modules folder anywaysnode_modules folder anyways
> doesn't matter whats in it
Yes, I realize that. But I don't quite realize how that could ever work without profiles and without dead code elimination.
So, generally speaking, how does that even work in the browser JS world? Suppose I have some... I don't know, React debugging library that must be built into the application code in order to work. Obviously, you don't want to use it in production at all.
But at the same time, if you have to use dev dependencies during the release image build process, how do you prevent that debugging library from ending up in the production code?if (process.env.NODE_ENV !== 'production') { comes into playif ("development" !== 'production') {requirements.txt. Since there are no scopes and profiles anywhere, people just write multiple files with all kinds of suffixes, and then write scripts to use different files in different environments.import() is even more fun ..node_modules and nothing ever imports that library, it won't end up in the release JS files even if DCE is not used?.jar filedeps.edn and never use it, it will still be there.copy-webpack-plugin thay copies over static assets to the output directory? I want to put some ES6 node_modules during build over there(ns alexandria.core
(:require
[reagent.core :as reagent ]
[re-frame.core :as rf ]
[day8.re-frame.http-fx]
[alexandria.events]
[alexandria.subs]
[alexandria.routes :as routes]
[alexandria.views :as views]
)
)
(defn main-panel
[]
[:h1 "Alexandria"]
; (let [active-panel (rf/subscribe [:active-panel])]
; [views/show-panel @active-panel]
; [:div [:h2 "Alexandria "]]
; )
)
(defn mount-root
[]
(rf/clear-subscription-cache!)
(println "mounting root")
(reagent/render [main-panel]
(.getElementById js/document "app")
))
(defn ^:export init
[]
; (routes/app-routes)
(println "Initializing")
(rf/dispatch-sync [:initialize-db])
(mount-root)){:devtools {:after-load alexandria.core/mount-root}} ?after-load) configured to re-render your app? https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooksmount-root in the above examplewatch I presume?(shadow.cljs.devtools.server/reload!)touch src/foo/bar.cljs?:cache-blockers(ns ^:dev/always foo.bar)-->
(require '["basicchart" :as bc :refer (BasicChart)])
-->
-->
bc
-->
#js {...}
-->
-->
BasicChart
-->
nil
-->
(require '["/name.js" :as n :refer (Component)]) gives me the same result. Their code comes in both es and cjs versions, the cjs seems to load, but shadow throws an exception when I try to require the es version directly.Component is in object:Component in the #js {…}println)(.-Component n):refer to"basicchart/BasicChart" or if it’s using the ES module it might be behind a default keyException in thread "async-thread-macro-9" java.lang.RuntimeException: java.lang.Exception: Not supported: class clojure.lang.ExceptionInfo... 20 more seems top be cutting of the relevant parts?(js/console.dir x) is probably the most useful thing. I've seen JS packages that only have one default export and add properties onto thatdefault property you might find what you are looking for therecljclj -A:foo shadow.cljs.devtools.cli watch app{:builds {:dev {:deps/aliases [:dev] ...} ...}}shadow-cljs -A:foo watch app:devclj directlynpx shadow-cljs server. I'm triggering it by doing the (require ...) in the browser based repl that server provides.shadow-cljs browser-repl instead, the web interface might not route some output properly maybe(gen/generate (s/gen ::open?)) Error: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
clojure.test.check.generators?:devtools {:after-load alexandria.core/mount-root
:http-root "/"
}
in my shadow-cljs/ is definitely not correct/public?public in your project dir?//?/:watch-dir "public":http-root does nothing if you don't actually use that webserver{:http-root "public"} to {:watch-dir "public"} but still no joypublic/css/foo.css with your css file included in the HTML via <link rel="stylesheet" href="/css/foo.css">?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e0928f8486928599a0ad8183a28f8f8bcdb0928fce888994928f8e889582ce888f8d85"}, :content ("[email protected]")}<html>
<head>
<script src="/js/main.js"></script>
<script src=""></script>
<link rel="stylesheet" type="text/css" href=""></link>
<link rel="stylesheet" type="text/css" href="/css/alexandria.min.css"></link>
<meta charset="utf8" />
<title>Alexandria</title>
</head>
<body>
<div id="app">Hello from Alexandria dsf</div>
<script>alexandria.core.init()</script>
</body>
</html>
{:source-paths ["src/cljs"]
:dependencies [[bidi "2.1.6"]
[cider/cider-nrepl "0.22.0-beta1"]
[cljs-ajax "0.8.0"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[kibu/pushy "0.3.8"]
[re-frame "0.10.6"]
[reagent-utils "0.3.3"]
[day8.re-frame/http-fx "0.1.6"]
[refactor-nrepl "2.4.0"]
[reagent "0.8.1"]]
:builds {:alexandria {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:entries [alexandria.core]}}
:devtools {:after-load alexandria.core/mount-root
:watch-dir "public"
}
}}
:nrepl { :port 8777 }
(defn position
[r c]
(vscode.Position. r c))
(defn range
([p1 p2]
(vscode.Range. p1 p2))
([r1 c1 r2 c2]
(vscode.Range.
(position r1 c1)
(position r2 c2))))
where above there was (def vscode (js/require "vscode"))(:require ["vscode" :as vscode]) and then vscore/Range:node-script is for. building that is. running things is not supported.clj-run. the command may just get a bit longshadow-cljs run your.tool your.cljs.main output-to/foo.js or soshadow-cljs start on the commandline, it opens port 9000 and I can connect to it using Cursive. Is there a way to get the same behaviour when starting shadow from a repl with (shadow-server/start!)?shadow-cljs.edn as normal?lein with project.clj?start! thoughstop! 😉:node-library since I had to eject trying to build it as an :npm-module after a lot of hard trying to make that work). I'm pondering my options. Since it works for release builds, I think I can try build the extension with Webpack only for those, and then use my current build config for development. (I am not sure I can make this work, but I think so.) However, is it just a fluke that it works for release builds, or is it something I can rely on?:npm-module?:npm-module problems, just that I, with your assistance, couldn’t make it to work. It was something with the entry point.:npm-module problems either but it should be working fine. just may need to create one additional file manually or so. thats the part that :node-library basically does for you.shadow-cljs release wouldn't do?clj-fmt. The vsce packager greates a zip file with file extension .vsix, in which cljs-lib.js, created by shadow-cljs release is just one of the files. If I include Webpack in the build chain, it bundles all the js files into one, and vsce stops complaining about that I should use webpack. And the extension installs much faster and works excellently.:npm-module problems. You and I really gave that a shot, back then. But we reached a point where you said, “use :node-library instead”. Which is where I am now. I can of course try with :npm-libarary again, but I don’t like the idea of spending days to again find out it won’t work. 😃:node-library is never gonna work with webpack during development and what you describe is easily possible with :npm-module:node-library will NEVER work with webpack during development:node-library as the name implies assumes it will be running in node which is not true if you package it with webpack firstnode runtime facilities to load code dynamically which is also not possible when using webpack:npm-module+webpack during development is that it becomes loadableshadow.loader in a production build. Module loading isn’t working, and I’ve determined that shadow.loader.initCalled is undefined. The problem goes away when I enable --debug mode, which makes me think maybe it has something to do with an advanced-mode name collision of some kind. I haven’t been able to reproduce locally, only when it is built on our CI server. (Just posting here in case some possible avenue to look at comes to mind, i’ll keep debugging)shadow.loader.initCalled in the optimized code?shadow.loader object,initCalled keyinit I do see shadow.loader.init was already called!window.shadow.loader1 as the error (which i believe just means ’consecutive errors`<script> tags in the correct orderdropify.js?v=<hash>:module-hash-names true 😉:modules {:entries something.core} ?:modules {:main {:init-fn some.core/init}}:modules {:main {:init-fn some.core/init :entries [foo.bar]}}:js-provider :require is only for node environments and doesn't work in the browser.nodeenvironments? If so, as a newbie coming to the documentation, that wasn't immediately obvious to me and could well be worth clarifying
:advanced optimizationsnode_modules will only do :simple which already fails for viz.js so :advanced is unlikely to work(do (declare ^{:arglists '([a b c] [a b & cs])} create-element)
(set! create-element react/createElement))
and currently seeing this warning during compilation:
18 | (defn tag-render [{:keys [title body]}]
-------^------------------------------------------------------------------------
Wrong number of args (5) passed to hiccup-next.react/create-element
--------------------------------------------------------------------------------
19 | #h/n [:div {:class "card"}
20 | [:div {:class "card-title"} title]
21 | [:div {:class "card-body"} body]
22 | [:div {:class "card-footer"}
--------------------------------------------------------------------------------
#h/n this isn't supported (in shadow-cljs)(ns my-app.core
(:require [hiccup-next.core]
[hiccup-next.react :refer [<>]]))
(defn Mycomponent [props]
(let [name (goog.object/get props "name")]
(<> [:div {:style {:color "green"}}
[:span "Hello, " name]
[:ul
(for [n (range 10)]
(<> [:li {:key n} n]))]])))
(react-dom/render (<> [MyComponent {:name "Sydney"}])
(. js/document getElementById "app"))hiccup-next.react unless you require it#hiccup vs (hiccup)(register-element! :my-app/foo FooComponent)…#h/n ... vs (h/n ...) is ease of typing 😛 I basically write hiccup like I have been trained with Reagent / hx, then stick the tag on the beginning at a few places and I’m done#time/duration {:minutes 30} etc(time/duration {:minutes 30}) works just as well and has no such issuesreact.clj lib that was separate from a specific hiccup library / ui framework like rum / hx / uix / etc.{:type "div" :props {...}} and implement turning those trees into an HTML string(:require [hiccup-next.react :refer [<>]]) to (:require [[something.else :refer [<>]])[:div {:onClick (fn [e] ...)} ...] is bad for server rendered code[:div {:on-click [:foo 1 2 3]} ...] good on the server and clientshadow-cljs watch two builds in the same page at the same time? When I try to do this shadow-cljs watch app logger one of them cannot load properly because of 404s on the scripts it loadsshadow-cljs watch app, load shadow-cljs' UI and click the logger build?output-dir? Does the second build work flawlessly when started alone?output-dirrequires?
E.g. I have
(:require ["@material-ui/core" :as core]
[reagent.core :as reagent])
in my CLJS ns declaration. I then write some boilerplate code for each MUI component that I'd like to shove in a macro.
I think I can get away with just assuming that reagent and core aliases are available when the expanded CLJS code is compiled. But is there a better alternative?(defn foo [...] (core/foo ...))(the-macro core/thing ...)"@material-ui/core" directly, be more specific with the requirescore come from? "@material-ui/core" is not available for CLJ.
Or did you mean basically what I said, so that function would end up being called only in the expanded code?
What about a macro that does something like \(do (require ["@material-ui/core" :refer [Toolbar]]) (... using Toolbar))`?
Yes, sure - I oversimplified the ns declaration a bit. I require only the things that I need.:require inside of ns, and we can’t manipulate ns forms with macros(defmacro defcomponent [cljs-name args]
;; Intended usage:
;; (defcomponent app-bar [{:keys [classes color position] :as props} & children])
;; (defcomponent toolbar [{:keys [classes component disable-gutters variant] :as props} & children])
;; The full props specification is needed for correct parameters info during development.
;; E.g.in Cursive, `defcomponent` could be resolved as a function, making Cursive show that
;; `app-bar` accepts [{:keys [classes color position] :as props} & children] as parameters.
(let [;; "app-bar" -> "AppBar"
comp-name (string/join (map
string/capitalize
(string/split (name cljs-name) #"-")))]
`(do
(require ["@material-ui/core" :refer [~comp-name]])
(let [comp (reagent.core/adapt-react-class ~comp-name)]
(defn ~cljs-name [& props+children]
(into [comp] props+children))))))
(require [reagent.core]) but you get the idea.require only a REPL thing in cljs?:refer is kind of a trap here since it doesn't do what you think it does(:require ["@material-ui/core/Button" ...])(:require ["stuff/core" :refer [Component]]) seems to work just fine, just as (:require ["stuff/core/Component" :default Component]).@material-ui/core you will require the "meta" package:refer is not very useful on its own:refer-like :require to a :default-like one, right?:stories {:target :npm-module
:output-dir ".storybook-compiled"
:devtools {:enabled false}}{:source-paths ["lambda-src"]
:builds {:aws {:target :node-library
:exports {:handler ingest-events.aws/handler}
:output-to "ingest-events/index.js"
:js-options {:js-provider :shadow
:keep-native-requires true}
:release {:compiler-options {:source-map true
:optimizations :simple}}}}}
(:require ["module-name" :as module-name]) and (:require ["module-name"])?
Reference: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages(:require ["moment" :as moment]) vs (:require ["moment"]).(:require ["moment"]) has no alias so you it will be included in the code but you can't reference itshadow-cljs - dependencies updated [:app] Compiling ... IllegalStateException: could not find where to put constant for module goog.structs.map.jsAnd I am not sure if this is the issue with some gitlab optimizations or with the way we have set up the project. I can reproduce it locally (sometimes), but it is really inconsistent locally and it fixes itself when it breaks like that. We also noticed that removing the .shadow-cljs directory in the pipeline makes this issue happen less often. If anyone can point me in some direction would be cool 🙂
:npm-module build?goog.* code. it might be that there is a keyword where this is the only common dependency which should also never happen because that is supposed to be cljs.core.(clojure.string/foo ...) in an ns that doesnt have a (:require [clojure.string ...]) ;; TODO :printed-value was removed in nREPL 0.6.0"react-select": ""react-select/ directory in node_modules(ns alexandria.views
(:require
["react-select" :default Select]
[reagent.core :as r]
[re-frame.core :as rf]
[re-frame.db :as db]
[alexandria.mapbox :refer [mapbox ]]))The required JS dependency "react-select" is not available, it was required by "alexandria/views.cljs".
Searched in:/Users/rodfrey/dev/terrapin/alexandria/node_modules
You probably need to run:
npm install react-select
See:
fireplace.vim: Something went wrong: {'status': ['done'], 'id': 'fireplace-MacBook-Pro.hitronhub.home-1560792001-475', 'session': ['ef44ac71-4693-4684-91aa-9673224c2965'], 'err': 'The required JS dependency "react-select" is not available, it was required by "alexandria/views.cljs".^@^@Se
arched in:/Users/rodfrey/dev/terrapin/alexandria/node_modules^@^@You probably need to run:^@ npm install react-select^@^@See: import Select from 'react-select';"react-select": "^3.0.4" and cleaned everything out and did npm install/Users/rodfrey/dev/terrapin/alexandria/node_modules/react-select?npm sometimes acts funky and leaves empty directories{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "44362b202236213d04092527062b2b2f6914362b6a2c2d30362b2a2c31266a2c2b2921"}, :content ("[email protected]")}dist folder is full’o’code too.node_modules too much{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6c1e03080a1e09152c210d0f2e030307413c1e03420405181e030204190e4204030109"}, :content ("[email protected]")}shadow-cljs - connected to servergoogl.string.isNumeric is not a function and other seemingly Google Closure issues. The issue is resolved when building for productiongoogl? that shoul be goog?lein deps :tree[com.google.javascript/closure-compiler-unshaded "v20190325"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
clj-ajax library has a dependency on some javascript file which has a symbol that is not really defined. So thanks for the pointers 🙂cljs-ajax build fails sometimes: https://gitlab.com/lucmartens/cljs-pipeline-test/merge_requests/1/diffs
Without it seems to succeed: https://gitlab.com/lucmartens/cljs-pipeline-test/merge_requests/2/diffsIllegalStateException: Could not find where to put constant cljs$cst$keyword$body. Used by [ajax.easy.js, ajax.xhrio.js, ajax.xml_http_request.js, ajax.ring.js, ajax.interceptors.js, ajax.protocols.js], selected common dep goog.structs.map.js
shadow.build.closure.ReplaceCLJSConstants.process (ReplaceCLJSConstants.java:61)NullPointerException. Any ideas?:local/root.localhost:8080 instead of prod services) and a different one for production?wss://shadow-cljs watch app running, and I am making changes in the code. When I make changes in the existing namespaces, they get reloaded automatically but when I create a new namespace and require them in the existing namespace, i get the following error:
The required namespace "<new namespace>" is not available, it was required by "<existing ns>.cljs"
shadow-cljs server process you can just restart the watch:log {:level :debug} will print a bunch of stuffshadow-cljs server and select the build from the web interface. May be it was one off issue. I will keep an eye on itcljsjs.* packages. using (:require ["react" :as x]) will not expose the globaljs/React.createElementrelease build you can maybe cheat that but in development nostring/replace thenjs/React only needs to come from that scopevar React = the.actual.react; into the output-wrapper that should be finejs* and is loaded first(ns hack.react (:require ["react" :as react] ["react-dom" :as react-dom])) (js* "var React = {};" react) (js* "var ReactDOM = {};" react-dom)cljsjs shims so they don't export a global:modules {... {:entries [hack.react ]}} or by just requiring it first in whatever ns is loaded first2019-06-21 15:57:52.567 - INFO] duplicate resource cljsjs/react/dom.cljs on classpath, using jar:file:/home/mitchel/.m2/repository/thheller/shadow-cljsjs/0.0.18/shadow-cljsjs-0.0.18.jar!/cljsjs/react/dom.cljs over file:/home/mitchel/Development/atlas-crm/atlas-crm-kit/src/cljsjs/react/dom.cljs [2019-06-21 15:57:52.577 - INFO] duplicate resource cljsjs/react.cljs on classpath, using jar:file:/home/mitchel/.m2/repository/thheller/shadow-cljsjs/0.0.18/shadow-cljsjs-0.0.18.jar!/cljsjs/react.cljs over file:/home/mitchel/Development/atlas-crm/atlas-crm-kit/src/cljsjs/react.cljs
shadow-cljsjs(js* "var React = ~{};" react)(js* "var React = ~{};" react) results in React=null;(js* "var React = ~{};" r)
(js/console.log "react" r js/React (identical? r js/React))(:require ["react" :as r])(ns atlas-crm.server.react-hack
(:require ["react" :as r]
["react-dom" :as rd]))
(js* "var React = ~{};" r)
(js/console.log r)
(js* "var ReactDOM = ~{};" rd)
(js/console.log rd)
And this results in:
React=null;console.log(nl_avisi_atlascrm.A0);ReactDOM=null;console.log(nl_avisi_atlascrm.L7a);
(js* var WTF = ~{};" r) or soReact name?nl_avisi_atlascrm.A0.createElement,a,b,cWTF=null;console.log(nl_avisi_atlascrm.A0);React.createElement,a,b,c againReact is declared in the externs and you are not allowed to reassign it maybe?React.createElement,a,b,c
nl_avisi_atlascrm.A0.createElement,a,b,c
React.createElement,a,b,c again(js* "var React = ~{};" r)
(js* "var ReactDOM = ~{};" rd)
It changed all the code to:
nl_avisi_atlascrm.A0.createElement,a,b,c
nl_avisi_atlascrm.A0?:modules is supposed to work. I just don't get why it is assigning var React=null;nl_avisi_atlascrm.A0=(6)
shadow.js.jsRequire callshadow-cljs release build --pseudo-namesReact to null if its never used againReactnl_avisi_atlascrm.$module$node_modules$react$index$$.createElement.apply(null, $arr$jscomp$166$$);
nl_avisi_atlascrm.$module$node_modules$react$index$$react=null assignment for now. no idea where that is coming from or if that somehow can be removed otherwisenl_avisi_atlascrm.$module$node_modules$react$index$$ = nl_avisi_atlascrm.$shadow$js$require$$(6);
ns (like: (:require ["router5" :as router5]))) and try to use one of the exported functions (`createRouter`) I get TypeError: module$node_modules$router5$dist$index.createRouter is not a function, and looking at the actual export it is in fact an empty object. But, if I’m in the browser repl and do (require '["router5" :as router5]) I can use the exported functions just fine.node_modules/router5/dist/index.js is a commonjs file, with exports like:
exports.RouteNode = RouteNode; exports.transitionPath = transitionPath__default; exports.createRouter = createRouter; exports.cloneRouter = cloneRouter; exports.constants = constants; exports.errorCodes = errorCodes; exports.default = createRouter;
module.exports = everything works fine…(require ...)(js/console.dir router5) to the file using itnode-library which I think is npm deployable. But how can a .jar file be made which can be deployed on Clojars?lein deploy to publish to e.g. clojars or other maven repopackage.json and just start using it?.jar format, they can be included in :dependencies in project.clj. Right?deps.cljs to your .jar with {:npm-deps {"foo-bar" "1.2.3"}}^export because that would be wrong?onOpen callback defined?(defn ^{:export "onOpen"} your-on-open [e] ...)^:export isn't enough because that would create a fully qualified name:export takes an actual string as well(ns (:require ["@material-ui/core/AppBar" :as mui-AppBar])) (def app-bar (factory-apply mui-AppBar)) ;; app-bar isn't usedWill be included in final bundle?
a,b,c,d,...)$(...).modal() fn it's supposed to add to jQuery isn't available. Maybe just require it somewhere to make sure the module loads?(:require ["jquery-modal"])and everything worked.
react-native shadow-cljs build in Docker, and devtools on the phone is trying to connect to a ws:// URL that’s only accessible inside the Docker container (`<ws://169.254.32.96:9630/ws/...`>).
Related line in react-native.cljs - https://github.com/thheller/shadow-cljs/blob/89acb664f800af48344288e963873bf8972ee9fb/src/main/shadow/cljs/devtools/client/react_native.cljs#L206
The ws connect fails so the app crashes with the React Native red screen every 30 seconds.
Related GH issue? https://github.com/thheller/shadow-cljs/issues/482
Are there any workarounds? Can we specify the websocket hostname in shadow-cljs.edn?heartbeat! https://github.com/thheller/shadow-cljs/blob/0e28c615cd75d4cbce27ede7a8f7f70785d42c86/src/main/shadow/cljs/devtools/client/react_native.cljs#L244shadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}' or just the :local-ip in the build config itself["react" :as React] now returns an empty javascript object, and I get cascading failures about how .createContext etc is not a function.node_modules files too much.shadow-cljs fixes it. I can reproduce this 100% of the time.connected to server on startup you did not restart the server isntance just the watch.shadow_cljs (but I’m keeping a copy around 😉 ):maven {:proxy ...} in ~/.shadow-cljs/config.edn{:maven
{:proxy
{:host "localhost"
:port 8099}}}project.clj or deps.edn is what I'll get. No ambiguity. The whole ^2.1.3 automatic bumping thing scared the living daylights out of me.npm ci does not. Yarn has more same defaults. main.js as a script on one of the pages running on 3375 in Windows, when it loads, I’m getting the following errors: it'll attempt to load the files from 8700:devtools-url or the proxy config as pointed out above:asset-path config option. so :asset-path "":http {:port 9630 :host "my-ip"}
shadow-cljs - server version: 2.8.39 running at
:devtools-url properlyshadow-cljs run shadow.cljs.build-report <my-build-id> report.html and it raises an error:
NoSuchFileException: .shadow-cljs/release-snapshots/dev/latest/main.js:browser builds? do you use :browser?amazon-cognito-identity-js directly, without aws-amplify?
having a weird issue here:
i have a namespace where i require cognito like this:
(ns xt.auth
(:require
["amazon-cognito-identity-js" :refer [CognitoUserPool]]))
And then i use it like this:
(defn user-pool [config]
(CognitoUserPool. #js {:UserPoolId (:pool-id config) :ClientId (:client-id config)}))
Everything works when i load that namespace in REPL.
Once i load it in browser (as dependency of another namespace), i’m getting error saying that CognitoUserPool is not a constructor.
And it stops working in REPL too. (same error, not a constructor)
Sometimes (not sure what’s the pattern yet), if i then reload the namespace in REPL, it starts working again, but once i refresh the browser, it stops working.:configure hook a sane way to go ? or, i'm already using gulp to coordinate the result of the webapp build... i could also just modify the shadow-cljs.edn file from gulp - unless there's something obvious i'm missing ?.nrepl-port file to be created even if [:nrepl :port] is set? Calva uses this file’s creation as a signal in its jack-in process (because limitations in the vscode API:s).require?
The reason for that is that while developing an atom package I found out that I can compile it with :js-provider :shadow to avoid using node_modules. This made the package smaller, installs faster, and when Atom starts the package adds waaay less time on startup timerequire('fs') for example, and shadow's compilation complains that it can't find the module for it.shadow-cljs/nrepl.port is always generated?.nrepl-port is wrong and kind of unreliable since it doesn't want to interfere with lein creating one.shadow-cljs/*.port files:fs-watch {:watcher :polling} to shadow-cljs.edn but that didn't alleviate the issue(js/thatGlobal.foo.bar)var ice = require('./assets/ice.jpg');
(def ice (js/require "./assets/ice.jpg"))but it seems to see "require" is not defined
repl/invoke error, [ReferenceError: Can't find variable: require](require '["./assets/ice.jpg" :as ice])but it just sits there
react-vega and got an interesting error (paths truncated for brevity):
package in /.../node_modules/d3-scalespecified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["build/d3-scale.js"], :package-dir #object[java.io.File 0x58381a04 "/.../node_modules/d3-scale"]}
ExceptionInfo: package in /.../node_modules/d3-scalespecified entries but they were all missing
I think there's a space missing in d3-scalespecified. And d3-scale is missing from node_modules so it looks like the message "package d3-scale specified entries but they were all missing" is a bit misleading since it's the package itself that's missing./.../node_modules/vega-scale/node_modules/d3-scale/.:asset-path?:asset-path starts with a / and your <script tag including the initial JS does as well: dependencies vector in shadow-cljs.edn.The required namespace "' is not available, ...deps.edn instead of shadow-cljs.edn solve this problem?[keechma/toolbox "0.1.6"]shadow-cljs watch and the backend with a normal repl.
A disadvantage to running is that the dev server for the frontend is running on a different port than the backend. Is there a way to run the dev shadow cljs server in the same process and port than the backend server?:npm-module target, and requiring some JS files from cljs using (:require ["/abs-path-to-js" :as my-js]). Compiles, but when that js file is evaluated I get a ReferenceError: shadow$provide is not definedshadow$provide = {}, then see another error - the pattern in these re-emitted js files is
shadow$provide.module$foo = function() {...}
module.exports = module$foo
..and module$foo is not definedidentity$$module$ftest$util instead of module$ftest$util.identityimport * as util from './util' export const IDENTITY = (x) => util.identity(x)
:npm-module target(js/require "..") would be more reliablejs/require probablyjs/require in shadow?:output-dir so whatever you require must be relative to that1)registerCallback fn that lets you add a callback for errors, but this is only called after it has attempted to load a script a few times, and doesn’t pass you the actual errorgoog.log.warning(
this.logger, 'Loaded incomplete code for module(s): ' + moduleIds, e); etc(ns ... (:require [goog.debug.Console :as Console]) (:import [goog.debug Console])) (.setCapturing (Console.) true) (Console/autoInstall)
(:require [goog.debug.Logger.Level :as Level]
[goog.log :as glog])
(:import [goog.debug Console])
(.setCapturing (Console.) true)
(.setLevel (glog/getLogger "") Level/WARNING)
(shadow.cljs.devtools.api/repl :the-build-id)[:no-worker :the-build-id]{:builds {:this-is-the-build-id {:target :browser ....}}}:app or whatever you haveshadow-cljs.edn(shadow.cljs.devtools.api/watch :the-build-id)cljs.user=> [:selected :app] 1 No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
:target :browser you need to open the browser and load your JS(shadow.cljs.devtools.api/browser-repl) or (shadow.cljs.devtools.api/node-repl):builds {:app {:target :node-library
:exports {:handler server.main/handler}
:output-dir "target"
:output-to "target/main.js"}}}
target/main.js via node or sonode-repldeps.ednException in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
deps.edn?thheller/shadow-cljs to your dependencies:dump-core compiler option supposed to work in cljs builds? I'm finding that even when setting that to true, cljs.js/dump-core still returns nil:dump-core is not supported. if you need self-hosted support you should follow this https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.htmlnpx shadow-cljs watch ... with :http-root to work on any version of shadow-cljs later than 2.6.x. I tried a personal project, the re-frame example[1], and the quickstart browser example[2]. Every time I run them everything other the than index (js,css,etc) fails to load with a 404. I tried changing to the new format suggested by issue 436[3] and got the same behavior. There are no sym-links involved in any of this. I am on mac. I tried node versions 8 and 10, with no difference in behavior.
The index.html is loading and making changes to it are reflect, but no other resources are loaded (in same directory or otherwise). Serving that folder with something like simple-http works perfectly fine.
I am on mac os catalina, so that could be the issue. I can’t really follow the code for the dev server. I do know based on adding print statements to my personal project that the js and css files are ultimately making their way to the push state handler[4], where they are then turned in 404s.
If there is any way I can help debug this issue I’d be happy to. I wanted to check on here first to make sure I’m not missing something obvious.
[1] https://github.com/shadow-cljs/examples/tree/master/re-frame
[2] https://github.com/shadow-cljs/quickstart-browser
[3] https://github.com/thheller/shadow-cljs/issues/436
[4] https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/http/push_state.cljcd shadow-examples/re-frame npm i npm i -D shadow-cljs # currently installs 2.8.40 npm run watch # shadow-cljs watch appAfter letting the build complete, I am able to load both the compiled code and CSS
println via the :after-load configuration?shadow-cljs after saving changes to outcry_mobile/ui/main.cljs. Problem is that changes visible in running application. Behavior and look of UI remains same after this.start fn?(defn ^:dev/start start []
(print "startt")
(reload))^:dev/start that does nothing(reload) do?(defn reload []
(let [current @running-app]
(if current
(app-state/stop! current start-app!)
(start-app!))))current exist it'll call stop!start-app! in stop! that probably is your problem?stop callback and then actually only stop on reload?current is app-definition/app-config here.stop callback is optional param.(app-state/stop! current) called and app would be stopped. But you would have to start it again yourself.stop! in ^:dev/before-load and start-app! in ^:dev/after-load. right?:dev/before-load and :dev/after-loadkeechma.shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn cli version: 2.8.40 node: v10.15.2 shadow-cljs - starting via "clojure" Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
deps.edn manuallynpx shadow-cljs server and then do what?npx processnpm WARN cark.tags No descriptionrunning: cmd /C npm install --save package.json so it doesn't do that all the timenpx create-cljs-project acme-appC:\Users\thheller\code\tmp\acme-app> npx shadow-cljs server shadow-cljs - config: C:\Users\thheller\code\tmp\acme-app\shadow-cljs.edn cli version: 2.8.40 node: v11.9.0 shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.8.40/shadow-cljs-2.8.40.pom from Retrieving thheller/shadow-cljs/2.8.40/shadow-cljs-2.8.40-aot.jar from shadow-cljs - dependencies updated [2019-07-08 18:51:16.283 - WARNING] TCP Port 9630 in use. shadow-cljs - server version: 2.8.40 running at shadow-cljs - nREPL server started on port 51194
expo-three node module in a shadow-cljs expo project, I get this error:
Uncaught Error: Cannot find module './suppressWarnings'This happens when i require
THREE from expo-three module.
I can see that the supressWarnings.ts file is there in the repo where Three.ts file is in this repo: https://github.com/expo/expo-three/blob/master/src/Three.ts
Is this because the exported object is suppressExpoWarnings but the filename is suppressWarnings? I am weak on JavaScript and not sure if it is because of the way shadowcljs compiles the ts files or if there something else I am missing.yarn watch on one terminal, and once it compiles, yarn web to open the react-native-web app on browser (if it does not automatically open the browser you can open http://localhost:19006/webpack.config.js which seems to do a whole bunch while your project has none. https://github.com/EvanBacon/Expo-Pillar-Valley/blob/master/client/webpack.config.js(shutdown-agents) was called maybe?$ clj Clojure 1.10.1 user=> (shutdown-agents) nil user=> (future 1) Execution error (RejectedExecutionException) at java.util.concurrent.ThreadPoolExecutor$AbortPolicy/rejectedExecution (ThreadPoolExecutor.java:2055). Task
shutdown-agents are not being ran… will investigate a bit further 🙂shadow-cljs seems to swallow the NPE (but unfortunately still emits invalid JS):
goog.provide('cljsbug.wat.shadow.core');
goog.require('cljs.core');
cljsbug.wat.shadow.core.a = cljs.core.rand_nth(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [null], null));
if(cljs.core.truth_(cljsbug.wat.shadow.core.a)){
( * (2));
} else {
}
shadow-cljs clj-run could helpclj-run is that simple solution. you just create a clojure function in some namespace and call that using clj-run:node-library or :npm-module), and how to configure shadow-cljs.edn and package.json.
A template for a Javascript Extension can be found here: https://github.com/jupyterlab/extension-cookiecutter-js/tree/master/%7B%7Bcookiecutter.extension_name%7D%7D.
Furthermore the JupyterLab documentation states the following: “An Extension is a valid npm package that meets the following criteria:
• Exports one or more JupyterLab plugins as the default export in its main file.
• Has a jupyterlab key in its package.json which has “extension” metadata. The value can be true to use the main module of the package, or a string path to a specific module (e.g. “lib/foo”).
• It is also recommended to include the keyword jupyterlab-extension in the package.json, to aid with discovery (e.g. by the extension manager).
It would be great if someone could point me in the right direction!:node-library would be what you wantTypeError: "FS.readFileSync is not a function" in the browser consolerelease build will probably workwatch or compile:node-library as the name implies is meant for things that run in node:npm-module is probably a better fit then(def ^:export thing ...)main in package.json"main":"./lib/your.ns.js" or so{:target :npm-module :entries [your.ns] :runtime :browser}:runtime :browser was the part I was missing earlier:target :jupyter that takes care of all of that but I never used it before:target abstraction(def ^:export extension #js {:stuff :here}) to be the default export?default but maybe it does. so it would just be (def ^:export default ...)default$ since default used to be a reserved symbol.js file and use that as mainimport { x } from "./lib/your.ns.js" and export default x;(def ^:export x ...) in your CLJS ns of course(:require ["fs" :as fs]) and (fs/readFileSync ...) or so?goog.crypt? 🤔(js/require ...) directly, but I guess if you use strings on the :require block it works as wellvar { createCanvas } = require("canvas"); to the namespace require in cljs(ns ucv.controller.barcode
(:require
["canvas" :as createCanvas]))
(ns ucv.controller.barcode
(:require
["canvas" :refer [createCanvas]]))
createCanvas was exported default, (which does not look like the case looking at var { createCanvas } = require("canvas");, it would have been (:require ["canvas" :as canvas :default createCanvas])`(ns ucv.controller.barcode
(:require
["canvas" :as canvas]))
(def createCanvas (.-createCanvas canvas))
(def canvas (js/require "canvas")) (js/console.log (.-createCanvas canvas))
(:require ["canvas" :refer [createCanvas]]) would be the correct translationWalletConnectProvider as it is defined here https://github.com/WalletConnect/walletconnect-monorepo/blob/53206bb3a6c9a7205942271f0433877f51763327/packages/web3-provider/src/index.jsexport default function WalletConnectProvider (opts) {}["@walletconnect/web3-provider" :default WalletConnectProvider] and used (new WalletConnectProvider ...)i?["@walletconnect/web3-provider" :as x :default WalletConnectProvider] and then logging (js/console.dir x) to verify if the properties you are looking for actually existx gives me::default is probably correct then.default property(pending) forever 🤔:loader-mode :eval be set as default in the future?/js(:require ["antd/es/date-picker" ...]) and so on?require css related to antd/es/date-picker?import 'antd/es/date-picker/style/css';node-sass and import it thereshadow-cljs with electron. Everything works well until now except the usage of the fs module in the renderer process. From the main process it is no problem to (require '["fs" :as fs]) and get the fs module.
But from the renderer process, all I get is an empty map: #js {} while for the modules path and url i get the right modules.
I cannot figure out how this happens. Does anyone have an input to this?:js-options {:js-provider :require}shadow-cljs!Uncaught ReferenceError: require is not defined 😞require directly?.shadow-cljs and the errors vanished except that the behavior with the fs module is still the same with the :js-options {:js-provider :require} option(js/require "fs")?:requirerequire is not defined errors always appear with :require set as js-provider, the fs problem occurs with and withoutfs and such are typically only used in the main processnpm install xregexp doesn't help, it then gives another error:
The required JS dependency "core-js/library/fn/array/is-array" is not available, it was required by "node_modules/@babel/runtime-corejs2/core-js/array/is-array.js". Searched in:<my-project>/node_modules You probably need to run: npm install core-js/library/fn/array/is-arrayNeither this instruction, nor
npm install core-js help.
Has anyone else had success using cuerdas "2.2.0" on the client with shadow-cljs?npm install work?:dev build targeted for :node-script, it works when I do shadow-cljs watch dev in one terminal window and node target/app.js in the other, but I just want to CIDER-jack-in.
When I jack-in-cljs:
- it first prompts me with the type of REPL, to which I say “shadow”, there’s also “shadow-select”, which I believe is the same thing.
- then it prompts me again for a build, I choose :dev,
- then it prompts me for the third time, asking if I want to launch a browser (wtf?).
Anyway, it kinda works, but what bothers me - it doesn’t print anything, anywhere (unlike when I run the app like above). My :devtools {:after-load function, I can’t tell if it’s firing or not. I tried setting (enable-console-print!) and (node/enable-util-print!) - it’s not printingdeps.edn with shadow-cljs - and failed at that as well. Anyway - my end goal is to run Puppeteer scripts, I believe I have to use :target :node-script for that. But why it’s not printing anything? prn doesn’t appear to be working, neither js/console.log. It’s not complaining, there’s simply no output anywheredev not :devcider-jack-in-clojurescript
2. Select shadow
3. Choose dev
4. Press n to not open a browser
Once the build has completed once, in a terminal run the command:
node target/app.js
and you should see your console.log println etc. show up in the Node process terminalindex.html but also other files? Currently I have the below files under the public folder. There are both static pages (`index.html`, log-in.html, and sign-up.html) and my single page app (`app/index.html`). I want the single page app to handle all the routing under the path /app/*, for example /app/profile. However, when loading /app/profile, the dev server falls back to public/index.html. Any suggestion is welcome.
public/index.html public/log-in.html public/sign-up.html public/app/index.html
["public/app" "app"]/app/profile does not match any file under those two roots, and thus the default handler was called.:push-state/index key might be the one I am looking for.re-frame-10x has a bug when using shadow-cljs whereby require like [react-highlight.js :as react-highlightjs] leads to an exception due to not binding the correct value, whereas ["react-highlight.js" :default react-highlightjs] does work. As a library, I will need to maintain support for both standard CLJS/figwheel and shadow-cljs with any fix. Any guidance on how one supports both please ?module.export = Highlight; and re-frame-10x should be using [react-highlight.js :as react-highlightjs] and then later when using it react-highlightjs/default in the adapt-class callcljsjs alias namespace with global variable. like most other packagesreact-highlight.js ns which maps directly to the npm packageHighlight.default unwrappingreact-highlightjs you could just use (or react-highlights/default react-hightlightjs)/default but the rest would use the other onescaler looks like this
export const scaleImage = () .....shadow-cljs/builds dir and restarting the buildbuilds folder from shadow-cljs and it starts to working again. It’s quite easy to reproduce it:
- call JS file from CLJS
- call JS file methods from the above JS file (as an import)0.4.2 that fixes compatibility with shadow-cljs as per above. Thanks @thheller!shadow-cljs compile my-app I’m getting an error:
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.when I explicitly add shadow to my deps.edn, this goes away. confused why that might be the case, as it wasn’t listed in my deps.edn pre monorepo migration
node_modules in a different directory than the top level?:js-options {:node-modules-dir "some/nested/path"} in your build config:advanced compiled builds are much less dynamic and certain dynamic things you can do in dev builds wont work:compiler-options {:infer-externs :auto} in your build config and check the warnings (if there are any)shadow-cljs release your-build --debug to make things a bit easier to debug(fn [^goog e] ...) to make that warning to awayevent_ is though. doesn't look like something you should be using directly(fn [^js e] ...) which will cause externs for event_ to be added. maybe that fixes itjs->clj but EDN/transit don't have those issues"version": "0.0.1",
"private": true,
"devDependencies": {},
"dependencies": {
"bootstrap": "^4.3.1",
"core-js": "^3.1.4",
"create-react-class": "^15.6.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-transition-group": "^4.2.1",
"sass": "^1.18.0",
"xregexp": "^4.2.4",
"yarn": "^1.13.0"
}
core-js is being required by xregexp
and also create-react-class
I don't have an idea of how it can be resolved (being new with using npm deps in cljs and shadow-cljs), any hints?node_modules/xregexp/package.json. then make sure to install that version.npm i --savedid the trick! ta!
:js-options {:node-modules-dir "some/nested/path"} anywhere, would you like a PR that adds a tiny note about it?:ci {:target :karma}:
{
"message": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n at ci.js:229378:1",
"str": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n at ci.js:229378:1"
}
The line that throws the error the is a transpilation of a js class extension:
$jscomp.inherits(ShuffleLoader$$module$nubank$shuffle$common$ui$shuffle_loader, module$node_modules$react$index.PureComponent);Shadow-clj compiles and runs the app perfectly, the error only appears when running tests.
$jscomp is the var the GCC uses for polyfills:compiler-options {:output-feature-set :es6} so it doesn't transpile classes:compiler-options did the trick. Thank you very much!:es7 or :es8{:clojure.main/message
"Execution error at shadow.build/eval16057$loading (build.clj:1).\nUnable to resolve spec: :clojure.core.specs.alpha/args+body\n",
:clojure.main/triage
{:clojure.error/class java.lang.Exception,
:clojure.error/line 1,
:clojure.error/cause
"Unable to resolve spec: :clojure.core.specs.alpha/args+body",
shadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn cli version: 2.4.5 node: v10.16.0npx shadow-cljs servernpx ... in the same directory as my node_modules (now i have two in two separate dirs) launches the servershadow-cljs.edn.cpcache dir so deps.edn does its thing againnpm install --profile browsernpm install --profile node in another context:node-modules-dir prevents your process from startingshadow-cljs.edn presumably with a :deps and deps.ednshadow-cljs clj-repl in that directorynpx shouldn't really matter:node-modules-dir just have package.json and node_modules in a subdirectory:deps in shadow-cljs.edn?:deps {:aliases [:test :cljs :dev]}clj -A:test:cljs:dev please(require 'shadow.cljs.devtools.cljs-specs)user=> (require 'shadow.cljs.devtools.cljs-specs) nil
:dev i have it thheller/shadow-cljs {:mvn/version "2.8.21"}.cpcache and .shadow-cljs no luckclj command again please( "clojure/core/specs/alpha.clj")~/s/ucv (feature/barcode-scanner↑2|✔) $ clj -A:test:cljs:dev Clojure 1.10.1-beta2 user=> ( "clojure/core/specs/alpha.clj") #object[java.net.URL 0x5efb3259 "jar:file:/Users/currentoor/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar!/clojure/core/specs/alpha.clj"]
:js-options {:node-modules-dir "..."} would work for a :browser target but not :node-script:keep-native-requires(require 'my.ns :reload-all) but this doesn't seem to work. Is this an effect of the caching? Do I need to turn this off completely when developing?:node-script:node-script is just going to use direct js require calls and let node do the resolving. so it'll automatically "adapt" to the node_modules dir whereever you execute the scriptnpm i -D shadow-cljsnpx shadow-cljs watch <build-id> and everything is working as expected, except, i have to manual refresh the browser to see dom changes. Is there a way to have it refresh when i make changes?[:builds your-build :devtools :after-load]SHADOW_ENV is defined.Execution error (IllegalStateException) at com.google.common.base.Preconditions/checkState (Preconditions.java:823). Externs must contain builtin for env BROWSER: whatwg_console.js
[ [thheller/shadow-cljs "2.8.41"] [binaryage/devtools "0.9.7"] [fulcrologic/fulcro "2.8.4"] ]
lein deps :treepathom which has a visualizer which uses fulcro. Oh well.#error {:message
"The map literal star … ven number of forms."
, :data {:type :reader-exception, :ex-kind :reader-error}}
(let [color (.hcl js/d3 color)
color (.brighter color .9)]
(.toString color))
The map literal starting with :prefix contains 5 form(s). Map literals must contain an even number of forms.shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:168 (anonymous) @ browser.cljs:349
--config-merge is used to override vars in shadow-cljs.edn but you cannot use it to define custom vars? I would like to do something like shadow-cljs build app --env=dev, so I have to manage it inside my app and not with shadow-cljs?["moment" :default moment]doesn’t work but it turns out they intentionally have the ES6 importable code in
["moment/src/moment" :default moment]
["moment" :as m] probably works too. :default is kinda dependent on how the package is packagedgoog.provide('xycp.frontend.event.http');
goog.require('cljs.core');
goog.require('cljs_http.client');
goog.require('cljs.core.async');
goog.require('re_frame.core');
//# sourceMappingURL=xycp.frontend.event.http.js.map
(ns xycp.frontend.event.http
(:require [cljs-http.client :as http]
[cljs.core.async :refer [<! go]]
[re-frame.core :as re-frame :refer [reg-fx]]))
(defn hello [] 1)
this is the code^js/Foo.Bar but I decided to skip those in shadow-cljsshadow-cljs node-repl and go:node-script build for the actual script then./src/infrastructure/config.js from another (to be specific) ./src/api/client/schemas/login.js file.
From the login.js I tried to import the configuration via:
const config = require('../../../infrastructure/config.js')
But I'm receiving the undefinedapi/client/core.cljs via ["./schemas/login" :as login]
Project configuration:
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[mount "0.1.16"]
[funcool/promesa "2.0.1"]]
:builds {:api {:target :node-script
:output-to "target/api.js"
:ns-regexp "^api.*"
:main api.server/main!
:devtools {:after-load api.server/reload!}}
:worker {:target :node-script
:output-to "target/worker.js"
:ns-regexp "^worker.*$"
:main worker.setup/main!
:devtools {:after-load worker.setup/reload!}}
:worker-test {:target :node-test
:output-to "target/worker-test.js"
:autotest true
:ns-regexp "^test.worker.*"}}}
config.js
const providers = {
someProvider: {
scope: [{
name: "shopping-lists"
}]
}
}
const allowedProviders = Object.keys(providers)
export const configuration = {
...providers,
allowedProviders
}
export with require./src/api/client/schemas/login.js looks like
import joi from '@hapi/joi'
import { configuration } from '../../../infrastructure/config.js'
console.log(configuration)
Error message: TypeError: Cannot read property 'configuration' of null.js files directly and not have shadow-cljs process them in any wayexports.configuration = ... instead of the export const configuration cider/cider-nrepl and cider/piggieback as dependencies and get the following warnings when starting the repl: https://pastebin.com/LPrmeKmz[2019-07-24 12:37:11 - SEVERE] Unhandled REPL handler exception processing message {:id ae40bfe8-e180-4ad0-33de-ceb5d15054f3, :op classpath}
java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'nrepl.transport/Transport found for class: clojure.tools.nrepl.transport.FnTransportcrypt.cljs in your screenshot. I'm searching for a library for doing AES in cljs, any sugeestions?Cannot read property 'charAt' of undefined
(ns foo.bar (:require ["crypto-js" :as CryptoJS])) ((.. CryptoJS -enc -Base64 -parse) "aGVsbG8n")This is the JS version
var CryptoJS = require('crypto-js');
var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
<!DOCTYPE html>
<html>
<head></head>
<body>
<script src="node_modules/crypto-js/crypto-js.js"></script>
<script>
var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
</script>
</body>
</html>
(.. crypto/enc -Base64 (parse "hello"))
CryptoJS.enc.Base64.parse and (.. CryptoJS -enc -Base64 -parse) are totally equal. tried in the console and repl.(.. crypto/enc -Base64 (parse "hello"))
piggieback and shadow-cljs these days? Now that I can connect with clojure I'm having problems getting the cljs repl connected. I used to just put :Piggieback :app and it worked. Shadow-cljs says it's watching build :app I have the cider/piggieback dependency loaded in.CryptoJS.enc.Utf8.parsethis. this post have a great explain.shadow-cljs, the live reloading works great, except when i create a new namespace inside a package (folder) and require it somewhere, where it says : The required namespace X is not available, it was required by Y, so i need to kill the shadow-cljs server and restart it, is there a better way to do this? i've tried shadow/stop-worker and then shadow/watch again but no luck2.8.40<script> tags for node_modules in the html during development. Anyone remember how to do that?:devtools {:loader-mode :eval} in the build confignpm packages that work in the browser as well?:node-library output browser compatible(ns infrastructure.util
(:require
[clojure.tools.macro :as macro]
[promesa.core :as p]))
(defmacro defn-handler
[name & attrs]
(let [[aname [fn-args & fn-body]] (macro/name-with-attributes name attrs)
args-count (count fn-args)
afn `(fn ~fn-args
I've just created macro which is used to define the express.js handlers.
(defn-handler get-login-status [req res] (println req res))For some reason code works perfectly fine but the shadow-cljs outputs a warning:
const required = require(`../vectors/${name}`);
vector = required.default || required;
js/require directly but it is not supported otherwisemy-project.thing had a corresponding my-project.thing-spec, we could watch for the creation of those files and add their require to a ns that was included via a preloads-like method at dev-timecider/cider-nrepl "0.21.0" to nrepl "0.6.0" which worked in letting me hook vim into the running nrepl. But I now don't have access to cider and all it gives me, including functionality from other plugins that require cider. The folks at #cider tell me they are very different dependencies but I can't get both the nrepl and the cider-nrepl dependencies in this shadow-cljs to work together. Any advice on how to get Cider working right (outside of emacs, I'm using vim)?:preloads*.thing-spec namespaces for dev builds but instrumentation is tricky enough. automating it entirely and getting that right reliably might be tricky:auto-spec true
;; or
:auto-spec {:only #{app.foo-spec app.bar-spec}}
;; or
:auto-spec {:except #{app.baz-spec}}
;; additional
:auto-spec {:include #{app.specs}}
release for the :browser target, has anyone experienced local paths appearing in the build artifact? im trying to figure out where that might be leaking in_where:"/Some/local/path" is in the shadow provide exportsrequire("package.json"). some js packages do thatTypeError: app.core is undefined whereas file exists and is set in shadow-cljs.edn
:modules
{:main
{:entries [app.core]}}
index.html directly of the filesystem you need to change the path)index.html, sorry for the noise 😉load-file-in-repl command is in emacs/cider solve this problem? that should be working normally?cider-load-file does is let you select a file, then it load.load-file which force loads the actual file from disk (cider-load-file "some.clj") in elisp.
but as almost every tutorial they will teach user use a command called C-c C-k, that is cider-load-buffer.
will load current buffer.load-file then that should be fine(defn foo [] 2) but in the file you have (defn foo [] 1)load-file right now.:require to foo.core will NOT trigger a reload of bar.core from diskload-file manuallyload-file as in the nrepl commandgoog.provide('bar.core');
goog.require('cljs.core');
//# sourceMappingURL=bar.core.js.mapbar.core. shadow-cljs watch kicks in and finds that the file is not used in the build so it is not compiledbar.core is never changed it isn't automatically replaced(load-file "/full/path/to/bar/core/cljs") in the REPL however that is done in cider should fix itload-file it should not be empty(require 'bar.core :reload) is broken so that does not fix itload-file(load-file "/full/path/to/bar/core.cljs")[:result {:type :repl/error, :ex #error {
:cause "symbol bar.core already provided by [:shadow.cljs.repl/resource \"bar/core.cljs\"], conflict with [:shadow.build.classpath/resource \"bar/core.cljs\"]"
:data {:provide bar.core, :conflict [:shadow.cljs.repl/resource "bar/core.cljs"], :resource-id [:shadow.build.classpath/resource "bar/core.cljs"]}
load-file should be overwriting that but could be that it doesn'tdoseq also hangs.:node-script build with watch the websocket connection used for the watch itself will keep the process alive:devtools {:enabled false}watch but only for the compilation part (or so I thought), running the output script manually each time.if looks broken#(do (if %1
(js/console.log %1)
(put! data-chan %2))
(close! data-chan)))(if <pred> <then> <else>)nil out of the channel at the end thanks to the close, though.node extract.jsshadow-cljs watch or not?watchwatchafter I added async thingsshadow-cljs node-repl if you want an actual REPLcljs.analyzer/with-warning-handlers but that seems to have no effect in shadow{:warnings true|false|{<warning-type true/false}}{:warnings :error} to treat all warnings as errors{:warnings {:undeclared-var :error}} to pick specific things that should be errors:warnings-as-errors true/false or :warnings-as-errors #{:only :these}:warnings-handlers approach seems a bit icky to me and not really user friendly{:warnings {:undeclared-var :error}}:warnings-as-errors true for all and with a set for more control{:warnings :error} to treat all warnings as errors
> {:warnings {:undeclared-var :error}} to pick specific things that should be errors:warnings might cause troubles later on the compile:warnings over :warnings-as-errors is that you’d be able to turn warnings off:warnings is a standard CLJS feature so turning them off is possible regardless:closure-warnings was a thing:compiler-options {:warnings {:undeclared-var false}} would disable that warning:error to throw instead of warning would be pretty straightforward. just not sure if it breaks other places that only expect a booleanclosure-defines feature{:closure-defines {my-app/FOO true}}, then try to use it somewhere, the compiler returns: Use of undeclared Var my-app/FOO(ns ) (goog-define FOO false):closure-defines { true}(ns ) (goog-define FOO false) I still get that compilation error(:require [ ...])?expected actual structures which works seamlessly with shadow-cljs?npx shadow-cljs compile devshadow-cljs - config: /Users/victor/Ericsson/code/cenx/apps/frontend/eric-cenx-ui/shadow-cljs.edn cli version: 2.8.41 node: v12.7.0 Execution error - invalid arguments to shadow.cljs.devtools.api/loading at (api.clj:1)
{:dev {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "/js/compiled"
:modules {:app {:entries [epiphany.core]}}}}npx shadow-cljs clj-repl work?clj-repl does the same thing------ ERROR -------------------------------------------------------------------
File: /.../common/ui/layout.cljs:572:26
--------------------------------------------------------------------------------
569 |
570 | (def css-button
571 | {:background-color "transparent"
572 | :border "1px solid #c49dc9"
--------------------------------^-----------------------------------------------
.../common/ui/layout.cljs [line 572, col 26] Invalid number: 1px." is actually ". I seen all sorts of weird stuff when copying " from skype or some other office crap":dev/after-load function, but my app isn’t rerendering at all. Editing a file further up the chain does the trick.node_modules while shadow-cljs is runningnpm install some-big-package-with-lots-of-dependenciesCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. when starting up one of my projects using 2.8.41. My project used to be usingh 2.8.8, and if I go back to that things work.deps.edn which changed and you must now add theller/shadow-cljs to your deps.edn manuallydeps.edn project on Windows. Since it needs clojure to run it also needs Powershell. I can make that happen, with some work. Would you say that checking for the existence of deps.edn is enough for detecting this situation before launching, @thheller?clojure can only be invoked in a Powershell environment. So if I just launch the process npx, this project fails. For general clojure-cli projects I therefore run clojure in a powershell.exe process. Thinking I could do the same for shadow projects that need clojure.2.8.40 or earlier2.8.8... It behaves differently with 2.8.41 indeed, but still seems to need some special quoting on my part. I get this error now: > Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/cider-nrepl:0.21.1 watch :app < npx: installed 92 in 12.938s shadow-cljs - config: e:\rn-rf-shadow\shadow-cljs.edn cli version: 2.8.41 node: v10.16.0 shadow-cljs - socket connect failed, server process dead? shadow-cljs - starting via "clojure" Unknown option: "-i" Unknown option: "-n" Unknown option: "-p" Unknown option: "-u" Unknown option: "-t" Unknown option: "-F" Unknown option: "-o" Unknown option: "-r" Unknown option: "-m" Unknown option: "-a" Unknown option: "-t" Unknown option: "-o" Unknown option: "-u" Unknown option: "-t" Unknown option: "-p" Unknown option: "-u" Unknown option: "-t" Unknown option: "-F" Unknown option: "-o" Unknown option: "-r" Unknown option: "-m" Unknown option: "-a" Unknown option: "-t"
-d cider/cider-nrepl:0.21.1 that is the issue-Sdeps EDN dataclojure. Could be the slash there that gets things interpreted as an options... 2.8.42. hope that sorts out all the powershell escaping issuesnpx: installed 92 in 8.673s
shadow-cljs - config: e:\rn-rf-shadow\shadow-cljs.edn cli version: 2.8.42 node: v10.16.0
shadow-cljs - starting via "clojure"
failed to start service
{:id :cljs-watch}
ExceptionInfo: failed to start service
shadow.runtime.services/start-many/fn--9540 (services.clj:135)
shadow.runtime.services/start-many (services.clj:126)
shadow.runtime.services/start-many (services.clj:105)
shadow.runtime.services/start-all (services.clj:144)
shadow.runtime.services/start-all (services.clj:139)
shadow.cljs.devtools.server/start-system (server.clj:370)
shadow.cljs.devtools.server/start-system (server.clj:242)
shadow.cljs.devtools.server/start! (server.clj:493)
shadow.cljs.devtools.server/start! (server.clj:411)
shadow.cljs.devtools.server/start! (server.clj:414)
shadow.cljs.devtools.server/start! (server.clj:411)
shadow.cljs.devtools.server/from-cli (server.clj:625)
shadow.cljs.devtools.server/from-cli (server.clj:601)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/lazy-invoke (cli.clj:24)
shadow.cljs.devtools.cli/lazy-invoke (cli.clj:21)
shadow.cljs.devtools.cli/blocking-action (cli.clj:131)
shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
shadow.cljs.devtools.cli/main (cli.clj:179)
shadow.cljs.devtools.cli/main (cli.clj:134)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:221)
shadow.cljs.devtools.cli/-main (cli.clj:219)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
IOException: Incorrect function.
sun.nio.fs.WindowsWatchService$Poller.implRegister (WindowsWatchService.java:433)
sun.nio.fs.AbstractPoller.processRequests (AbstractPoller.java:260)
sun.nio.fs.WindowsWatchService$Poller.run (WindowsWatchService.java:595)
java.lang.Thread.run (Thread.java:748)
It's this project: https://github.com/PEZ/rn-rf-shadowIncorrect function error when I run the project from that virtual box network mount. Things work if I run the project from the ”harddrive” of the Windows virtual machine.deps.edn anyways just call clj directly, eg clj -Stree or so"renegeratorRuntime" is undefined.renegeratorRuntime is some babel thing for transpiled code that needs to be included separately for some reason_uncontrollable.default is undefined which probably relates to the uncontrollable package. What’s the root issue? Who knows.(:require ["regenerator-runtime/runtime"]) before your JS requires.default is usually a problem with commonjs VS es6 codeclojure with the dev alias. picard-facepalmnode_modules/react-overlays/node_modules/uncontrollable — when there is a top-level node_modules/uncontrollable as well?uncontrollable packages included in your build 😉uncontrollable released a version 7.0 who’s only change is to break the default exports. Now all the consumers have to change, and of course not everyone has done yet.(defjson my-json "/some/path/to.json") and that macro slurped in the json file at the path is there a way to tell shadow-cljs that when I change the file at "some/path/to.json" it should recompile the cljs file I've used the macro in?(js/console.log "foo") is mapped correctly(def styles
^js (-> {:container
{:flex 1
:backgroundColor "#fff"
:alignItems "center"
:justifyContent "center"}
:title
{:fontWeight "bold"
:fontSize 24
:color "blue"}}
(clj->js)
(rn/StyleSheet.create)))
(defn bad-press [e]
(js/console.log "pressed the bad button")
(throw (ex-info "button pressed" {})))
(defn root []
(react/createElement rn/View #js {:style (.-container styles)}
(react/createElement rn/Text #js {:style (.-title styles)} "Hello!")
(react/createElement rn/Button #js {:onPress (fn [e] (bad-press e))
:title "error"})))js/console.log is properly mapped in chrome:npm-module target and while (r/inline "/my/path") inlines the resource it doesn’t recompile the file i’m using it in when the resource changes during the watch. This does work for the :browser target though.:npm-module within storybook, but I’ve confirmed that it’s shadow not rebuilding the files by looking at the generated source in my out dir:browser target?shadow-cljs watch app --verbose yes[:stories] Compiling ... -> build target: :npm-module stage: :resolve -> Resolving Module: :main <- Resolving Module: :main (31 ms) <- build target: :npm-module stage: :resolve (34 ms) -> build target: :npm-module stage: :compile-prepare <- build target: :npm-module stage: :compile-prepare (0 ms) -> Compile CLJS: project/ui/stories/button_stories.cljs <- Compile CLJS: project/ui/stories/button_stories.cljs (20 ms) -> Cache write: project/ui/stories/button_stories.cljs <- Cache write: project/ui/stories/button_stories.cljs (19 ms) -> build target: :npm-module stage: :compile-finish <- build target: :npm-module stage: :compile-finish (0 ms) -> build target: :npm-module stage: :flush -> NPM module flush: /Users/colinkahn/code/project-web/out/stories <- NPM module flush: /Users/colinkahn/code/project-web/out/stories (34 ms) <- build target: :npm-module stage: :flush (35 ms) [:stories] Build completed. (412 files, 1 compiled, 0 warnings, 0.23s)
/Users/colinkahn/code/project-web/out/stories?out/stories/project.ui.stories.button_stories.js:after-load for a module instead of for a build? (Tried the obvious thing and it had no effect)shadow-cljs release app it fetches again the clojure dependencies, is there a way to configure Shadow so i can try this approach for cache https://gitlab.com/gitlab-org/gitlab-ce/issues/52407#note_133093686 ?MAVEN_OPTS ?shadow-cljs server, I get this error
shadow-cljs - config: /home/mavbozo/yolo/znet/machine/shadow-cljs.edn cli version: 2.8.42 node: v11.6.0 shadow-cljs - updating dependencies shadow-cljs - dependencies updated Execution error (IllegalStateException) at com.google.common.base.Preconditions/checkState (Preconditions.java:823). Externs must contain builtin for env BROWSER: whatwg_console.js Full report at: /tmp/clojure-9009315503829928826.edn
shadow-cljs - config: /home/mavbozo/yolo/znet/machine/shadow-cljs.edn cli version: 2.8.39 node: v11.6.0 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - server version: 2.8.39 running at shadow-cljs - nREPL server started on port 41083
:mvn/local-repo variable from shadow-cljs ?:maven {:local-repo "foo"} in shadow-cljs.ednshadow-cljs info will download all deps when using shadow-cljs.edn to manage deps.cljc and .cljs file with the same name and namespace?.cljc is strictly a macro namespace yes. otherwise no."shadow-cljs": "2.8.40" in package.json & [fulcrologic/fulcro "2.8.12"] in shadow-cljs.edn's :dependencies. If I removed the fulcrologic/fulcro 2.8.12, shadow-cljs server works. I've created a demo repo here https://github.com/mavbozo/shadow1[fulcrologic/fulcro "2.8.12" :exclusions [org.clojure/clojurescript org.clojure/core.async]] instead:dependencies [ [fulcrologic/fulcro "2.8.12" :exclusions [org.clojure/clojurescript org.clojure/core.async]] ]
org.clojure/google-closure-library and com.google.javascript/closure-compiler-externs to the exclusions:eval, source map problem is already fixed?master has the switch to eval as a default but it is incomplete and cannot be used yet:loader-mode is only a thing for browser builds currentlyrequire in general but mostly affects images yeseval stuff in master it is currently not possible to use images so that needs to be solved before I can release thatjs/require is the non-magic way. But it is the magic in React-Native.:node-script yourself to REPL into intoshadow-cljs node-replnode target/main.jsshadow-cljs node-repl in another terminal, it said shadow-cljs - connected to server, but emacs REPL still gives the same error:node-repl:app you need to run node target/main.js manually elsewherenode-repl I can't help you since I have no clue how cider handles thatnode target/main.js immediately exitsnode-repl but I cannot comment about the cider partsshadow-cljs node-repl you get a REPL right awayshadow-cljs node-repl is what you want.
What should happen is:
1. Run cider-jack-in-cljs, choose shadow for repl type, and then enter your node app build ID. If it asks you to open a browser window, say no.
2. Once you see the “build completed” message for the first time in the CIDER REPL buffer, in a terminal session run node <path/to/output.js> like configured in your shadow-cljs.edn
If you have devtools enabled, it should start the app and keep it open, hot loading your changes while you develop your appnode-repl since there is no point linking to a specific build if you just want a REPLmodule$node_modules$aws_sdk$lib$aws errorfoo def, no matter which file you save that won’t be recompiled with project.module or project.core.shadow-cljs browser-repl and run (require '["whatever-from-npm" :as x])watch but the browser-repl seems to be much betterwatchbrowser-repl is just a watch with a default configshadow-cljs browser-repl does from the resulting prompt(shadow/watch :browser-repl) (shadow/repl :browser-repl) then I can connect like the prompt:frontend running you should REPL into that too(shadow/watch :browser-repl) won't work if its not already running:browser config should just work out of the box(require '["aws-sdk" :as AWS]) - when I run the latter it seems to load the module, but the ns require seems to not load the AWS var properlyns require should be fine since it does exactly the samens however, when I try to reference AWS I get this:
ReferenceError: module$node_modules$aws_sdk$lib$aws is not defined
at eval (eval at <anonymous> (), <anonymous>:1:1)
at
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
at WebSocket.<anonymous> ()(require '["aws-sdk" :as AWS]) in the same namespace and then the AWS reference begins to work properlyns in the REPLns s-expression in the REPLshadow-cljs browser-repl but not in a regular :browser build?ns command returns nil but does not create the AWS references in the :brower-repl versionns macro and so I had to use the (require..) function in the namespace.
Thinking on it overnight I realized that this new ns wasn't referenced by the app and so I added it to the app's ns and now things work.
So, I don't know if that's intended or not but it looks like there just has to be a path to the desired ns at repl startup or else things get a little off.
Thanks for your help and for making such a great tool.NODE_ENV to development so React will give me the error?shadow-cljs check? Maybe it helps, I would have liked to know about it earlier a few months ago 🙂:infer-externs :auto turned on? it is most likely related to missing externs and using property access for something https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externsparadigm. However when I followed the technique described to convert CLJSJS packages things went wrong in a weird way when released. Somehow the code was optimizing in a way that js/paradigm was resolving to the cljs paradigm namespace rather than the paradigm that we exported globally. I have no clue why this was happening only on a release build but worked fine in dev. Changing the namespace to avoid clashing with the global object fixed it.firebase serve, the app works, but if i do shadow-cljs release main (main is the app build), and do firebase serve I get errors for firebase. It does not initialize firebase and app does not show up. Is there a way to test advanced build using shadow-cljs?:dev {:compiler-options
{
:optimizations :advanced
:closure-defines {re_frame.trace.trace_enabled? true
day8.re-frame.tracing.trace-enabled? true
;goog.DEBUG false
}}}
:advanced optimizations on the buildshadow-cljs release main --debug:dev,:optimizations :advanced on the normal (non-release) builds? using that key value on compiler-options did not seem to create advance optimized builds Uncaught TypeError: firebase.initializeApp is not a function on the "release" versionfirebase in your app?re-frame-firebase library. I don't call firebase directly.js/firebase that library uses[cljsjs/firebase "5.7.3-1"]cat node_modules/@firebase/app/package.json(ns (:require ["@firebase/app" :default firebase])
"name": "@firebase/app", "version": "0.4.11", ...
"firebase": "^6.3.1",:browser build:modules maybe?:modules {:main {:entries []}}firebase variableshadow-cljs release main --pseudo-names and debug it in the browser(fn [foo] foo) it returns the following stack trace:(fn [foo] foo) it returns the following stack trace:SyntaxError: Unexpected token .
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
at WebSocket.<anonymous> ()
(fn foo-fn [foo] foo) seems to work as expected(function cljs$user$cljs.user.cljs(foo){\r\nreturn foo;\r\n}) which is invalid JSshadow-cljs release app shadow-cljs - config: /Users/den/Dropbox/dev/code/zeal/shadow-cljs.edn cli version: 2.8.42 node: v8.11.1 shadow-cljs - connected to server Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:381). shadow.cljs.devtools.cli
shadow.cljs.devtools.cli wherever you start the server:dependencies for a build?
as with clj's :extra-deps
Long:
In a shadow-cljs project, I'm having two build aliases,
which are being used as
shadow-cljs watch local shadow-cljs release prodI'm using
re-frisk as a dependency,
How would I include re-frisk as dependency only for :local build?
i.e. not include it in :prod{:builds
:dependencies [[re-frisk "version"]]
{:local
{:target :browser
:devtools {:preloads [[re-frisk.preload]]}}
:dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
:extra-deps {
nubank/workspaces {:mvn/version "1.0.9"},
binaryage/devtools {:mvn/version "0.9.10"}
day8.re-frame/re-frame-10x {:mvn/version "0.4.1"}
day8.re-frame/tracing {:mvn/version "0.5.1"}
}
}
:prod
{:target :browser}}
}
deps.edn to define that :dev like:
{:paths [...]
:deps {;actual deps here
}
:aliases {:dev {:extra-paths [...]
:extra-deps {...}
}
}
`
and in shadow-cljs.edn :
{:deps {:aliases [:dev]}
:builds {:local ...}}
...
}
:preloads are only used in development builds so it automatically won't be included in the release buildload-file op it responds with err messages (ex: {'id': '874b6a4f-5419-4acc-3f82-bdca8708ac7d', 'session': 'acf389b9-51cb-4231-8499-1a9ee17fa53d', 'err': 'WARNING: No such namespace: str, could not locate str.cljs, str.cljc, or JavaScript source providing "str" at line 24 /path/to/file.cljs^@'}) but shadow-cljs just responds with a {'status': ['done'] ...} message(shadow/watch :app) API but load-file still just returns ['done']shadow-cljs start to start a background server, if that makes a differenceshadow-cljs watch :app) and the webpage (via the HUD/overlay) both report the errors just fine, but I was hoping to also get them via the nrepl connection for displaying in Vimcat tests/tests.first_test.js
goog.provide('tests.first_test');
goog.require('cljs.core');
test("Adds 1 + 2 to equal 3",(function (){
return expect(((1) + (2))).toBe((3));
}));
var $CLJS = require("./cljs_env");
var $jscomp = $CLJS.$jscomp;
require("./cljs.core.js");
var module$shadow_js_shim_module$react=$CLJS.module$shadow_js_shim_module$react || ($CLJS.module$shadow_js_shim_module$react = {});
var clojure=$CLJS.clojure || ($CLJS.clojure = {});
var cljs=$CLJS.cljs || ($CLJS.cljs = {});
var shadow=$CLJS.shadow || ($CLJS.shadow = {});
var goog=$CLJS.goog || ($CLJS.goog = {});
var reagent=$CLJS.reagent || ($CLJS.reagent = {});
var app=$ || ($ = {});
var taoensso=$CLJS.taoensso || ($CLJS.taoensso = {});
var module$shadow_js_shim_module$create_react_class=$CLJS.module$shadow_js_shim_module$create_react_class || ($CLJS.module$shadow_js_shim_module$create_react_class = {});
var tests=$CLJS.tests || ($CLJS.tests = {});
var module$shadow_js_shim_module$react_navigation=$CLJS.module$shadow_js_shim_module$react_navigation || ($CLJS.module$shadow_js_shim_module$react_navigation = {});
$CLJS.SHADOW_ENV.setLoaded("tests.first_test.js");
goog.provide('tests.first_test');
goog.require('cljs.core');
test("Adds 1 + 2 to equal 3",(function (){
return expect(((1) + (2))).toBe((3));
}));
module.exports = tests.first_test;
//# sourceMappingURL=tests.first_test.js.map
index.js require should be the same but depending on what you were doing it maybe changed?"testMatch": [
"**/*+(_test).js"
]
is my matcher:react-native build?<output-dir>/index.jsimport './app/shadow.cljs.devtools.client.react_native';
import { init } from './app/app.core';
init();
so we were using it wrong.import "./app/index.js":npm-module targetindex.js itselfmetro throws an exception when an error is thrown in the appindex.js matters and contains all code:npm-module buildlein with-profiles +cljs repl Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1). Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1). Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1). Syntax error compiling var at (/private/var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/form-init6039849328054616621.clj:1:10151). Unable to resolve var: shadow.cljs.devtools.server.nrepl/cljs-load-file in this context Full report at: /var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/clojure-2400420031541069613.edn Subprocess failed REPL server launch timed out. Error encountered performing task 'repl' with profile(s): 'base,system,user,provided,dev,cljs' REPL server launch timed out.
$ lein -v Leiningen 2.9.1 on Java 11.0.2 OpenJDK 64-Bit Server VM
lein -v Leiningen 2.9.1 on Java 1.8.0_144 Java HotSpot(TM) 64-Bit Server VM
:none for {:js-options {:js-provider :shadow}}? Debugging with source maps is PITA.;; :whitespace or :simple work but some patterns really require the DCE done by :simple ;; eg some conditional imports done by react&friendsSo apparently the answer is no. Oh well.
:simple is a must but you can use {:source-map false :pretty-print true :variable-renaming :off}:js-options?
I'm trying to debug a nice library called react-beautiful-dnd. Not sure why, but it seems that the source maps are not aligned with the source code itself - breakpoints are set on different lines, and when they hit I get a completely different context from what I'd expect. I'll try cleaning everything and rebuilding.:js-optionsx with some particular content but in the Scope panel its content resides within y. Whereas y could not possibly have such a value. But it may be an issue with V8 (I think?) optimizing some variables away. It basically removes some of the variables completely, and you cannot disable it. Drives me nuts.var _action$payload = action.payload;
state = _action$payload.critical;
action = _action$payload.dimensions;
state and action have been used before but now a piece of code const {critical, dimensions} = action.payload; has been turned into that abomination with variable reuse.const {critical, dimensions} = action.payload is represented as is, the Scope panel should correctly display variables named critical and dimensions. However, the above code is compiled into that snippet with var _action$payload which reuses variables. Because of that, the Scope panel now displays the value of action.payload.critical as belonging to the state variable. Of course, it is correct from the POV of the compiled code. But in this case, I can just throw away the original source code since it can't help me at all because of all the renaming and reuse.npm ci && shadow-cljs compile main, check the file at public/js/cljs-runtime/module$node_modules$react_beautiful_dnd$dist$react_beautiful_dnd_cjs.js and look for INITIAL_PUBLISH must come after a IDLE phase. Compare the following few lines to the code after the same string at node_modules/react-beautiful-dnd/src/state/reducer.js.:js-options. Since between us you're the the only one with the relevant domain knowledge, I thought that maybe this behavior can somehow be changed, if that makes sense.const {a} = b; is compiled into something like variable_used_before = b.a; instead of just const a = b.a;. The variable reuse is what makes it hard to debug since the old value is now hidden and the name how has wrong semantics.:simple optimizationsnode_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js this is the file shadow-cljs uses in the first placeconst use in thereconst {a} = b; can already be run in the modern browsers, which should probably be used for the main development workflow anyway.
> you are not saying WHY you are looking at that code
Because it's not relevant to the issue with the compiler itself. 🙂 "Give a man a fish" and all that.
> optimized code isn't intended to be readable
I agree. But because we have to run some optimizations even during development, it makes debugging hard - that's my whole point.
> node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js this is the file shadow-cljs uses in the first place
Oh... OK. Well const itself doesn't change anything thought - that file still got the naming correct. E.g. the relevant section has critical = _action$payload.critical which in the compiled version looks like state = _action$payload.critical. Again - there is no error here of any kind. It just makes it much harder to understand what's going on during debugging, regardless of the reason why someone is trying to understand what's going on.:whitespace and DCE or even have just DCE without any other optimizations?:nrepl-middleware in the :cljs profile it starts up..server.nrepl to ..server.nrepl04 in the :nrepl-middleware map/sockjs-node/* in chrome (didn't work on firefox)error SHA-1 for file /home/tianshu/sandbox/expo-proj/awesome/app/rn-input.android.is (/home/tianshu/sandbox/expo-proj/awesome/app/rn-input.android.is) is not computed. Run CLI with --verbose flag for more details.node v10.16.0 shadow-cljs 2.8.45 expo 34.0.1
:react-native and it works great!GET net::ERR_INSUFFICIENT_RESOURCES
:devtools {
:loader-mode :eval
}
:loader-mode :eval in :devtools of your build in shadow-cljs.ednnpx shadow-cljs watch app without a running server:loader-mode :eval do?<script... tag instead of many["@material-ui/core/Button" :as Button]) - which is the recommended import. I remember this enables easier Tree-Shaking for Webpack.
Is there any downside in just importing multiple exports at once ["@material-ui/core" :refer [Button CircularProcess]] in shadow-cljs?
I guess google closure should be able to remove unnecessary code well enough or am I mistaken?:simple optimizations which means it won't do dead code removal:refer does nothing for DCE. you need the specific imports for now:loader-mode solved your question. I was stating that the article which solved a completely different problem had a "side rant" in it that actually answered your question:require and I need to def lazy-component wrap each fully qualified namespaced component. Is that right?:require the namespaces will be moved to that module and cannot be code-splitlazy-component however is just a proof of concept that combines it with React componentsnew Worker vs navigator.serviceWorker:web-worker true option also works for service workersasset-path in code?js/CLOSURE_BASE_PATHclass property sync with the selector in css.
2. less runtime stuff, as static as possible
3. manipulate style with functions.css files but instead injects the css at runtimeshadow-cljs.edn but it's definitely possible with shadow-cljs.edn + deps.edn.deps.edn. It's just an additional flag in shadow-cljs.edn: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edndeps.edn ...shadow-cljs while specifying profiles but I bet you could do it if you launch it via lein itself.clj build will be moving to deps.edn at some point soon, and i'm using gulp to run shadow atm, which is working very nicelyTypeError: shadow.js.shim.module$react_native.Text is not a function while trying to use :react-native target. ns looks like this:
(ns my-app.mobile
(:require ["expo" :as ex]
["react-native" :as rn]
[rum.core :as rum]
[shadow.expo :as expo]
))
(rum/defc root
[]
(rn/Text #js {} "TEST"))
(defn ^:dev/after-load mount
[]
(expo/render-root (root)))
(defn start!
[]
(mount))
Seems like "react-native" is defaulting to some kind of shadow shim, but I’m likely doing something wrong…(rum/defc root
[]
(r/createElement rn/Text #js {} "TEST"))
r is required like ["react" :as r](rn/Text #js {} "TEST") but Text is a react element not a function[:> rn/Text "Test"](defn >$ [class props & children] (apply r/createElement class (clj->js props) children)) (def view (partial >$ rn/View)) (def text (partial >$ rn/Text))
:> helper in reagent is doing something similar(ns my.ns (:require ["@firebase/app" :refer [firebase]])) (def firebase firebase)
(def firebase firebase)(ns my.ns (:require ["@firebase/app" :as x])) (def firebase x/firebase)
deps.cljs with {:npm-deps {"foo" "version"}} in your .jarnpm install on the packages listed in deps.cljs on startup? (if they aren't already in package.json)shadow-cljs CLI and running via lein with lein run -m shadow.cljs.devtools.cli and :lein true ?:npm-deps and :foreign-libs ? For example
The required namespace "react" is not available, it was required by "day8/re_frame_10x/inlined_deps/reagent/v0v8v0/reagent/core.cljs". The namespace was provided via :foreign-libs which is not supported. Please refer to for more information. You may just need to run: npm install react
:foreign-libs is a different mechanism. has nothing to do with :npm-depsdeps.cljs at the root in your distributed .jar filepackage.json ?:npm-deps. May I ask where the source is and if you accept pull requests on docs ? I also wanted to add :external-config to the compiler options which is missing.:external-config is not a thing in the compiler. it is purely community convention?:compiler-options { :external-config {:devtools/config {:features-to-install [:formatters :hints]}}} does work for cljs devtools.cljs-devtools by directly looking at the compiler-options(get-in @cljs.env/*compiler* [:options :external-config :devtools/config]). 👍:external-config key because of figwheel which had "strict" validation of the compiler-options map:npm-deps / :foreign-libs. For something like re-frame that needs to maintain compatibility with multiple build systems would it be recommended to simply declare both ?deps.cljscljsjs/react etc works but is helped by including a deps.cljs with :npm-depsdeps.cljslein-shadow plugin @thheller?:npm-deps out of project.clj. Might it make more sense from a design perspective for such a plugin to get that out of deps.cljs directly ?project.clj and deps.cljs.:npm-deps at allpackage.json IMHOdeps.cljspackage.json from :npm-deps key in project.clj. A bit of a hack, but it works.package.json AND the lockfiles (eg. package-lock.json) if you want anything remotely reliablenpm directly is going to mess things updeps.cljs - If you are working directly in a libs project (in this case, it behaves like an 'app') you would need to duplicate deps between both package.json and deps.cljs ?package.json as deps.cljs; i.e. it is repeatable. Then it is OK ?package.json for developmentdeps.cljs when neededlein-sahdow) :npm-deps should be taken from a deps.cljs not from project.clj.deps.cljs is that you need to run a JVM with the full classpath to get them:npm-deps mappackage.json. period. don't outsource it to anything else.deps.cljs is problematic but works ok-ish until you run into version conflictsdeps.cljspackage.json based on deps.cljs as a standard or is that a space you don't want to go ?deps.cljs handling shadow-cljs currently does is all I'm willing to dodeps.cljs with :npm-deps on startup, do a best effort conflict resolution, run npm install if the package is not in package.json alreadynode_modules folder structurenpm install etc. and keep the lock files in version controlnpm install the-thing will end up with the same dependenciesdeps.cljs as per above - https://github.com/reagent-project/reagent/pull/441 @thhellerlet wish = require('shadow-cljs.wishful-repl');
wish.startRepl();
and then be able to connect to it using e.g. cider-mode or inf-clojure-mode, and eval cljs-code in the context of the browser page 🙂 I hope I'm making senserequire I'm going to guess that something like webpack is usedwindowwindow.reactRoot = ... then in the repl js/window.reactRoot:browser build and load that normally alongside your JS projectappliedscience/js-interop 🙂js-interop doesn't? 🙂js-interop comes with its own get-in etcre-frame/dispatch in the fn-to-call-on-load callback)(rf/dispatch ...) instead of a fn (eg. #(rf/dispatch ...) to the loader as a callback. My bad, all good. I confirm you can load modules that contain re-frame event definitions (eg. (rf/reg-event-fx...) dynamicallylocalhost:8280, and as a result any attempts to run an async HTTP request (GET https://google.com for instance) are forced to the same uri.
GET 404 (Not Found)Since shadow-cljs is the thing serving the page during development, how can I get it to include the CORS headers? I noticed that it has some code to do this at https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web/api.clj#L180 , but I'm not clear on how to get it to activate
+handler will allow you to bring a server up on localhost:3000, but it doesn't seem possible to hit
• If you're using Ring on the serverside, you can use ring-CORS https://github.com/r0man/ring-cors
• If you're using Aleph with Compojure (my case), see https://github.com/muhuk/aleph-middleware
Your routes should look like so:
(def handler
(-> (compojure/routes
(GET "/" [] root-handler)
(GET "/healthz" [] healthcheck-handler)
(route/not-found "No such page."))
(middleware.cors/wrap-cors :access-control-allow-methods #{:get}
:access-control-allow-headers #{"content-type"}
:access-control-allow-origin #"[\s\S]+")
(params/wrap-params)))
Note the #"[\s\S]+" regex -- this matches any incoming request, but you can also use it to limit the origin.
tested with [aleph "0.4.6"], [aleph-middleware "0.2.0"], [ring-cors "0.1.10"], [compojure "1.6.1"].js files that shadow-cljs has generatedre-frame-template into it, plus getting cider-jack-in-cljs working with it.
Though it sounds like I could blindly have the Boot webserver serve the client's resources/index.html from the filesystem?nil to the URLNo application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code., when I’m running shadow-cljs watch app in one terminal, shadow-cljs cljs-repl app in another, and expo-cli start --lan -c in the third.expo app has not connected back to the shadow-cljs processwebsocket connected message when you start the appWebSocket connected! REPL init successful Running application on iPhone SEin the logs sometimes, but still get the can’t connect issue. It’s almost like it’s connected to somewhere else
watch and the cljs-repl have different nrepl ports, is this relevant?Uncaught TypeError: Cannot read property 'BaseModel' of undefined
at o.t$jscomp$0.PortModel [as constructor]
(ns test.storm
(:require ["@projectstorm/react-diagrams" :as storm]
["react" :as react]
["react-dom" :as react-dom]))
(defn doit []
(let [engine (doto (storm/DiagramEngine.) (.installDefaultFactories))
model (storm/DiagramModel.)
node1 (doto (storm/DefaultNodeModel. "Node 1" "rgb(0,192,255)") (.setPosition 100 100))
port1 (.addOutPort node1 "Out")
node2 (doto (storm/DefaultNodeModel. "Node 2" "rgb(0,192,255)") (.setPosition 400 100))
port2 (.addOutPort node2 "In")
link1 (.link port1 port2)]
(.addAll model node1 node2)
(.setDiagramModel engine model)
(react-dom/render
(react/createElement
(storm/DiagramWidget.
#js {:className "srd-demo-canvas"
:diagramEngine engine}))
(js/document.getElementById "app"))))
"dependencies": {
"@projectstorm/react-diagrams": "5.3.2",
"closest": "0.0.1",
"create-react-class": "^15.6.3",
"dagre": "^0.8.4",
"lodash": "^4.17.15",
"mathjs": "^6.0.4",
"pathfinding": "^0.4.18",
"paths-js": "^0.4.10",
"react": "^16.9.0",
"react-dom": "^16.8.6",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.6"
},
(react/createElement
storm/DiagramWidget
#js {:className "srd-demo-canvas"
:diagramEngine engine})import {
DiagramEngine,
DiagramModel,
DefaultNodeModel,
LinkModel,
DiagramWidget,
DefaultLinkModel
} from "@projectstorm/react-diagrams";
import * as React from "react";
import * as ReactDOM from "react-dom";
//1) setup the diagram engine
var engine = new DiagramEngine();
engine.installDefaultFactories();
//2) setup the diagram model
var model = new DiagramModel();
//3-A) create a default node
var node1 = new DefaultNodeModel("Node 1", "rgb(0,192,255)");
node1.setPosition(100, 100);
let port1 = node1.addOutPort("Out");
//3-B) create another default node
var node2 = new DefaultNodeModel("Node 2", "rgb(192,255,0)");
node2.setPosition(400, 100);
let port2 = node2.addInPort("In");
// link the ports
let link1 = port1.link(port2);
//4) add the models to the root graph
model.addAll(node1, node2, link1);
//5) load model into engine
engine.setDiagramModel(model);
//6) render the diagram!
ReactDOM.render(
React.createElement(DiagramWidget, {className: "srd-demo-canvas", diagramEngine: engine}, null),
document.getElementById("app")
);
(storm/DiagramWidget. ...)?new DiagramWidget(), ...:compiler-options {:output-feature-set :es6} I still see the same error I was seeing beforewatch, maybe it is in a confused state or somethingshadow-cljs, leiningen and cursive IDE in Intellij. I want to start a repl of clojurescript in the Intellij, and do as following:
Add a port config in
clojure
:nrepl {:port 9600}
Add
I add a Clojure REPL of Remote with the Host 127.0.0.1, and Port 9600.
Start shadow-cljs Server in Terminal
I open a terminal and do:
# app is the app-id $ shadow-cljs watch appRun the REPL to connect the Server in Intellij I click the green button of the
run in the left-top of of Intellij.
As default, it will connect a clojure REPL, and I can't switch it to clojurescript REPL. How should I do? And I also want to load the project to REPL, too. Is there anyone having an experience about it?npm-module, then use it in Expo App.js.:npm-module is tricky with regards to REPL setup. can you not use the proper :react-native target?App.js, it's convenient, so I don't think more about it. The :react-native target is enough simple?:npm-module you must set :runtime :react-native in your build configApp.js require("./app/shadow.cljs.devtools.client.react-native")(shadow.cljs.devtools.api/repl :app) to switch to the CLJS repl for :appNo application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.:npm-module target has to do this manual setuprequire("./app/shadow.cljs.devtools.client.react-native") in App.js? Are there another operations in App.js? At beginning, I just refer npm-module compiled and export a App(), just as default of expo init yields.websocket, I start expo and run it on IPhone, then it print WebSocket disconnected with a long Map.shadow-cljs watch app --verboseshadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}':local-ip in your build configlocal-ip. I don't know how the shadow-cljs work and which ip to set for it. It's My work environment:#1. start shadow-cljs and expo on two terminals; #2. set shaodw-cljs nREPL port 9600, which in localhost and LAN, you can connecnt it in any one; #3. set Cursive nREPL remote host and port 127.0.0.1:9600; #4. Run app on IPhone by QR code with LAN optionLAN as host. It doesn't work too.ifconfig but I can't remember192.168.1.5 or soNo application has .... toolocal-ip as the IP of my OSNo application has ....expo start if config as above."The operation couldn’t be completed. Connection refused":npm-module?:npm-module have some problem when work with expo?react-native as target, works well.:npm-module?:target :react-native is meant for expo as wellexpo docs first, it looks like use App.js as a entry file is very simple, and needn't manually add AppRegistry. So I do it as in clojurescript.rm -rf app/* && shadow-cljs release app:preloads yes (and you just run the code directly)lein-cljfmt plugin. I am trying to run cljfmt using shadow-cljs run but it looks like shadow-cljs is trying to consume my --file-pattern argument for itself.npx shadow-cljs run cljfmt.main/-main -- fix --file-pattern '\/[^.]+\.clj[sxc]?$' src test-- is sort of convention on linux or soshadow-cljs with Cider, but got this error:
user> (server/start!) Aug 15, 2019 8:05:01 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.7.2.Final Aug 15, 2019 8:05:01 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.7.2.Final Aug 15, 2019 8:05:01 PM org.jboss.threads.Version <clinit> INFO: JBoss Threads version 2.3.2.Final shadow-cljs - server version: 2.8.42 running at shadow-cljs - nREPL server started on port 9876 :shadow.cljs.devtools.server/started user> (shadow/watch :app) [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (175 files, 1 compiled, 0 warnings, 2.73s) :watching user> (shadow/nrepl-select :app) Execution error (IllegalStateException) at shadow.cljs.devtools.api/nrepl-select (api.clj:377). Can't change/establish root binding of: *nrepl-cljs* with setlast two lines
shadow.cljs.devtools.server.nrepl04 instead of shadow.cljs.devtools.server.nreplnrepl04 middleware worked perfectly simple_smileoutput-to at :browser target.
I want make my src/main/resources/public/compiled directory clean.
Of course I can delete it before build.shadow-cljs at all, but: Any recommendations or common practice to separate CLJ vs CLJS deps (in the same source tree)? All open projects I've looked at seem to keep all deps together... which I don't likelein I usually create a :cljs profile there I put my CLJS deps (eg. the shadow-cljs project itself)shadow-cljs.edn and server side in a separate deps.ednshadow-cljs the name of the deps.edn file? (say, deps.cljs.edn?).lein-tools-deps... which has the option to do sodeps.ednproject.clj, this seems to work: :lein-tools-deps/config {:config-files [:install :user "./deps.clj.edn"]}lein-tools-depsThe required JS dependency "object-assign" is not available, it was required by "node_modules/react/cjs/react.production.min.js". Yes, I'm aware I could also use npm to install object-assign, but this just doesn't seem right to me. Sorry, I'm sure this is a question that's repeatedly asked. I've looked at a lot of examples and I don't see anything different between them and what I have. PS - I did repeatedly npm install all missing dependencies and it does eventually compile.object-assign should have been installed when you did npm install react since it is listed as one of its dependencies? https://unpkg.com/react@16.9.0/package.jsonnode_modules folders are modifiednpm install react ...node -v?# node -v v8.10.0
npm -v?# npm -v 3.5.2
# npm install -g ... # ll /usr/lib/node_modules/ drwxr-xr-x 1 root root 4096 Aug 15 20:52 ./ drwxr-xr-x 1 root root 4096 Aug 15 20:51 ../ drwxr-xr-x 3 root root 4096 Aug 15 20:52 create-react-class/ drwxr-xr-x 8 root root 4096 Aug 15 20:51 npm/ drwxr-xr-x 5 root root 4096 Aug 15 20:52 react/ drwxr-xr-x 5 root root 4096 Aug 15 20:52 react-dom/Vs
# npm install ... # ll node_modules/ drwxr-xr-x 25 root root 800 Aug 15 20:55 ./ drwxr-xr-x 19 root root 608 Aug 15 20:55 ../ drwxr-xr-x 3 root root 96 Aug 15 20:55 .bin/ drwxr-xr-x 10 root root 320 Aug 15 20:55 asap/ drwxr-xr-x 20 root root 640 Aug 15 20:55 core-js/ drwxr-xr-x 9 root root 288 Aug 15 20:55 create-react-class/ drwxr-xr-x 9 root root 288 Aug 15 20:55 encoding/ drwxr-xr-x 10 root root 320 Aug 15 20:55 fbjs/ drwxr-xr-x 8 root root 256 Aug 15 20:55 iconv-lite/ drwxr-xr-x 6 root root 192 Aug 15 20:55 is-stream/ drwxr-xr-x 14 root root 448 Aug 15 20:55 isomorphic-fetch/ drwxr-xr-x 7 root root 224 Aug 15 20:55 js-tokens/ drwxr-xr-x 10 root root 320 Aug 15 20:55 loose-envify/ drwxr-xr-x 13 root root 416 Aug 15 20:55 node-fetch/ drwxr-xr-x 6 root root 192 Aug 15 20:55 object-assign/ drwxr-xr-x 17 root root 544 Aug 15 20:55 promise/ drwxr-xr-x 14 root root 448 Aug 15 20:55 prop-types/ drwxr-xr-x 9 root root 288 Aug 15 20:55 react/ drwxr-xr-x 18 root root 576 Aug 15 20:55 react-dom/ drwxr-xr-x 9 root root 288 Aug 15 20:55 react-is/ drwxr-xr-x 9 root root 288 Aug 15 20:55 safer-buffer/ drwxr-xr-x 12 root root 384 Aug 15 20:55 scheduler/ drwxr-xr-x 5 root root 160 Aug 15 20:55 setimmediate/ drwxr-xr-x 12 root root 384 Aug 15 20:55 ua-parser-js/ drwxr-xr-x 8 root root 256 Aug 15 20:55 whatwg-fetch/
# nodejs -v v12.8.1 # npm -v 6.10.2Looks like global installs cannot be supported by shadow-cljs
user.clj working? he is explicitely starting dirac agent inside his nrepl server here: https://github.com/kurtharriger/shadow-cljs-examples/blob/dirac/dev/user.clj#L6lein repl ::react-native is still incomplete but here is an example with expo https://github.com/thheller/reagent-expo and without https://github.com/thheller/reagent-react-native(foo 1 2 3) when foo is nil"pause on exceptions" in chrome2.8.48 shows warnings more reliablywebpack-dev-server allows me to manually type URLs that utilize dynamic routes into the address bar (during development). Is there a way to configure shadow-cljs to the the same? If I try to type anything other than the root page I get an error.This site can't be reached The webpage at might be temporarily down or it may have moved permanently to a new web address. ERR_INVALID_RESPONSE
curl -v -H "Accept: text/html" or so% curl -v -H "Accept: text/html" ✹ * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 3000 (#0) > GET /graphiql HTTP/1.1 > Host: localhost:3000 > User-Agent: curl/7.54.0 > Accept: text/html > < HTTP/1.1 404 Not Found < Connection: Keep-Alive < Cache-Control: private, no-cache < Server: Aleph/0.4.4 < Content-Type: application/octet-stream < content-length: 0 < Date: Fri, 16 Aug 2019 19:25:44 GMT < * Connection #0 to host localhost left intact
M-x cider-jack-in-cljs, but it fails with below output
[:app] Configuring build. [:app] Compiling ... shutting down ... user> *** Closed on Fri Aug 16 21:22:00 2019 ***Is there a way to view the exception causing compilation to fail, some sort of logs? In my scenario right now, running
lein dev still works without any errors in the browser console on page loadcider-jack-in-cljs. not the slightest clue what that does.create-react-app app https://github.com/thheller/reagent-react-integration/blob/shadow-cljs/src/index.js[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! [WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor! Syntax error compiling var at (/tmp/form-init5310097246403534856.clj:1:9214). Unable to resolve var: shadow.cljs.devtools.server.nrepl04/cljs-load-file in this contexton
lein repl2.8.48 for some reason changes my :init-nsshadow.user2.8.47 for now, no problem here{:lein true
:nrepl {:port 9876}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/public/js/compiled"
:modules {:app {:init-fn rpquest.main/main}}}}}
lein part I need. that is all fine(defproject rpquest "0.1.0-SNAPSHOT"
:min-lein-version "2.8.3"
:source-paths ["src/clj" "src/cljc" "src/cljs"]
:resource-paths ["resources"]
:clean-targets ^{:protect false} ["resources/public/js/compiled"
:target-path]
:auto-clean false
:dependencies [[aero "1.1.3"]
[aleph "0.4.7-alpha5"]
[integrant "0.7.0"]
[integrant/repl "0.3.1"]
[metosin/reitit "0.3.9"]
[metosin/ring-http-response "0.9.1"]
[org.clojure/clojure "1.10.1"]
[re-frame "0.10.8"]
[reagent "0.8.1"]
;; [thheller/shadow-cljs "2.8.47"]
[thheller/shadow-cljs "2.8.48"]
;; [thheller/shadow-cljs "2.8.42"] - yes
;; [thheller/shadow-cljs "2.8.45"] - yes
;; [thheller/shadow-cljs "2.8.47"] - yes
]
:profiles {:dev {:source-paths ["dev/clj"]
:repl-options {:nrepl-middleware [
;; shadow.cljs.devtools.server.nrepl04/cljs-load-file
;; shadow.cljs.devtools.server.nrepl04/cljs-eval
;; shadow.cljs.devtools.server.nrepl04/cljs-select
shadow.cljs.devtools.server.nrepl04/middleware
]}}
:uberjar {:aot :all
:main rpquest.main }}
:uberjar-name "rpquest.jar")
:init-ns thing was called mistakenlyprofiles.clj{:user {:plugins [[lein-ancient "0.6.15"]
[jonase/eastwood "0.3.6"]
[lein-bikeshed "0.5.2"]
[lein-cljfmt "0.6.4"]
[lein-count "1.0.9"]
[lein-hiera "1.1.0"]
[lein-kibit "0.1.7"]]
:dependencies [[nrepl "0.6.0"]]
:aliases {"anc" ^{:doc "Check all dependencies for updates"}
["do"
["ancient" "check-profiles" ":all" ":check-clojure"]
["ancient" ":all" ":check-clojure"]]
"anc-up" ^{:doc "Upgrade all dependencies interactively"}
["do"
["ancient" "upgrade" ":interactive" ":all" ":check-clojure"]
["ancient" "upgrade-profiles" ":interactive" ":all" ":check-clojure"]]
"anc-snapshot" ^{:doc "Check all dependencies for updates, allow snapshots"}
["ancient" ":allow-all" ":all" ":check-clojure"]
"dev" ^{:doc "Run development repl"}
["repl" ":headless"]
"dev-clean" ^{:doc "Run fully clean development repl"}
["-U" "do" "clean" ["repl" ":headless"]]
"deps-dev" ^{:doc "Run lein deps with repl profile"}
["-U" "with-profile" "repl" "deps"]}}
:repl {:plugins [[cider/cider-nrepl "0.22.0-beta10"]
[refactor-nrepl "2.5.0-SNAPSHOT"]]}}
:profiles {:dev {:source-paths ["dev/clj"]
:repl-options {:nrepl-middleware [
;; shadow.cljs.devtools.server.nrepl04/cljs-load-file
;; shadow.cljs.devtools.server.nrepl04/cljs-eval
;; shadow.cljs.devtools.server.nrepl04/cljs-select
shadow.cljs.devtools.server.nrepl04/middleware
]}}
:uberjar {:aot :all
:main rpquest.main }}
:repl-options inside?:repl {:plugins [[cider/cider-nrepl "0.22.0-beta10"]
[refactor-nrepl "2.5.0-SNAPSHOT"]]}
2.8.49. I added back the missing piggieback descriptor I deleted accidentallyError loading shadow.cljs.devtools.server.nrepl04: Syntax error compiling var at (shadow/cljs/devtools/server/nrepl_impl.clj:21:5). Syntax error compiling var at (/tmp/form-init1375884670700473546.clj:1:8600). Unable to resolve var: shadow.cljs.devtools.server.nrepl04/middleware in this context
:require ["@date-io/moment" :default MomentUtils], the cljs repl tells me (undefined? MomentUtils) => true. MomentUtils seems to be built from a TypeScript export default class. The js rendition looks like var MomentUtils = (function () { function MomentUtils (_a) {...}; ...; return MomentUtils; }()); module.exports = MomentUtils["@date-io/moment" :as MomentUtils]λ shadow-cljs watch app
shadow-cljs - config: D:\Dev\clojure\rn-rf-shadow\shadow-cljs.edn cli version: 2.8.50 node: v10.9.0
shadow-cljs - starting via "clojure"
Exception in thread "main" java.io.FileNotFoundException: -A:dev (The system cannot find the file specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:110)
at clojure.lang.Compiler.loadFile(Compiler.java:7083)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$script_opt.invoke(main.clj:336)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:619)
at clojure.lang.Var.invoke(Var.java:430)
at clojure.lang.AFn.applyToHelper(AFn.java:195)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
clojure, by default I has only clj in console.choco and don't create copy of clj.bat with name cljure.bat, use developers instructionsclj without clojureinstrument in your dev environments?^:dynamic variable used for some initial setup. how can I change this variable and make sure it happen before macro expansion.
will put it before the macro usage work?alert and a variblae *should-alert**should-alert*?*should-alert* is something like a global configuration.failed to require macro-ns "better-cond.core".cljs file.(set-xxx! {...})
set-xxx! do?vendors.
I want configure which vendor used on which property.watch make sure it doesn't say connected to server ...shadow-cljs clj-repl and then ( "better_cond/core.clj")nil[better-cond "2.1.0"] to shadow-cljs.edn :dependencies, like the rest of themclj-repl didn't say connected to server?$ shadow-cljs clj-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.8.50 node: v10.13.0 shadow-cljs - connected to server shadow-cljs - REPL - see (help) To quit, type: :repl/quit [6:0]~shadow.user=>
$ /mnt/c/src/xportal/assets/node_modules/.bin/shadow-cljs clj-repl shadow-cljs - config: /mnt/c/src/xportal/assets/shadow-cljs.edn cli version: 2.8.41 node: v11.13.0 shadow-cljs - server version: 2.8.41 running at shadow-cljs - nREPL server started on port 55813 shadow-cljs - REPL - see (help) To quit, type: :repl/quit
/mnt/c/src/xportal/assets/shadow-cljs.edn?[foo.bar "1.2.3" [better-cond ...]] something like that?:compiler-options {:external-config {:mcss {:the-data true}}}(get-in @cljs.env/*compiler* [:options :external-config :mcss]):external-config will invalidate the cache so at least recompiles will happen:compiler-options and trigger recompiles accordingly:external-config in compiler options.mcss.defaults.clj, and let user provides an overwrite version if he wants. is it a good idea? since shadow support this.pom.xml file with shadow-cljs pom? (apart from mangling the resulting xml with xquery or something)deps.edn for that? clj -Spom and clj -Spath?cljs.js in the build the self-hosted support won't be added?init call, but changing these things doesn't seem to result in anything different than what I am seeing. It is a bit challenging to evaluate because it does not happen on every reload - sometimes it doesn't even happen for many reloads.cljs.js is the reasoncljs.js namespace. so would you want to NOT include it?cljs.js/eval-str?:modules {:whatever { ...}}} and then loading the generated whatever.js file in the browser?:modules {:main {:entries [myapp.core]}}main.js file?head like this:<script src="/js/main.js"></script>
/js/main.js is included?<script>myapp.core.main();</script>
main fn do?(defn render-app
[]
(let [app (.getElementById js/document "app")]
(r/render [home-page] app)))boot/init fn is called and it takes a callback<script>myapp.core.main();</script> call<script src="/js/main.js"> to the bottom of your page right above your </body>:modules {:main {:init-fn myapp.core/main}}M-x cider-jack-in-cljs it usually (90% of time) fails with below output. One in 10 runs inexplicably succeeds.
[:app] Configuring build. [:app] Compiling ... [:app] Build completed. (608 files, 1 compiled, 0 warnings, 3.68s) To quit, type: :cljs/quit user> [:selected :app] shutting down ... cljs.user> *** Closed on Mon Aug 19 18:38:22 2019 ***If I delete the
[:app] Build completed. (608 files, 607 compiled, 0 warnings, 16.99s) To quit, type: :cljs/quit user> [:selected :app] cljs.user>Starting via
lein dev works fine 100% of the time.
Deleting the folder .shadow-cljs/builds/app/dev/ana/northstar seems to raise the success rate to around ~50%shadow-cljs - server pid exists but server appears to be dead, proceeding without server. shadow-cljs - config: /Users/quest/repos/ns/browser/shadow-cljs.edn cli version: 2.8.46 node: v12.8.0 shadow-cljs - running: lein update-in :dependencies conj [nrepl "0.6.0"] -- update-in :dependencies conj [cider/piggieback "0.4.0"] -- update-in :dependencies conj [refactor-nrepl "2.4.0"] -- update-in :dependencies conj [cider/cider-nrepl "0.21.1"] -- run -m shadow.cljs.devtools.cli --npm -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.21.1 server shutting down..
.shadow-cljs/builds/app/dev/ana/cljs seems to raise success rate to 100%. I notice that it's a 5MB+ folder, which probably causes the compilation step to take longer.
* However deleting .shadow-cljs/builds/app/dev/ana/re_frame still results in a noticeable amount of failure -- but it's only a 500K library, so maybe similar to deleting my ana/northstar/browser (project's) folder:jvm-opts ["-Xmx2G"] (or 1G) in project.clj:jvm-opts ["-Xmx1G"] in project.clj :profiles -> :dev completely fixes it. Doesn't seem to matter if it gets 1G or 2G.
(FYI to anyone later reading this, tried setting it in shadow-cljs.edn with no effect, so make sure you set it in project.clj):advanced compilation might require moreshadow-cljs watch app without the server running and I would get the attached error. This ran fine if I started the server ahead of time. Sure enough limiting the RAM helped. I have no clue why running this with more RAM causes this to break. If I run the command while providing 4GB to Java it will cause the same issue. (I'm sitting at 6GB in use out of 16GB right now, so it's not running out of memory)
EDIT: Just to be clear, this issue is FIXED by adding :jvm-opts ["-Xmx2G"] to my shadow-cljs.edn file. I was just wondering if there was any reason why that fix works?:jvm-opts ["-Xmx4G"] in project.clj, it gives the shutting down.. start message at least 30%+ of the time.
Values of 1G or 2G seem 100% stable.
Setting :jvm-opts in shadow-cljs.edn seems to have no effect regardless of 1G, 2G, or 4G/usr/local/bin/npx shadow-cljs watch app:jvm-opts in shadow-cljs.edn to 1/2/4G values, didn't seem to make a difference)/usr/local/bin/npx shadow-cljs watch app(shadow.cljs.devtools.server/stop!)cljs folder from .shadow-cljs cache made the issue go away 100% of the time for that run)[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 242]shadow-cljs clj-repl and just let it sit for a bit(shadow/watch :app {:verbose true}) after a bitshadow.user=> just fine, letting it sit a minute[:app] Build completed (608 files, 1 compiled, 0 warnings, 4.34s) and gave me back the [1:0]~shadow.user=>, so seems that we did trigger a shutdown somehowjava -version do you use?> java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
(shadow/compile :app) to see if that also gets terminated(shadow/release :app)release won't include all the re-frame-10x code so it might survive due to using less resources.cljs filesreact and react-dom be benefit from optimizations of closure compiler?react-dom bundle size is pretty large:base
:base {:entries []}:base module doesn't make sense when you only have 2 modulesmain and devcards both depends on base:devapp.devcards should likely be its own build:module:modules is that you should only use them if and only if ONE user may end up using ALL modulesshadow-cljs watch app devcards starts two builds:preloads:dev and :release with tools-deps:preloads:preloads?devtools, but it appears in the report.compile button it shows you a :dev buildrelease button instead to see the release deps/namespacescljs.analyzer. I have to switch a router to remove that.:clj instead;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/spill"
"src/test"]
:dependencies
[[org.clojure/core.async "0.4.500"]
[reagent "0.8.1"]
[re-frame "0.10.6"]
[bouncer "1.0.1"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[clj-commons/secretary "1.2.4"]
[venantius/accountant "0.2.4"]
[binaryage/oops "0.7.0"]
[binaryage/devtools "0.9.10"]
[day8.re-frame/re-frame-10x "0.3.7-react16"]
[day8.re-frame/tracing "0.5.1"]]
:builds {:app {:output-dir "web/root/js/shadow"
:asset-path "js/shadow"
:target :browser
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [devtools.preload day8.re-frame-10x.preload]
:modules {:app {:init-fn spill.app.core/init}}
:main "spill.app.core"
:devtools {:http-root "web/root"
:http-port 8080}
:compiler-options {:optimizations :none}}}}
re-frame-10x:preloads into :devtools, and adding re-frame.trace/trace-enabled? true to your :closure-defines map may do it:main "spill.app.core" that does nothing and can be removed:compiler-options {:optimizations :none} also does nothing and can be removed:preloads belongs in :devtools:modules {:app {:init-fn ... :preloads [...]}}:asset-path to go along with [:devtools :watch-dir] ? Watch-dir does not work for me, and I think it is because the URLs are not generated like :watch-dir expects (just /some/path under :watch-dir) - in my case I have a prefix./f/css/front_dev.css , and in [:devtools :watch-dir] I have this: resources/public/cssresources/public/css/f/css/front_dev.css?/f/ there/f/? why does that exist?:output-dir "resources/public/js/compiled" :asset-path "/f/js/compiled"and therefore that part works
:watch-dir "resources/public" and then put the actual file into resources/public/css/front_dev.css and use /css/front_dev.css as the path in HTML/f isresources/public/f/css/front_dev.css? and have you webserver serve resources/public like every web server out there?<link tag itself that is used to comparehref but it could also check something like <link rel="stylesheet" href="/f/css/front_dev.css" data-css-path="/css/front_dev.css" />asset-path, just for the css?{:watch-dir "resources/public" :watch-asset-path "/f"}{:watch-dir "resources/public" :watch-path "/f"}:lein true the :jvm-opts have no effect since lein will be starting the JVM.:jvm-opts is something I should add to the +cider profile ? If it reliably solves the issue then at least cider users won't get any bad surprises when using the template ?:jvm-opts ["-Xmx1G"] seems to reliably fix the issue 100% of the time. If nothing else, might be worth mentioning on the re-frame template README.
This issue could be just on OSX though -- I'm not sure about Windows/*nix. Without the option & with the .shadow-cljs cache already present, it seems to pass/fail every other launch-Xmx16G just fine. it should be dying 100% for you with that right?clj -J-Xms16G (note -Xms not -Xmx) which sets the min amount of RAM(do ...) but all the code is fully removablesass --watch web/scss/spill/spill.scss web/root/css/app.css to get my sass compiled. Is there any way to run this with shadow?::http/file-path "public"public/js (does so by default) (or whatever your module name was):http-handler option: https://github.com/Day8/re-frame-template/blob/ed85dc98ad383fd03d61acaa8a2092af89bee8c0/src/leiningen/new/re_frame/shadow-cljs.edn#L22:devtools section of shadow-cljs.edn.{:lein true
:nrepl {:port 8777}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:dev {:modules {:app {:entries [devtools.preload
day8.re-frame-10x.preload
dummy-10x.core]}}
:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release {:modules {:app {:entries [dummy-10x.core]}}
:compiler-options {:optimizations :advanced
:pretty-print false
:closure-defines {goog.DEBUG false
re-frame.trace.trace-enabled? false
day8.re-frame.tracing.trace-enabled? false}}}
:devtools {:http-root "resources/public"
:http-port 8280
:preloads [devtools.preload
day8.re-frame-10x.preload]
:after-load dummy-10x.core/mount-root}}}}
{:lein true
:nrepl {:port 8777}
:dev-http {8280 "resources/public"}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn dummy-10x.core/init
:preloads [devtools.preload
day8.re-frame-10x.preload]}}
:dev {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}}}:npm-deps [
{:keycloak-js "^6.0.1"}
] this is invalid and doesn't do anythingservice configservice.clj: https://pastebin.com/hMdUt7Gkresources/public dirview.cljs has been reloaded but the page does not update.telifit-web/core.cljs(defn mount-root [] to (defn ^:dev/after-load mount-root []shadow-cljs.edn…{:deps {:aliases [:cljs]}
:source-paths ["src/cljs"]
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:entries [telifit-web.core]
:preloads [devtools.preload
day8.re-frame-10x.preload
re-frisk.preload]}}
:dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
}}}:devtools {:repl-pprint true}:devtools {:repl-pprint true} got it working in CIDER! Thank you & documented this at https://github.com/thheller/shadow-cljs/wiki/Cider{:source-paths ["src/cljs"]
:dependencies [[day8.re-frame/http-fx "0.1.6"]
[dorothy "0.0.7"]
[reagent "0.8.1"]
[re-frame "0.10.8"]
[datascript "0.17.1"]
[re-com "2.5.0"]]
:dev-http {9500 "resources/public/"}
:builds {:app {:output-dir "resources/public/js/"
:asset-path "/js"
:target :browser
:compiler-options {:output-feature-set :es6}
:modules {:main {:init-fn clograms.core/init}}
:devtools {:after-load clograms.core/mount-root}}}}
^:dev/once to the ns that has the atom then everything is fine (but I can't reload code there)(defonce the-atom (atom {})?(defonce storm (atom {}))(reset! storm {}) or something?(defonce storm (do (prn :init-the-atom) (atom {}))(:require ["@projectstorm/react-diagrams" :as storm])release build, but not ideal when I want a reload workflow for development:browser w/ the associated config options leads to my getting weird errors like The required JS dependency "path" is not available... despite path being installed and available in the correct dir.
setting the target to :node-script appends an #!/usr/bin/env node to the output file, which doesn’t actually work in a browser context when loaded via a script tag.
anyone have an idea for either 1) how to specify that node requires are kosher in a :browser target or 2) strip the #!/usr/bin/env node heading from the output file in a :node-script target?:browser? https://github.com/thheller/shadow-cljs/issues/279:devtools-url https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support:asset-path "...":devtools {:loader-mode :eval}:loader-mode :eval works! thanks! only thing is I see “connection fail” bottom left warning on ui:devtools {:devtools-url ""} since that by default will try to use the current document.location:node-script is for node scripts. it is not intended to run in the browser. you can use the regular :target :browser and set :js-options {:js-provider :require}javascript library function, but this will make this in the called function invalid. Is it relative to the compiler? @thheller(.thatFn the-object 1 2 3) will keep the-object as this?.bind and other tricks don't work so well with CLJS currently((.-thatFn obj) arg1 arg2)(.thatFn obj arg1 arg2)? whats the point of getting the fn off the object first?(obj.thatFn)(arg1, arg2) in JS either?(.-fn obj arg1 arg2) I also try it, but doesn't work too.-.-fn is short for getting that property`. (.fn ...) is short for calling that fn(.-fn obj) will get the function, so the first way doesn't matter, I have verified it.(.-fn obj) will GET the function. (.fn obj) will CALL the function[nREPL] Starting server via npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.0-beta11 server. After Select ClojureScript REPL type: node, I see [nREPL] Direct connection to localhost:37269 established, but I get an error Unhandled java.lang.AssertionError Assert failed: (keyword? repl-env). I'm using version 2.8.51, node 10.16.3, and spacemacs /cdn-cgi/l/email-protection{:source-paths ["src"]
:dependencies []
:builds {:app {:target :node-library
:exports {:handler test.main/handler}
:output-dir "target"
:output-to "target/main.js"}}}custom and do (shadow/watch :app) (shadow/node-repl :app)deps.cljs :npm-deps dependency tree ?npm list or so after they are installed(->> (ClassLoader/getSystemResources "deps.cljs")
(enumeration-seq))slurp and read themlein-shadow (i.e. build tool problem) ?package.json is the source of truth. deps.cljs stuff is only added if it is not already in package.jsonre-frame-10x there are some important transitive deps: https://github.com/Day8/re-frame-10x/blob/master/src/deps.cljsshadow-cljs run some.util/show-npm-depsUncaught ReferenceError: $jscomp is not defined
when calling toAscii:advanced? that name shouldn't exist anymore?$jscomp is used by the closure compiler for polyfills.$jscomp?shadow-cljs release app --pseudo-names:compiler-options {:output-feature-set :es6} might do it if you can live with thatnamehashed fn is this one:compiler-options {:output-feature-set :es6} worked!2.8.39 to 2.8.45 (or .51) is unfortunately breaking our REPL setup on the final NPM build of our project. We checked for the usual culprits but nothing did the trick except reverting to 2.8.39.
This is an :npm-module that's being consumed by a Webpack project. From JS we have
window.CLOSURE_BASE_PATH = '/javascripts' // Should match our assets location
require('cljs/shadow.cljs.devtools.client.browser')
After the update, the REPL connects as usual but apparently cljs.core isn't loaded:
cljs.user> 3
3
cljs.user> (first [1 2])
ReferenceError: cljs is not defined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js), <anonymous>:1:1)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js:878:16)
at eval (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js:887:44)
[...]
Is there something else we could try?
Thanks!global-eval fn. https://github.com/thheller/shadow-cljs/commit/1470c6d2d06195d01ba2b486ef6f730c36b51840global-eval to fix another issuebrowser.cljs https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs and just replacing the #(global-eval .. with (js/eval ...global-eval substitution is still queued up, trying to find a breach on the schedule)
Thanks again![cider/cider-nrepl "0.21.1"] fixed itreagnet?
Why we can't do this to update Component:
(def content (r/atom 0))
(js/setInterval (fn []
(swap! content inc)
(println @content)) 1000)
(defn home []
[:> rn/View {:style (styles :container)}
[:> rn/Text @content]])
If I try to define atom in global, and there is no update for rn/Text.reagnet?
Why we can't do this to update Component:
(def content (r/atom 0))
(js/setInterval (fn []
(swap! content inc)
(println @content)) 1000)
(defn home []
[:> rn/View {:style (styles :container)}
[:> rn/Text @content]])
If I try to define atom in global, and there is no update for rn/Text.reagent then many people use it. Not sure what you mean by "any update will invalid", the code seems fine to me. Try asking in #reagentupdate or state change will not result in rerender.[:app] Build failure:
Module Entry "riverford.mobile-app-orders.db.catalog" was moved out of module ":default-products".
It was moved to ":index" and used by #{:default-products :default-categories}.{:app
{:target :react-native
:init-fn riverford.mobile-app-orders.core/init
:output-dir "app"
:infer-externs :auto
:devtools {:autoload true}
:chunks {:default-products riverford.mobile-app-orders.db.catalog/default-products
:default-categories riverford.mobile-app-orders.db.catalog/default-categories}}}:watch-dir, right? Otherwise it seems that Shadow-CLJS won't know that something has changed and won't notify the browser.:watch-dir?:watch-path.target
- Some CSS from node_modules that I copy with build hooks into target.
If I watch just the vendored dir, I won't get any notifications on the changes within target, and vice versa.
If I set :watch-dir "." then I get notified but there's no reload since I get specify the correct :watch-path.public/css/main.css and that is loaded via /css/main.css served by a webserver with root publicresources/vendored/a.css -(web server)-> /static/vendored/a.css
resources/b.scss -(scss compiler)-> target/dev/b.css -(web server)-> /static/b.css
node_modules/lib/c.css -(build hook)-> target/dev/lib/c.css -(web server)-> /static/lib/c.css
Does this make sense?resources or target?resources and target. There are multiple roots.
Yes, an actual shadow-cljs build hook that just copies a bunch of specified files from one location into another./static checks resources AND target/dev?resources btwpublic dir and generate everything into public/css or so and everything in there is .gitignore'dyada and integrant - not really usefult, I think.
> /static checks resources AND target/dev?
Yes! There is a priority and the server just tries to find the first matching path.
> it is not a good idea to directly server resources btw
In my case, it only contains the stuff the needs to be served, with the exception of SCSS files, so I don't think it's a big deal.
> loading 3 different css files is not great performance wise
Is there really a noticeable performance difference though? Especially when the files themselves are relatively small, and the browser downloads them in parallel anyway.
But you gave me the idea. I started using SCSS just a few days ago. Before that, there was no way to combine multiple CSS files into one. But with SCSS, I think I should be able to do that.resources might be but I'm assuming that is packaged as an uberjar at some point?/b.scss if I understand your setup correctly/b.scss is accessible?/b.scss is accessible?
Sure, it should be if I deploy it (haven't deployed yet since I started using SCSS). Yeah, I can see how it can potentially be an issue.
> I keep my web resources out of uberjars too and just serve regular files
Oh, I don't use uberjars at all. Couldn't make it work on Heroku as it just crashes with OOM during the startup process. Tried uberjar, onejar, capsure. I may mix some names up - has been a minute since I tried that.@importing vendored CSS - worked just fine.
But it's not as easy with files from node_modules. E.g. TinyMCE has a whole load of all kinds of files that are loaded dynamically depending on the settings you provided it during runtime. I just thought that maybe I could also get rid of the build hook but apparently that's not the case.public dir and generate everything into public/css or so and everything in there is .gitignore'd
@thheller How do you deal with multiple assets of different kinds? E.g. I have a bunch of JS files (some code that's not available in NPM) - I can probably move that to src and ship it within main.js. But there are also all sorts of images and manifests:
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="manifest" href="/site.webmanifest"> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">Plus the
/favicon.ico and /browserconfig.xml and other stuff like that.public directory (added to git, except generated files)public/css and public/js dirs are gitignored and files are just generated into those dirstarget. Extra entry in .gitignore, extra step to prevent IDEA from indexing it. And juxt/kick.alpha supports setting only a single target directory at the moment, so CSS generated from SCSS and JS generated from CLJS all go into one place. Which makes sense IMO.:watch-dir and :watch-path support vectors (without losing the support for plain strings of course), I'd be happy to create a PR.target should be sufficient in my case..json files for that then? 😛.json files?(js/require "./default-products.js") somewhere. why not just do (js/require "./default-products.json")?(js/require "./default-products.json") where I used it wasn’t enough to stop the app trying to parse the json at startup. Perhaps it was working to do that, but it wasn’t making much of a differenceCan't take value of macro clograms.diagrams/xx, it is a very simple macro defined in the same namespace but in a .clj file, any ideas?(defmacro foo [] :foo) (identity foo)lein new re-frame example +cider +10x +garden +re-com +routes +less
Running the repl using npx:
npx shadow-cljs browser-repl
--> this works where it creates a REPL and launches a browser window
What I am trying now:
run clojurescript repl using EMACS, CIDER, SHADOW-CLJS
(cider-jack-in-cljs)
The error i am getting is:
error in process sentinel: Could not start nREPL server: npx: installed 91 in 3.274s shadow-cljs - config: /Users/davesh/sandbox/prototypes/example/shadow-cljs.edn cli version: 2.8.51 node: v12.9.0 shadow-cljs - running: lein update-in :dependencies conj [nrepl "0.6.0"] -- update-in :dependencies conj [cider/piggieback "0.4.1"] -- update-in :dependencies conj [refactor-nrepl "2.5.0-SNAPSHOT"] -- update-in :dependencies conj [cider/cider-nrepl "0.22.0-beta11"] -- run -m shadow.cljs.devtools.cli --npm -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.0-beta11 server Executable 'lein' not found on system path.
lein on my classpath:
EMACS: (setenv "PATH" (concat "/usr/local/bin:/Library/TeX/texbin:" (getenv "PATH"))) (push "/usr/local/bin" exec-path) (push "/Users/dhruv/bin" exec-path) OSX: $ which lein /Users/dhruv/bin/lein
(shell-command-to-string "which lein") what does that return?react-chart-editor from plotly but I can never reach the homepage because the dependencies are toooo big. (Similar to what happens if you load @material-UI/iconsreact-chart-editor. If so, try requiring only the stuff that you need.x :refer [a b c] but as x/a :as a.(ns app.core
(:require [reagent.core :as r :refer [atom]]
["react-native" :as rn :refer [AppRegistry, Platform]]))
(defn app-root []
[:> rn/View
[:> rn/Text "First line"]
#_[:> rn/Text "------------------"]
[:> rn/Text "Second line"]
[:> rn/Text "Hi!!!!"]])
(defonce app-root-ref (atom nil))
(def updatable-app-root
(with-meta app-root
{:component-did-mount
(fn [this]
(println "did mount")
(reset! app-root-ref ^js this))}))
(defn init []
(.registerComponent AppRegistry
"Han"
#(r/reactify-component updatable-app-root)))
(defn reload {:dev/after-load true} []
(.forceUpdate ^js @app-root-ref))
The only real difference with before that I can think of, is that I’m using RN 0.60 now.app-root, not on app-root itself.Module app registry is not registered call-back module, the code in question is:
(defonce app (app/fulcro-app
{:render-root! expo/render-root}))
(defn init
{:dev/after-load true}
[]
(app/mount! app Root :i-got-no-dom-node)
(js/console.log "Loaded"))
`
Where app comes from [com.fulcrologic.fulcro.application :as app]
Any ideas?The required namespace "react" is not available, it was required by "reagent/core.cljs". The namespace was provided via :foreign-libs which is not supported. Please refer to for more information. You may just need to run: npm install react
npm install react react-dom create-react-class
<project>/node_modules/react/package.json for examplepackage.json in your project dir?npm init -y in your project dir firstpackage.json so you should create that via npm init -ynpm init -y
npm install react react-dom create-react-class
:npm-deps worksdeps.edn and a deps.cljs file in src somewherenpm install auth0-js"package.jsonnpm install react or so to manage JS deps (which will add it to package.json)deps.cljs at the top of my classpath and shadow cljs did an npm savepackage.json so we need to put it there. I only recommend using deps.cljs when publishing libraries. Otherwise use package.json directly AND keep your package-lock.json in version control too.[reagent "0.8.1"]package.jsondeps.cljs?deps.cljs does nothing except transfer the dependencies to package.jsondeps.cljs do?deps.cljs should be provided as a convenience so downstream users have that dependency automatically installedauth0-jspackage.json is the source of truth and will be used over deps.cljsdeps.cljs npm-deps are only only transfered if they are not contained in package.json already["auth0-js" :as auth0-js] in my :requireUse of undeclared Var hoplon-auth0.api/auth0-js------ WARNING #1 - :undeclared-var -------------------------------------------- File: /home/thedavidmeister/hoplon-auth0/src/hoplon_auth0/api.cljs:28:2 -------------------------------------------------------------------------------- 25 | 26 | (defn web-auth 27 | [] 28 | (auth0-js.WebAuth. --------^----------------------------------------------------------------------- Use of undeclared Var hoplon-auth0.api/auth0-js -------------------------------------------------------------------------------- 29 | hoplon-auth0.data/web-auth)) 30 | 31 | (defn authorize 32 | ([] (authorize nil)) --------------------------------------------------------------------------------
(auth0-js/WebAuth.)shadow-cljs.edn?deps.edn syntax doesn’t seem to be working:react-native support has been amazing to use. I’m currently using it to control an external credit card reader over bluetooth and it’s been a joy poking it from the REPL. Thanks for all your had work Thomas 🙏ERR_INSUFFICIENT_RESOURCES, when downloading the clojurescript files in Chrome in development mode? (shadow version 2.8.51):loader-mode :eval?[2019-08-26 19:17:00.010 - WARNING] :shadow.cljs.devtools.server.reload-macros/macro-missing - {:ns-sym clojure.spec.test.check}
It keep spamming forever in the repl, every 1 sec.2.8.52 with the fixlein shadow release app?
Found this
https://gitlab.com/nikperic/lein-shadow
But it fails on a call to Closure.
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:68:5).
...
Caused by: java.lang.NoSuchFieldException: getRegisteredGroups
at java.base/java.lang.Class.getField(Class.java:1958)
lein run -m shadow.cljs.devtools.cli compile app[com.google.javascript/closure-compiler-unshaded "v20190819"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]to your deps
[org.clojure/clojurescript "1.10.520]node repl-node/main.jsshadow-cljs watch appshadow-cljs cljs-repl appprn and (.log js/console ...)js/console logs will show in the output of the actual node process. so node repl-node/main.jsprn can only be captured partially so will most likely also only show up there.then wouldn't complete and/or be able to log from inside the callback?node process should still show the output thoughprn randomly not working.then wasn't happening, it's .catch now >.<[com.google.javascript/closure-compiler-unshaded "v20190819"] [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]Thank you Mr Heller!
:karma adding :loader-mode :eval is useful?ERR_INSUFFICIENT_RESOURCES and the browser would hang forever, reach the Karma timeouts and then fail the tests?FROM node as node RUN npm install FROM clojure COPY --from=node node_modules RUN clj -A:cljs:build RUN aws s3 put target/out.js s3://
clj -m shadow.cljs.devtools.cli release your-buildnode_modules folder and the package.json so it doesn't try to install deps from deps.cljsunsafe-eval in the Content-Security-Policy header, which I'd rather avoid. But when I generate it with "commonjs_strict" output it doesn't work. Here's the diff (`---` is working but unsafe; +++ is safe but non-working): https://gist.github.com/cap10morgan/b9f283fa8035b8c0bc527b0911eed1fb
Anyone know if / how I can use the +++ version in a shadow-cljs app?:js-options {:resolve {"create-react-class" {:type :npm :require "preact-compat/lib/create-react-class"}}}goog is not defined when I run it): https://gist.github.com/cap10morgan/b1b0a0f151b02809b084a568c13ac2fc(:require ["path/to/js_file" :as game-lib]) in both cases.:advancedsrc/gen and :source-paths ["src/main" "src/gen"](:require [proto.game.Whatever :as x]) or soexports with proto, I can just refer to game-lib/game.Thingy in my CLJS code.;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[binaryage/devtools "0.9.10" :scope "test"]]
:builds
{:app
{:target :npm-module
:runtime :react-native
:output-dir "target"
:compiler-options {:infer-externs :auto}
:devtools {:autoload true
:async-require true}}}}
index.js
/**
* @format
*/
if (__DEV__) {
require('./target/shadow.cljs.devtools.client.react_native');
require('./target/forg.dev.devtools').install();
}
import { AppRegistry } from 'react-native';
import { Application } from './target/forg.root';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => Application);
:npm-module. use :react-nativecheck isn't very reliable 😉shadow-cljs release app --pseudo-names:compiler-options {:infer-externs :auto}.props since it is getting renamed to .$props$ or .Ad in actual releaseexterns/app.txt and add one line with props(defn register
([key]
(register key nil))
([key options]
(let [get-props
(fn [this]
{::key key
::id (-> this .-state .-id)
:component-id (-> this .-props .-componentId)})
wrapper
(crc #js
{:displayName
(str key "Wrapper")
:getInitialState
(let [id (swap! id-seq-ref inc)]
(fn [] #js {:key key
:id id}))
:componentDidMount
(fn []
(this-as
^js this
(bind-component this)
(swap! mounted-ref
assoc-in [key (-> this .-state .-id)] this)))
:componentWillUnmount
(fn []
(this-as
^js this
(swap! mounted-ref update key dissoc (-> this .-state .-id))))
;; FIXME: forward other lifecycles the same way
:navigationButtonPressed
(fn [params]
(this-as
^js this
(let [{:keys [navigation-button-pressed]}
(get @screens-ref key)
props
(get-props this)]
(js/console.log "navigationButtonPressed"
key
(boolean navigation-button-pressed)
(pr-str props))
(when navigation-button-pressed
(navigation-button-pressed
(js->clj params :keywordize-keys true)
props)))))
:componentDidAppear
(fn []
(this-as
^js this
(js/console.log "componentDidAppear" key)))
:componentDidDisappear
(fn []
(this-as
^js this
(js/console.log "componentDidDisappear" key)))
:render
(fn []
(this-as
^js this
(let [{:keys [render]}
(get @screens-ref key)
props
(get-props this)]
(js/console.log "render" key (pr-str props))
(-> (render props)
(r/as-element)))))})]
(when (not (nil? options))
(set! (.-options wrapper)
(fn [passProps] (clj->js options))))
(register-component key (fn [] wrapper)))))
--------------------------------------------------------------------------------
27 | (fn [this]
28 | {::key key
29 | ::id (-> this .-state .-id)
30 | :component-id (-> this .-props .-componentId)})
---------------------------------^----------------------------------------------
Cannot infer target type in expression (. (.-props this) -componentId)
--------------------------------------------------------------------------------
31 |
32 | wrapper
33 | (crc #js
34 | {:displayName
--------------------------------------------------------------------------------
(fn [^js this]^:dev/after-load fn isn't being called, and so my reagent/react components aren't reloaded. any hints for debugging?
(defn ^:dev/after-load re-render "Re-render the app when figwheel reloads" [] (mount-root))i've also tried explicitly setting
{:devtools {:after-load myapp.re-render in my shadow-cljs.edn file with no luck.shadow.cljs.devtools.client.browser.ws_connect() from js console and it will reconnect.shadow.cljs.devtools.client.react-native.ws-connect ?shadow.cljs.devtools.client.react_native.ws_connect()shadow-cljs watch to restore a websocket <-> REPL connection 🙂npx shadow-cljs server I constantly get these messages. This is on the latest (2.8.52).browser.cljs:360 Refused to connect to '' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback..Certificate from KeyChain on my Mac.Step 2.
https://certsimple.com/blog/localhost-ssl-fixshadow-cljs.edn file content:
{:lein true
:nrepl {:port 8777}
:builds {:app {:target :browser
:output-dir "resources/public/cordova/www/js/compiled"
:asset-path "/js/compiled"
:optimizations :whitespace
:modules {:app {:init-fn com.kctech.qulak.mobile.core/init
:preloads [devtools.preload]}}
:devtools {:http-root "resources/public/cordova/www"
:http-port 8280}}
:browser-test
{:target :browser-test
:ns-regexp "-test$"
:runner-ns shadow.test.browser
:test-dir "target/browser-test"
:devtools {:http-root "target/browser-test"
:http-port 8290}}
:karma-test
{:target :karma
:ns-regexp "-test$"
:output-to "target/karma-test.js"}}}
shadow-cljs server to start server and REPL.
shadow-cljs - config: /Users/sckn/projects/business/qulak/mobile/com.kctech.qulak.mobile/shadow-cljs.edn cli version: 2.8.52 node: v12.4.0 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm server shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.52 running at shadow-cljs - nREPL server started on port 8777Yeap, as you said.
"resources/public/cordova/www/index.html"? does it have a <meta http-equiv="Content-Security-Policy" ...?Googler, how can I help you @thheller?Cordova + Shadow-Cljs ?Re-frame + ReAgent.
I want to implement a prototype over Cordova.
I’ve created a new re-frame template from leiningen which contains shadow-cljs configuration.
And then, create a Cordova app with cordova create bla com.kctech.bla.bla Bla.
But, I couldn’t handle the process.
I compile my application. Run with cordova.
It pops-up some errors.Cordova app process ?
I want to implement all the UI specific work with browser. But I need the see on Mobile too.minimal template with these templates ?
@U0524B4UW, or Am I wrong at something ?guide on this topic ?
What are gotchas ? What are pitfalls ?web and Cordova buildings ?leintemplate and adding cordova in it ?
And, at least, can you show me or tell me anything about how should I keep my Project Structure ?www directorycordova -config.xml -www/ web -shadow-cljs.edn -src/ -test/ -target/
window.location=) to your shadow http serverJS file. Same as we did without shadow-cljs ?
with :simple or :advanced compilation flags ?shadow-cljs release appdevelopment ?shadow-cljs watch app?:devtools-url properly? eg set :devtools {:devtools-url ""}file://...development and production build configurations.
I was reading the documentation but, I have to implement a prototype, I’m in a rush.http: url has the advantage that triggering a page-reload on-device does the right thing - restarts the app at the latest build - that wouldn't be the case with :devtools-url would it @thheller?shadow-cljs watch app during development and then use shadow-cljs release app to create a production build. they both use the same config.file:... then a page reload will reload the files deployed to the device... whereas the shadow build may have moved on since then (since each shadow build does not redeploy the cordova app, and if it did would lose all the app state)http:... url, then i will get the latest build when reloadingfile:... reload just works on RNLocal Storage datas too ?background on this project.
Already got a SPA with Clojurescript with well designed theme.design.English.builds into one, single project with shadow-cljs ?English. I hope it gets better soon.Cordova
- AWS --Some back-end. 😇
- And importantly, my business-logic code.project. And manage them with that one.merging my builds. I think it would be the right phrase.shadow-cljs documentation yet.
It seems that It can solve my problem.:builds {:ios {...} :android {...} :backend {...} ...}figwheel and shadow-cljs builds ?figwheel - our shadow-cljs build is considerably faster than our old boot-cljs build. i have no idea why though - dyu know why @thheller ?quite a bit you said ?
My whole life was a lie.
How this thing compile my project within 4 secs ?
How ?
I’d bad feelings about my poor Mac. But it looks ok now. 😂shadow-cljs ?black-magic. 😂boot-cljs against shadow-cljs doing advanced compilation on our app - i ran builds twice, timing the second buildboot devapp-advanced 473.78s user 18.71s system 250% cpu 3:16.78 totalgulp release-yapdev-web 228.66s user 6.41s system 324% cpu 1:12.36 totalgulp build drives shadow) - so the gulp/shadow build was roughly twice as quick as the boot build.shadow-cljs directory, so cache was probably already there... having deleted .shadow-cljs and building again:gulp release-yapdev-web 321.94s user 30.53s system 387% cpu 1:30.96 total:parallel-build true enabled in boot? (it is always on for shadow-cljs):parallel-build might be a thing though - cpu usage does look higher for shadowlessc buildcheckouts directory like leiningen or some similar functionality? I can symlink node dependencies, now I just have to figure out how to symlink cljs dependenciescheckouts is not supported no but you can just add :source-paths ["src/main" "checkouts/foo/src/main"]node_modules/some-lib to somewhere/else/some-lib?deps.edn with :local/root for thatlein checkoutsdeps.edn. everything else stays the same.No implementation of method: :-evaluate of protocol: #'cljs.repl/IJavaScriptEnv found for class: nilI don't know whether it's some sort of cider internal issue or I'm doing something wrong. Steps to reproduce: 1. shadow-cljs.edn configuration
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[instaparse "1.4.10"]]
:builds
{:app
{:target :npm-module
:entry forg.parser.core
:output-dir "target"
:compiler-options {:infer-externs :auto}
:devtools {:autoload true
:loader-mode :eval
:repl-pprint true
:async-require true}}}}
2. cider-jack-in-cljs
3. start node-repl via shadow-cljs start node-repl
4. choose node-repl from cider
5. try to autocomplete and error'll occurclj-suitable which assumes it is working with figwheel:async-require in your build config does nothing. you can remove it/ or ./ or ../shadow puts the nrepl port into a file called .shadow-cljs/nrepl.port - is there anyway to get cursive to pick this up automatically?react-bootstrap with shadow-cljs and i'm seeing a weird behaviour. loading the compiled js in the browser throws an exception [1] only on the first load and nothing is rendered, and then any subsequent hot-reload renders the button just fine. can anyone seem what i'm doing wrong? 🙂
(ns myproject.views
(:require
[reagent.core :as r]
["react-bootstrap" :refer [Button]]))
(defn home-panel []
(fn []
[(r/adapt-react-class Button) {:variant "primary"} "Test 1"]))
[1]
Uncaught TypeError: (0 , _uncontrollable.default) is not a function
at Object.shadow$provide.module$node_modules$react_overlays$Dropdown (Dropdown.js:306)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_bootstrap$Dropdown (Dropdown.js:19)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_bootstrap$index (index.js:84)
at Object.shadow.js.jsRequire (js.js:63)
at Object.shadow.js.require (js.js:97)
at myproject.views.js:6
node_modules/react-bootstrap/node_modules folder existsnode_modules/react-bootstrap/node_modules/package.json i do see some potential conflicts, mainly react and react-dom which i have in my own root package.json. how might i go about resolving dependency conflicts? in figwheel land i would use a combination of :excludes and top level dependencies.node_modules/react-bootstrap/node_modules/package.json this shouldn't even exist?node_modules/react-bootstrap/package.json ?node_modules directory in node_modules/react-bootstrap.node_modules directorynpm list or something(0 , _uncontrollable.default) this looks very suspiciuous though so might be something elsereact-bootstrap requires react-overlays which wants "uncontrollable": "^6.0.0"react-bootstrap installs "uncontrollable": "^7.0.0"react-overlays has the nested install (so node_modules/react-overlays/node_modules/uncontrollable/...)import React, { Component } from 'react'; leads me to the error Requested module does not have an export "Component". when I import the file. Does anyone have an idea how to solve this issue?import React from "react"; and React.Component should do itReact is the default exportReact export:referreact itself is packaged as commonjs, shadow-cljs and closure-compiler only support strict-style commonjs -> ESM interop (as will webpack5)import PanelMenuWrapper from 'react-chart-editor';import RCE from "react-chart-editor"; and then RCE.PanelMenuWrapper?PanelMenuWrapper becomes the default exortPlotlyEditor is the default export(:require [some.thing :as whatever-you-want])index.js fileimport PlotlyEditor from './PlotlyEditor';
import DefaultEditor from './DefaultEditor';
import EditorControls from './EditorControls';
import {EDITOR_ACTIONS} from './lib/constants';
export {DefaultEditor, EditorControls, EDITOR_ACTIONS};
export * from './lib';
export * from './components';
export * from './default_panels';
export default PlotlyEditor;shadow-cljs browser-repl(require '["react-chart-editor" :as x])(js/console.dir x) then look at the object in the browser-repl browser console.js files just use const RCE = require("react-chart-editor");require not import)PlotlyEditorconst RCE = require('/node_modules/react-chart-editor/lib/index.js');require("react-chart-editor")?node_modules on the classpath?const RCE = require('react-chart-editor');is the output babelRCE should have all the stuff you want?console.log(RCE.Button); I get undefinedconsole.log(RCE) in the JS you get different output then (:require ["react-chart-editor" :as x]) and (js/console.log x)?JS -> undefined, cljs -> {default f} and when you open it you get the whole shebang of objects.console.log(require("react-chart-editor"))?f PlotlyEditor(props) for js, against the expected {default: f, ...}require here yes? definitely not import?import in the file at all anymore I mean?const RCE = require('react-chart-editor');
console.log(RCE.PanelMenuWrapper);
console.log(require('react-chart-editor'));
const CustomEditor = function (props, context) {
return React.createElement("div", null);
};
export default CustomEditor;undefined, and PlotlyEditor as output in the browserconsole.dir(RCE)module.exports.default = CustomEditorreact-chart-editor packagere-frame.this in their subcomponent.cljs.core multiple times is really bad as you mentioned:npm-module build that outputs all CLJS you want to use in the JS build:advanced optimizations really aren't suited for that:simplenode your_output_cljs.js?:node-script is meant to build scripts which you can run later yesshadow-cljs watch app, I get an error like this:
RejectedExecutionException: Task
Deleting the .shadow-cljs directory makes it go away, but it reappears when I restart shadow-cljs with an existing .shadow-cljs directory. Anyone come across the same issue?RejectedExecutionException: Task
shadow-cljs watch app?shadow-cljs - config: /Users/eerohe/Code/ci/shadow-cljs.edn cli version: 2.8.52 node: v11.15.0 shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app Warning: implicit hook found: lein-environ.plugin/hooks Hooks are deprecated and will be removed in a future version. NPM dependency "highlight.js" has installed version "^9.15.10" "9.15.8" was required by jar:file:/Users/eerohe/.m2/repository/day8/re-frame/re-frame-10x/0.4.2/re-frame-10x-0.4.2.jar!/deps.cljs shadow-cljs - server version: 2.8.52 running at shadow-cljs - nREPL server started on port 50001 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... shutting down ... shutting down ... [:app] Build failure: RejectedExecutionException: Task
shutting down ...:jvm-opts ["-Xmx2G"] in project.clj:lein key from my shadow-cljs.edn:
[2019-09-04 12:34:47.608 - WARNING] :shadow.cljs.devtools.server.fs-watch-hawk/hawk-start-ex ArityException Wrong number of args (0) passed to: clojure.core/juxt clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) hawk.core/watch! (core.clj:79) hawk.core/watch! (core.clj:59) shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:41) shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:29) shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:102) shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:100) clojure.lang.Var.invoke (Var.java:399) shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:26) shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:11) shadow.cljs.devtools.server/start!/fn--16824 (server.clj:435)
:source-paths then?shadow-cljs.edn? None, so that's probably the issue. Maybe disregard that for now, would probably need to make more extensive changes to my shadow-cljs.edn to eliminate Leiningen. 🙂:source-paths and :dependenciesXmx specify the maximum memory allocation pool?java -XX:+PrintFlagsFinal -version | grep HeapSize size_t MaxHeapSize = 8573157376 {product} {ergonomic}:dependenciesand {:dev {:dependencies ,,, }} from project.clj into shadow-cljs.edn wholesale and specifying :source-paths and the issue doesn't occur.~/.lein/profiles.clj or so adding extra deps?~/.lein/profiles.clj (which loads some plugins) with an empty map also solves the issue.shutting down .... so thats the real problemshadow-cljs and want to get integration with Emacs. Putting [cider/cider-nrepl "0.18.0"] in the shadow-cljs.edn file (under :dependencies) works fine. But when I remove it there and instead paste it into user config file ~/.shadow-cljs/config.edn it breaks. Some ideas?~/shadow-cljs/config.cljs should be ~/shadow-cljs/config.edn?{:dependencies
[[cider/cider-nrepl "0.18.0"]]
:deps-aliases [:cider]}
error in process filter: Wrong type argument: stringp, nil[nREPL] Direct connection to localhost:60273 established)m-x cider-version report?CIDER 0.22.0snapshot (package: 20190817.800)0.18.0 use 0.22.2 for your cider-nrepl versionshadow-cljs clj-repl and then ( "cider/nrepl.clj") to verify it is actually on the classpath(System/getProperty "java.class.path") and look for the cider entrynil - that shouldn't be, should it?[cider/cider-nrepl "0.22.2"]shadow-cljs - server version: 2.7.9~/.shadow-cljs/config.edn. it may be too old for that2.8.52 is currentns :require form which works in shadow-cljs node-repl with (require <...>). the form is:
["google-libphonenumber"
:refer [PhoneNumber]
:rename {PhoneNumber.CountryCodeSource ccs
PhoneNumberFormat pnf
PhoneNumberUtil pnu}]
am i doing something obviously wrong ?cljs-repl tho and can't eval buffers. In the clj-repl is the warning
WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings.[:app] Build completed. (1647 files, 1618 compiled, 0 warnings, 49,33s)pasted.
PhoneNumber.CountryCodeSource ccs and should never work------ WARNING #3 - ----------------------------------------------------------- Resource: er_model/util/phone_number.cljc:3:7 variable pnu is undeclared -------------------------------------------------------------------------------- ------ WARNING #4 - ----------------------------------------------------------- Resource: er_model/util/phone_number.cljc:8:200 variable ccs is undeclared -------------------------------------------------------------------------------- ------ WARNING #5 - ----------------------------------------------------------- Resource: er_model/util/phone_number.cljc:186:83 variable pnf is undeclared --------------------------------------------------------------------------------
ns form(ns er-model.util.phone-number
(:require
[plumbing.core :refer [assoc-when defnk]]
#?(:cljs ["google-libphonenumber"
:refer [PhoneNumber]
:rename {CountryCodeSource ccs
PhoneNumberFormat pnf
PhoneNumberUtil pnu}]))
#?(:clj
(:import
[com.google.i18n.phonenumbers
PhoneNumberUtil
PhoneNumberUtil$PhoneNumberFormat
Phonenumber$PhoneNumber
Phonenumber$PhoneNumber$CountryCodeSource])))
:rename, but i'm still getting errors relating to the other :rename symbols:renames and see how that goes(ns demo.cljc
(:require
#?(:cljs ["google-libphonenumber"
:refer [PhoneNumber]
:rename {CountryCodeSource ccs
PhoneNumberFormat pnf
PhoneNumberUtil pnu}])))
(js/console.log ccs pnf pnu)ccs is undefinedccs is an attribute of PhoneNumber which is where i was going with the accidentally working PhoneNumber.CountryCodeSource thing.cljccli version: 2.8.39 node: v12.5.0 and not using lein or deps directlyPhoneNumberFormat and PhoneNumberUtil objects don't seem to be there when compiling, although they do when running the replPhoneNumber object is there in both casesPhoneNumberUtil and PhoneNumberFormat don't work in the :require but are accessible as properties of the default export - https://gist.github.com/mccraigmccraig/1e8dafda6d86ea6ae0018b492992ee40.cljc and .cljs:as sets up a namespace alias. so you should NOT be using (.-PhoneNumberUtil phone-number) and use the correct phone-number/PhoneNumberUtil instead:refer [PhoneNumber PhoneNumberUtil PhoneNumberFormat] but that lead to nils for PhoneNumberUtil and PhoneNumberFormatphone-number/PhoneNumberUtil would be nil then as well?:refer and :rename work absolutely fine for me:refer in lots of other namespaces without issue...:rename before, but i was trying to duplicate what a cljsjs lib was doing:refer works fine, so i have no idea what was causing my issue before:rename should work fine except for the Thing.X so a dot is technically questionable :compiler-options {:infer-externs :auto}
to my shadow-cljs.edn
But the mount-chart function blows up with an undefined argument. Highcharts
How can I make that symbol stick ?
(ns prod-inv-ui.views
(:require
[reagent :as r]
...
["highcharts" :as hc]))
(defn mount-chart [comp]
(hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))
;; with cljsjs
;; (defn mount-chart [comp]
;; (.chart js/Highcharts (r/dom-node comp) (clj->js (r/props comp))))
(defn update-chart [comp]
(mount-chart comp))
(defn chart-inner []
(r/create-class
{:component-did-mount mount-chart
:component-did-update update-chart
:reagent-render (fn [comp] [:div])}))
(defn chart-outer [config]
[chart-inner @config])
(defn mount-chart [comp] (hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))there is an extra
Highcharts that seems undefined? and should just be (defn mount-chart [comp] (hc/chart (r/dom-node comp) (clj->js (r/props comp))))
highcharts.js:271 Uncaught TypeError: Cannot read property 'series' of null
at c$jscomp$1.Chart.init (highcharts.js:271)
at c$jscomp$1.Chart.getArgs (highcharts.js:271)
at new c$jscomp$1.Chart (highcharts.js:270)
at Object.c$jscomp$1.chart (highcharts.js:270)
at Constructor.prod_inv_ui$views$mount_chart (views.cljs:14)
at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:194)
at Constructor.componentDidMount (factory.js:666)
at commitAllLifeCycles (react-dom.development.js:17335)
at HTMLUnknownElement.callCallback (react-dom.development.js:150)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)series is likely expected to be a prop? did you check what you are passing to it? try logging (js/console.log (clj->js (r/props comp))) in the mount-chart fn?(. var -field) form inside some forms (`if`, when, but not do)
;; Both work (.-ok response) (. response -ok) ;; Works (if (.-ok response) true false) ;; Fails (if (. response -ok) true false)) 19 | (if (. response -ok) --------^----------------------------------------------------------------------- Error in phase :compilation IllegalArgumentException: no conversion to symbol clojure.core/symbol (core.clj:596) clojure.core/symbol (core.clj:589) cljs.analyzer/confirm-var-exists (analyzer.cljc:849) cljs.analyzer/confirm-var-exists (analyzer.cljc:837) cljs.analyzer/confirm-var-exists (analyzer.cljc:840) cljs.analyzer/confirm-var-exists (analyzer.cljc:837) shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:357) shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:142) cljs.analyzer/resolve-existing-var (analyzer.cljc:1269) cljs.analyzer/resolve-existing-var (analyzer.cljc:1264)Latest (`2.8.52`) also contains the issue, unfortunately. We've quickly tested it without shadow and it doesn't seem to break there 😞
response? does it also not work when changing the name?response is a #js object.
Using a regular CLJS map or changing the names give us the same error.
Surprisingly, running it on app.klipse.tech doesn't seem to break things!(.-ok works as expected!{:type java.io.FileNotFoundException
:message "/home/kenny/compute_software_mono/projects/ui/src/compute/ui/login/views.cljs (Too many open files)"
:at [java.io.FileInputStream open0 "FileInputStream.java" -2]}
Typically the only way to fix it is restarting my computer. Anyone know of a better solution?killall node but no node processes are found.java. the node process only starts the real java processlsof or so to see who has all those open fileslsof | grep .cljs maybe/home/kenny/.m2/repository/rewrite-cljs/rewrite-cljs/0.4.4/rewrite-cljs-0.4.4.jarnpx. Perhaps that is hiding the actual process somehow?killall java java: no process found
ps aux | sed 1d | awk '{print "fd_count=$(lsof -p " $2 " | wc -l) && echo " $2 " $fd_count"}' | xargs -I {} bash -c {}find -maxdepth 1 -type d -name '[0-9]*' \
-exec bash -c "ls {}/fd/ | wc -l | tr '\n' ' '" \; \
-printf "fds (PID = %P), command: " \
-exec bash -c "tr '\0' ' ' < {}/cmdline" \; \
-exec echo \; | sort -rn | head seems nicer 😛find command returns nothing.ps is the one that outputs two columns. Any idea what the columns mean? First one is, maybe, pid and second is open files?defmethod definitions yesdefmethod defined in a module that I chose to lazy load later, doesn't seem to be registred here, but i'll investigate and let you know, might be something else causing the issuedefmulti being defined in core and defmethod in a lazy loadable module)ready? before making callsjs/console.log is your friend 😉shadow.lazy/ready? and shadow.lazy/load, is it async for every function ?init in my separate modules, I call it using lazy/load and once it's lazy/ready?, I consider all parts of the said module as ready, am I doing it wrong ?ready? is not async. load islazy/load?(lazy/load (lazy/loadable mynamespace.mymodule/init))(-> (lazy/load (lazy/loadable mynamespace.mymodule/init)) (.then (fn [init-fn] the-defmethod-is-ready-now))ulimit -n 4096
cat /proc/sys/fs/file-max 1000000Still getting the too many open files exception...
/etc/security/limits.conf to 500000. I've set /etc/sysctl.conf fs.file-max to 1000000.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4d26282323340d3d223d60223e"}, :content ("[email protected]")}shadow-cljs - Stale Client! You are not using the latest compilation output!?:test-dir setting, but forgot to update the [:devtools :http-root] setting. 👍:node-test watch ? i'm guessing not, but it would be nicenode-repl not enough?shadow-cljs watch <node-test-target> - i'd like to be able to do repl exploration with hot-code-loading on the same code the tests are exercisingshadow-cljs node-repl for exploration, but there's no reloading afaics:autorun I presume? for the node-test build?:node-test is that it is supposed to exit the process once it has run all testsnode-repl but it is not currently accessible in a nice way(cljs.test/run-all-tests) or sonode-repl, so i can iterate ?(require ... :reload) in the repl ?load-file works a bit better so I'd use thatcljs.test (in the way it does with clojure.test) but the repl / reload workflow is greatshadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.21.2-SNAPSHOT node-repl then i could do M-x cider-connect-cljs and choose a shadow repl and node-repl build, and it works about 100x better than any cljs repl i ever used before:libs, basically, a fair amount of code is written in Google Closure JS and consumed by cljs code. Does shadow have a story for consuming such js files? these JS files can be run through advanced compilation as well…goog.provide and goog.provide they should be found normallyJSX files directly with Clojurescript project via shadow-cljs ?js files with my shadow-cljs project.
I’ve seen this error.
I fetch the shadow-examples from git. But, same is at the {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0c6e6d6e69604c69746d617c6069"}, :content ("[email protected]")}.
TypeError: undefined is not an object (evaluating 'module$node_modules$react$index.default.createElement')objects in app.txt, which refer to:
https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs
Actually, if it dosen't afford, some warning appear. But it seems that it will not affect the compile result.
It's a compile mechanism, but I also want to get some solutions about it. It's too trouble to add them manually.app.txt also a kind of externs, is it?:prepend https://shadow-cljs.github.io/docs/UsersGuide.html#_modules(-> (shadow/get-build-config :your-build) (update-in [:modules :main] assoc :prepend (slurp "whatever.doc")) (shadow/release*))shadow-cljs run your.build/fnjs/eval on src/main/shadow/cljs/devtools/client/browser.cljs) seems to fix the CLJS REPL breakage on 2.8.52!
I'm not sure whether that's good or bad news, though 🙂:browser builds again 😉 only fixes :npm-module:npm-module! We can stick to 2.8.39 without issue 🙂garden) and also regular clj tasks to accomplish the css file generation(ns app.core
(:require [reagent.core :as r :refer [atom]]
["react-native" :as rn :refer [AppRegistry, Platform]]
["react-native-orientation" :default Orientation]))
I then try to use it: (js/console.log "Orientation:" Orientation), but it is undefined. In the verbose compile output, I see that it is being flushed (`<- Flush: shadow.js.shim.module$react_native_orientation.js (1 ms)`). What am I doing wrong? (I have infer-externs auto enabled) ["react-native-orientation" :as Orientation]:default exports(:require ["module-name" :as defaultExport]) if the module is a commonJS moduleconst AuthenticationContext = require('expose-loader?AuthenticationContext!adal-angular')
[:app] Build failure:
The required JS dependency "expose?AuthenticationContext!adal-angular" is not available, it
was required by "node_modules/nm-adal/index.js".
Search in:
src/project/node_modules
You probably need to run:
npm install expose?AuthenticationContext!adal-angular
See:
[:app] Compiling ... Killed The command '/bin/sh -c cd my-app; clojure -A:shadow release app' returned a non-zero code: 137
:jvm-opts ["-Xmx1G"] in shadow-cljs.edn. if you need I could add other ways to add that so you don't need to put it into the configimport * as WebDataRocksReact from './webdatarocks.react';The package, on NPM, is just "webdatarocks". I did the import this way:
["webdatarocks" :as wdr]But when I try to use this component, I get an error "Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for"... In the component's doc, I should do
<WebDataRocksReact.Pivot />In clojurescript I can't figure out how to instantiate... I've tried thinks like
[:> wdr/Pivot {}]
or
[:> wdr/WebDataRocksReact {}]
None works...shadow-cljs browser-repl and then (require '["webdatarocks" :as wdr]) + (js/console.dir wdr)Pivot property then wdr/Pivot should workcomponentDidMount() {
var config = {};
config.container = ReactDOM.findDOMNode(this);
this.parseProps(config);
this.webdatarocks = new window.WebDataRocks(config);
}./webdatarocks.react import is a local importimport * as WebDataRocksReact from './webdatarocks.react'; is just importing ./webdatarocks.react.js relative to the App.jsjs/WebDataRocksReact if there is a global js/React (which there normally isn't)import "react-image-lightbox/style.css";node-sassnode_modules/react-image-lightbox/style.css into public/css/react-image-lightbox.css and include it via <link rel="stylesheet" href="/css/react-image-lightbox.css"> in your HTMLUse of undeclared Var myproject.views.home/*clojure. Looks like the kind of error where I'm missing something obvious (like maybe needing to require clojure somewhere)*clojure your macro?myproject.views.home/*clojure and it doesn't exist. no more to that error than that.defcomponent*clojure must be coming from somewhere. If you want help you need to provide more code. it is impossible to guess what you are doingshadow-cljs cljs-repl in order to connect with a repl to the app running on my phone, this works well, which is fantastic! my only problem is that when adding new requires I have to run shadow-cljs compile, and then reload the app. this seems to disconnect shadow-cljs cljs-repl. I was wondering if there was a way to reconnect it? my computer is pretty slow, so it generally takes a while to restart everythingdeleteing modules I wanted to be reloaded in a function that runs whenever shadow-cljs recompiles. e.g. in such a function:
(defn start
{:dev/after-load false}
[]
;; delete stuff here
)
maybe that can help? 🙂delete require.cache[require.resolve('./b.js')] 🙂shadow-cljs watch running for your build, so running compile is pointless?:dependencies change. no other restarts are ever required if you use shadow-cljs servershadow-cljs watch, since that triggers webpack which takes a lot of cpu (and eventually restart the app)shadow-cljs compile once, then I run shadow-cljs cljs-repl in order to connect with a repl 🙂yarn start and shadow-cljs cljs-repl I manage to connect to a repl, and then run code on the mobilecljs-repl starts the watch if it is not runningshadow-cljs server separatelycljs-repl quickly without it taking a long timewatch, but since I don't want the automatic recompiles atm I sadly have to turn it off(shadow.cljs.devtools.api/watch :app {:autobuild false}) in a shadow-cljs clj-repl, I don't have to restart any repl processes. my repl connection starts saying No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code., but as soon as the app has finished restarting it works again 🙂shadow-cljs server process started giving me:
[2019-09-14 12:24:48.771 - WARNING] :shadow.cljs.devtools.errors/format-error SocketException Broken pipe
(shadow.cljs.devtools.api/watch-compile! :app), then kill the app then start it again.
when I do that it seems like the cljs-repl still thinks it's connected (when I try to eval things, I get Timeout while waiting for REPL result.).
I could solve this by stopping the watch (using stop-watch) then starting it again.stop-worker (not stop-watch) works though, so no biggie 🙂 still don't need to restartshadow-cljs require clojure, or can it compile clojurescript using just node and the shadow-cljs package?(ns deft.client.search) (defn ^:export -main [& args] (enable-console-print!) (println "Hello shadows!")) (defn reload! [& args] (println "reloaded!"))
shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.52 running at shadow-cljs - nREPL server started on port 50145 shadow-cljs - watching build :local/client.search [:local/client.search] Configuring build. [:local/client.search] Compiling ... [:local/client.search] Build completed. (157 files, 1 compiled, 0 warnings, 3.00s)
npm install --save jquery and then (:require ["jquery" :as jq]) and (jq "#foo"), but I can't figure out how to bring jQuery UI into the picture so that I can its methods.(:require ["jquery-ui"]) and (require ["jquery-ui" :as jqu]) and then (.tooltip (jqu "#foo")).(:require ["jquery" :as jq] ["jquery-ui"])) and then use jq with tooltip and such(intermediate value)(intermediate value)(...).tooltip is not a function). Well, I'll keep looking into it. This is a step in migrating an app away from using jQuery UI, so another option is just to bite the bullet and rewrite the code not to use jQuery UI.jquery-ui package isn't really using commonjs(:require ["jquery" :as jq] ["jquery-ui"] ["jquery-ui/ui/widgets/tooltip"])) might work.js files working on a global jQuery objectscript tag["jquery-ui/ui/widgets/tooltip"] works, but as you said, would need to figure out which dependencies to require as well."react-navigation-stack" in shadow-cljs?
I can't pass one error:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object> This error is located at: in RTCView (at View.js:45) in View (at AppContainer.js:98) ...My code in app.cljs is:
(ns
(:require
["expo" :as ex]
["react-native" :as rn]
["react" :as react]
[reagent.core :as r]
[re-frame.core :as rf]
[example.events]
[example.subs]
["react-navigation-stack" :as ReactNavigationStack]))
(def text (r/adapt-react-class (.-Text rn)))
(def view (r/adapt-react-class (.-View rn)))
(def app-registry (.-AppRegistry rn))
(def styles
^js (-> {:container
{:flex 1
:backgroundColor "#fff"
:alignItems "center"
:justifyContent "center"}
:label
{:fontWeight "normal"
:fontSize 15
:color "blue"}}
(clj->js)
(rn/StyleSheet.create)))
(defn app []
(r/create-class
{:reagent-render
(fn [props]
[view {:style (.-container styles)}
[text {:style (.-label styles)} "Home page"]
])
}))
(def routes {:Home {:screen (r/reactify-component app)}})
(defn app-root []
; [c/view {:style (.-container styles)}
[(r/adapt-react-class ((.-createStackNavigator ReactNavigationStack)
(clj->js routes)
(clj->js {:initialRouteName "Home"})))])
(defn init []
(rf/dispatch-sync [:initialize-db])
(.registerComponent app-registry "main" app-root)
)
(defn app-root []
; [c/view {:style (.-container styles)}
[(r/adapt-react-class ((.-createStackNavigator ReactNavigationStack)
(clj->js routes)
(clj->js {:initialRouteName "Home"})))])createAppContainer call maybe? https://github.com/react-navigation/stack/blob/master/example/App.js#L141-L161(ns
(:require
["expo" :as ex]
["react-native" :as rn]
["react" :as react]
[reagent.core :as r]
[re-frame.core :as rf]
[example.events]
[example.subs]
["react-navigation-stack" :as ReactNavigationStack]))
(def styles
^js (-> {:container
{:flex 1
:backgroundColor "#fff"
:alignItems "center"
:justifyContent "center"}
:label
{:fontWeight "normal"
:fontSize 15
:color "blue"}}
(clj->js)
(rn/StyleSheet.create)))
(defn app []
[:> rn/View {:style (.-container styles)}
[:> rn/Text {:style (.-label styles)} "Home page"]])
(def routes {:Home {:screen (r/reactify-component app)}})
(defonce nav-stack
(ReactNavigationStack/createStackNavigator
(clj->js routes)
#js {:initialRouteName "Home"}))
(defn app-root []
[:> nav-stack {}])
(defn init []
(rf/dispatch-sync [:initialize-db])
(rn/AppRegistry.registerComponent "main" app-root))react-navigation-stack, clone it to reproduce my error. After cloning you will need to run yarn install then shadow-cljs watch app and after project compiles in second terminal run yarn start. @thheller can you take a look, please?Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Repo to reproduce: https://github.com/Kruszylo/rn-rf-shadowcreateStackNavigator, which probably isn't a react componentr/reactify-component:
(defonce nav-stack
(r/reactify-component (ReactNavigationStack/createStackNavigator
(clj->js routes)
#js {:initialRouteName "Home"})))
did not helpcreateStackNavigator to createAppContainer[:frontend] Build failure: The required namespace "react" is not available, it was required by "reagent/core.cljs".. I have react in my package.json. How should I deal with reagent requiring cljsjs/react?
react-navigation-stack.npm`shadow-cljs - starting via "clojure" Executable 'clojure' not found on system path. D:\Dev\Spill\spill_reactnative λ [master ≡]clojure Clojure 1.10.1 user=>
shadow-cljs - config: ...\shadow-cljs.edn cli version: 2.8.39 node: v10.16.0 🙂:source-paths ["target/classes" ...]:clj : loading namespace deft.untyped.logic
:clj : loading namespace deft.untyped.fn
:clj : loading namespace deft.untyped.error
[:local.client.search] Build failure:
------ ERROR -------------------------------------------------------------------
File: /Users/alexandergunnarson/Creating/Code/deft/src/all/deft/untyped/error.cljc
Exception: No namespace: deft.untyped.error found
clojure.core/the-ns (core.clj:4162)
clojure.core/ns-publics (core.clj:4189)
clojure.core/ns-publics (core.clj:4189)
shadow.build.macros/find-macros-in-ns (macros.clj:63)
However "src/all" is included in the shadow-cljs.edn’s :source-paths. One thing I thought might be the issue is this:
(ns deft.untyped.error
...
#?(:cljs (:require-macros
[deft.untyped.error :as self])))
However, this namespace uses the same paradigm, and is already loaded prior to the error ns:
(ns deft.untyped.logic
...
#?(:cljs (:require-macros
[deft.untyped.logic])))
(require 'deft.untyped.error) works just fine:clj : loading namespace deft.untyped.logic :clj : loading namespace deft.untyped.fn :clj : loading namespace deft.untyped.error
(ns <whatever> ...) (log-that-stuff) ...
shadow-cljs clj-repl and (require 'deft.untyped.error) works?(find-ns 'deft.untyped.error)load-file[2:0]~shadow.user=> (load-file "/Users/alexandergunnarson/Creating/Code/deft/src/all/deft/untyped/error.cljc") Syntax error (ClassNotFoundException) compiling at (src/all/deft/untyped/error.cljc:77:1). deft.ErrorI think I cleared out the Java stuff without recompiling it when I deleted the
target directory. The logs didn’t allude to a class not being foundClassNotFoundException show up before in shadow-cljs, but not this time for whatever reasonnpx create-cljs-project foo then cd foo npx shadow-cljs node-replFireplace: no default ClojureScript REPL:Piggieback :app but no resultsIf you are starting nREPL some other way, run :FireplaceConnect host:port.shadow-cljs node-repl you'd do :Piggieback :node-replnpx create-cljs-project hello-node:Piggieback (cider.piggieback/cljs-repl :node-repl)?shadow-cljs node-repl, Connected, Runned Piggieback :node-repl and tried to run Eval (+ 1 1) and got Fireplace: session closed:Piggieback (cider.piggieback/cljs-repl :node-repl)Editor Section in docs, maybe it is not supposed to work at allCljEval (shadow/repl :node-repl):Piggieback :node-repl should end up calling(defn PopOver []
[:> bp/Popover {:content [:div
[:> bp/Menu {:large false}
[:> bp/MenuItem {:text "test1"}]
[:> bp/MenuItem {:text "test2"}]
[:> bp/MenuItem {:text "Test3"}]]]
:enforceFocus false
;:position "Position.BOTTOM_LEFT" ;;error
:interactionKind "HOVER"}
[:> Button {:variant "info"} "hello"]]
) and require with ["@blueprintjs/core" :as bp] .. my problem is how to add content section and position part of the code:content expects a react element but you are passing a cljs vector(reagent/as-element [:div ...]):position bp/Position.BOTTOM_LEFTpackage.json file?:exclusions in the project.clj file - cljsjs/react etc - I think it's the cljsjs part I don't understand - basically how it's all connected. I come from React/Vue background and am used to just having one package listed[thheller/shadow-cljs "2.8.52"]
[thheller/shadow-cljsjs "0.0.20"][thheller/shadow-cljsjs "0.0.20"] this you don't include at all[reagent "0.9.0-rc1"]
[thheller/shadow-cljs "2.8.52"]
and then
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
} :exclusions for cljsjs:dependencies and :source-paths:js-options to map react and react-dom straight to the prod min files. That seemed to work.shadow-cljs release app --debug or shadow-cljs release --pseudo-names might provide clues if you are not using that yetshadow-cljs check app might be useful but has a lot of false positivesnpx shadow-cljs watch stories I get the following error:
npx: installed 91 in 3.066s shadow-cljs - config: /Users/.../shadow-cljs.edn cli version: 2.8.52 node: v10.16.3 shadow-cljs - connected to server Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:436). shadow.cljs.devtools.cliI'm unsure what is causing this error? Is it shadow-cljs related or Storybook etc
[org.clojure/core.async "0.3.465"] so it should still work...(shadow.cljs.devtools.server/start!)?(:require [shadow.cljs.devtools.cli]) in the ns that starts the server to ensure that it is loaded[org.clojure/core.async "0.4.500"][shadow.cljs.devtools.cli] [shadow.cljs.devtools.api :as shadow-cljs] [shadow.cljs.devtools.server :as shadow-server]
No config for build "stories" found. Build id required. - It must not be picking up my stories config in shadow-cljs.edn{:lein true
:builds {:frontend {:target :browser
:output-dir "resources/app/public/js"
:asset-path "/js"
:modules {:main {:entries [frontend.core]}}}}
:stories {:target :npm-module
:output-dir "resources/app/public/js"
;; storybook already handles all reloading
:devtools {:enabled false}}}}
{:lein true
:builds {:frontend {:target :browser
:output-dir "resources/app/public/js"
:asset-path "/js"
:modules {:main {:entries [frontend.core]}}}}
:stories {:target :npm-module
:output-dir "resources/app/public/js"
;; storybook already handles all reloading
:devtools {:enabled false}}} }No config for build "stories" found. :face_with_monocle::stories wasn't in :builds, I didn't paste the corrected versionulimit -n ( 30720, which seems like it should be enough). blatting their .shadow-cljs directory seems to fix the problem temporarily, but it still seems to crop up after a while. were on cli version: 2.8.52 node: v12.5.0 (which is later than https://github.com/thheller/shadow-cljs/issues/261 fix)... any ideas ?.shadow-cljs I would ....shadow-cljs is just cache, which will just be written again so it should end up at the same values after one buildfind .shadow-cljs | wc is returning 7118 for me atm... well within my 32k ulimitnode_modules openlsof or something maybe?.shadow-cljs next time it happens and get an lsof dump--config-merge EDN to those buildslsof dump @thheller - almost all the files are .jars from ~/.m2.shadow-cljs directory therepromesa-1.9.0.jar is open 142 times!reagent-0.8.1.jar 362 times(set! (.-onerror js/document) (fn [...] (log-pretty-error ...))), 2) bisecting the code by commenting out parts till I get to the error, and 3) just restarting the build. 2) and 3) have proven particularly time-consuming. Here’s an example of something (I still don’t know what it is — have to do good ol’ option 2 and 3 till I figure out) :
[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException: java.lang.String cannot be cast to clojure.lang.Named
clojure.core/namespace (core.clj:1597)
clojure.core/namespace (core.clj:1597)
shadow.build.compiler/write-cached-cljs-resource/spec-filter-fn--11841 (compiler.clj:707)
shadow.build.compiler/write-cached-cljs-resource/fn--11844 (compiler.clj:713)
clojure.core/fn--8429/fn--8431 (core.clj:6840)
clojure.core.protocols/iter-reduce (protocols.clj:49)
clojure.core.protocols/fn--8140 (protocols.clj:75)
clojure.core.protocols/fn--8140 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
clojure.core/reduce (core.clj:6828)
clojure.core/fn--8429 (core.clj:6830)
clojure.core/fn--8429 (core.clj:6830)
clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
clojure.core/reduce-kv (core.clj:6856)
clojure.core/reduce-kv (core.clj:6847)
shadow.build.compiler/write-cached-cljs-resource (compiler.clj:711)
shadow.build.compiler/write-cached-cljs-resource (compiler.clj:677)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:832)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:762)
shadow.build.compiler/par-compile-one (compiler.clj:895)
shadow.build.compiler/par-compile-one (compiler.clj:850)
shadow.build.compiler/par-compile-cljs-sources/fn--11897/iter--11919--11923/fn--11924/fn--11925/fn--11926 (compiler.clj:968)
clojure.core/apply (core.clj:665)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/apply (core.clj:669)
clojure.core/bound-fn*/fn--5749 (core.clj:2003)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
java.lang.Thread.run (Thread.java:748)
[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException:
[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException:
I’m happy to post more of these sorts of things as I come across them. Had quite a few yesterday but I worked through them.
(By the way those last ClassCastExceptions have no stack trace and it’s not obvious whether they relate to the first one)
^^^ Solved this particular issue by method #3. Doesn’t fix the crypticness but good to know it’s at least an available option..shadow-cljs directorylsof dump during compilation, since perhaps whatever open files are causing the issue are getting closed after compilation failsspec-filter-fns/def that does like (s/def :whatever/spec-name "docstring" {:meta-stuff "if you want"} some-spec)(s/def "docstring" :whatever/spec-name)(.-field something) as opposed to (goog.object/get something "field")?(.-field something). you just need to "tag" it either directly or indirectly as js to tell the compiler to not rename it. so either (.-field ^js something) or `(fn [^js something] ...). see https://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html(ns app.core
(:require [reagent.core :as r :refer [atom]]
["react-native" :as RN :refer [AppRegistry]]))
(defn app-root []
[:> RN/View {:style {:flex-direction "column"
:margin 40
:align-items "center"
:background-color "white"}}
[:> RN/Text {:style {:font-size 30
:font-weight "100"
:margin-bottom 20
:text-align "center"}}
"Hi Shadow!"]])
(defn init []
(.registerComponent AppRegistry
"YsjApp"
#(r/reactify-component app-root)))
The refactor-nrepl middleware isn’t available! Did you remember to install it?
From the code of clj-refactor it tests the availability of (cljr--op-supported-p "find-symbol"). But I thought, CIDER is injecting all the relevant parts in its jackin call.
So anyone has a clue how I get this running?refactor-nrepl dependency manually?cljsjs packages that provide those npm modules. shadow-cljs would continue using npm directly but others would fall back to cljsjslsof output from my shadow build which is failing with Too many open files - https://gist.github.com/mccraigmccraig/230d72c25b3a36d31c57fc5369ad0aabvnode: FD unavailable entries... don't know what they are yetlsof reading structures which are in the middle of initialisationchild_process.spawn from gulp)ulimit -n to 262144, which seems ridiculously overspecified, and i'm still seeing the errorshadow-cljs command issued manuallyshadow-cljs --config-merge '{:output-dir "target/yapster-web/js" :compiler-options {:closure-defines {er-webui.env/app-deployment-platform "web" er-webui.env/api-url "" er-webui.env/expected-api-version "2.6.0" er-webui.env/client-build-version "2.6.0.0" er-webui.env/sentry-release "yapster-2.6.0.0" er-webui.env/log-level "info"}}}' release yapdev
--verbose please?bash or zsh subshell it's still got ulimit -n of 262144:compiler-options {:parallel-build false} in your build configjava doesn't reset max-open-files:compiler-options {:parallel-build false} didn't change anythingspawnSync is maybe setting a ulimitspawnSync("ulimit", ["-n"], {stdio: "inherit"})const { spawnSync } = require("child_process");
spawnSync("ulimit", ["-n"], {stdio: "inherit"});
is 262144export default { title: 'foo'};(defn ^:export ?(def ^:export default ...)storiesOf('atoms/Button', module)
.add('text', () => <Button>Hello</Button>)
.add('emoji', () => <Button>😀😎👍💯</Button>);
is now:
export default { title: 'atoms/Button' };
export const text = () => <Button>Hello</Button>;
export const emoji = () => <Button>😀😎👍💯</Button>;
:npm-module I presume?(def ^:export default #js {:title "atoms/Button"}) (defn ^:export text [] (reagent/as-element [:button "Hello"])):stories {:target :npm-module(:require [reagent.core :as reagent])export const text etc(:require
["@storybook/react" :refer (storiesOf)]
["@storybook/addon-actions" :refer (action)]))
() => <Button>Hello</Button>; doesimport React from 'react';
import { Button } from '@storybook/react/demo';
export default { title: 'Button' };
export const withText = () => <Button>Hello Button</Button>;
(ns foo.bar
(:require
[reagent.core :as reagent]
["react" :as react]
["@storybook/react/demo" :refer (Button)]))
(def ^:export default #js {:title "Button"})
(defn ^:export withText []
(reagent/as-element [:> Button "Hello Button"]))(ns foo.bar
(:require
["react" :as react]
["@storybook/react/demo" :refer (Button)]))
(def ^:export default #js {:title "Button"})
(defn ^:export withText []
(react/createElement Button nil "Hello Button"))(ns frontend.ui.component.button-stories
(:require
[reagent.core :as reagent]
["react" :as react]))
(def ^:export default #js {:title "Button"})
(defn ^:export withText []
(reagent/as-element [:button "Hello"]))
export default creates an .export property just like what we didfoo.bar.default:npm-module is turning that into module.exports.default = ...can't redefine non-configurable property "default"
Storybook can't be trying to access the files directly if they worked on initial load?shadow-cljs release ... right? there is no server-mode instance running prior?shadow-cljs release ... - users have also seen the issue with watch buildsgit revert of that commit causes conflicts, which are beyond my ability to fix in a couple of minutes, so i haven't tested out the hypothesis that it's that commit which is to blamewatch is running could you try shadow-cljs clj-repl (separate terminal) and dump @shadow.build.macros/active-macros-ref?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "57243f363338207a343b3d241765796f796263"}, :content ("[email protected]")}. I added some caching so the macro stuff doesn't touch so many files. maybe that helps?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c8bba0a9aca7bfe5aba4a2bb88fae6f0e6fdfc"}, :content ("[email protected]")}, so i should get some more reports from my other devs tomorrowURLConnection which is holding files for file: URLs open then ?.jar2.8.54 is confirmed to resolve the too-many-open-files issue!.55 for the emacs users. I accidentally broke the cider detection mechanism(let [v (js/RegExp. "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$")]
(.test v p))
Then there is a compiler error:
main.cljs [line 55, col 54] Unsupported escape character: \d.
new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$").test("foo")
false
RegExp seems doesn't work for this, but # does, please try it. And shadow-cljs can't compile "#" pattern too.The shadow-cljs ClojureScript REPL is not available from CIDER with the new {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e4978c85808b93c987888e97a4d6cadccad1d0"}, :content ("[email protected]")} Do I need to change something?shadow.repl to be present, was it changed?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adbbadb6b6"}, :content ("[email protected]")} which brings back that ns for cider. doesn't do anything but should fix the detection.RegExp? 😂(let [v (js/RegExp. "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[^]{8,16}$")]
(.test v p))\\d not \d:compiler-options {:optimizations :advanced} affect this. when running shadow-cljs release app I had to set them to :simple in order to get the app to run. would this affect performance a lot?:compiler-options {:infer-externs :all} I get some 400 warnings. it'd take some time to fix those, so I just wanted to ask beforehand if you knew if there'd be any significant performance (in terms of fps) gains, or if I should focus on other things (e.g. not creating as many objects per frame):infer-externs :all. :auto is enough and all you can fix anyways.:advanced will be "smaller" so it'll probably load faster. runtime performance should be the same as :simple["@material-ui/core/styles" :refer [makeStyles]], what's the fully qualified name of makeStyles since @material-ui.core.styles/makeStyles will try to deref?makeStyles in a macro(cljs.analyzer/resolve-var &env 'makeStyles)(defn do-something [x] (makeStyles x)) and call do-something from the macrocider-jack-in-cljs I get a REPL which tells me:
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.cider-connect-cljs instead of jack-in, emacs will ask you a few questions like host, port, and type (i don't have access to my cljs environ so I can't be specific)... you'll give it for ex localhost 8888 shadow and your shadow target code like dev or app or however you set it upshadow-cljs watch [app]npx shadow-cljs server. There is no browser here, this is node.shadow-cljs node-repl:node-repl build. however that is done in cider I don't knowcider-jack-in.cider-connect-cljs and put in the nrepl port number output when running shadow-cljs node-repl is a Java REPLcider-connect-cljs then set the host and port then choose the cljs repl type as shadow-select then give the node-repl buildshadow-select I get error in process filter: Wrong type argument: stringp, nil in the minibuffer, and I never get to choose a build. So likely I have some package version mismatch somewhere. The story of Emacs....node path/to/output/script.jsnode-repl in Emacs (basically, a CLJS REPL without an associated build) I do:
1. cider-jack-in which lands me in a CLJ REPL
2. (shadow/node-repl) which lands me in a CLJS REPL where I don’t need to start an external process like node path/to/build/output.js or a browser window:cljs/quit to go back to the CLJ REPL and start/stop/REPL in to my other builds(condp = tag
...
:clojure.spec.alpha/invalid
(throw (ex-info
"Visual Segment Value Was Invalid"
{:value value
:explain-data (spec/explain-data :visual-segment/value value)})))
478 | (condp = tag
-----------^--------------------------------------------------------------------
Syntax error macroexpanding cljs.core/let.
Call to cljs.core/let did not conform to spec.
-- Spec failed --------------------
([... :clojure.spec.alpha/invalid ... ...] ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
should satisfy
any?
-- Relevant specs -------
:shadow.cljs.devtools.cljs-specs/bindings:
(clojure.spec.alpha/and
clojure.core/vector?
shadow.cljs.devtools.cljs-specs/even-number-of-forms?
(clojure.spec.alpha/* :shadow.cljs.devtools.cljs-specs/binding))
-------------------------
Detected 1 error
clojure.spec.alpha/invalid to anything else alleviates the error 😵(condp = tag :clojure.spec/invalid :foo) works fine(condp = :clojure.spec.alpha/invalid :foo :bar) this fails with the error?(let [x :clojure.spec.alpha/invalid] x)(def INVALID :clojure.spec.alpha/invalid) and then use INVALID in the condp(def blame-alex-miller ...)shadow-cljs watch app --verbosewatch did it say connected to server on startup?yarn shadow-cljs watch main renderer and after the builds complete, i launch the electron app from the command line.
i don't see "connected to server" in the output.
when i control-c for shadow-cljs, i see: shadow-cljs - Connection closed! in white text on a red background in the electron app
when i subsequently start the watch with: yarn shadow-cljs watch main renderer, i see very similar output to the first time (including no "connected to server")
if i issue control-r to the electron app, the devtools console of the electron app reports: shadow-cljs Websocket connected! and i am able to reconnect to a cljs-repl for renderer via the command line and succesfully evaluate code. however, i still see the white text on red background indicating "shadow-cljs - Connection closed!" and no successful connection to a repl for main's js-runtime.main isn't restarted if you control-r.babelrc file within a module's folder. I don't want Babel's default transformation of ES6 module syntax to commonjs, so have set it to false (https://babeljs.io/docs/en/6.26.3/babel-preset-env#modules). This doesn't seem to be working. Does shadow-cljs do any other transformation that would effect this?defaultcan't redefine non-configurable property "default". It also loads "Default" as a story, which is wrong, there should only be one story which is "Normal".export default is treated.:npm-module{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ed9e858c89829ac08e81879eaddfc3d5c3d8db"}, :content ("[email protected]")}(defn ^:export normal [button] "Hello")
(defn ^:export normalXXX [button] "Hello")
this._data[id] is undefined
Do you get that too? Changing anything else, the reload works as expected.[:no-worker :app] mean when attempting to start a CLJS REPL for the build :app?SHADOW import error /home/project/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$react_native.js
/home/project/node_modules/react-native/Libraries/Utilities/warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
^^^^^^^^^^
SyntaxError: Missing initializer in const declaration
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
:libs option, so I just go ahead and :require as normal?goog.module. I guess I have to switch to the old format until CLJS supports the new format.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "abd8c3cacfc4dc86c8c7c1d8eb998593859e9c"}, :content ("[email protected]")} it should properly fail if a hook failsgoog.module('test.Foo');
class Foo {
/**
* @param {string=} a
*/
constructor(a) {
/**
* @type {string}
*/
this.a = a || "G7S";
}
/**
* @return {string}
*/
say() {
return "Hello " + this.a;
}
}
exports = Foo;
:require it in a cljs namespacegoog.provide works as expectedgoog.module('demo.googClass');
goog.module.declareLegacyNamespace();
class Foo {
/**
* @param {string=} a
*/
constructor(a) {
/**
* @type {string}
*/
this.a = a || "G7S";
}
/**
* @return {string}
*/
say() {
return "Hello " + this.a;
}
}
exports.Foo = Foo;[demo.googClass :refer (Foo)]:npm-module target and running jest on the test files did the trick for testing snapshots for react-native components. shadow already supports it, thanks!test/my_project/core_test.cljs, and in shadow-cljs.edn I have :source-paths ["src" "test"], as well as a build defined as {:test {:target :node-test :output-to "unit-tests.js" :autorun true}}. However, when I go to run shadow-cljs release test, I see
[:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (27 files, 1 compiled, 0 warnings, 4.51s)
deftest statement in the test file, with two assertions.shadow-cljs restart. My bad. Thanks for the help though!/Users/jberlage/toto/node_modules/react-native-keychain/index.js:2
import { NativeModules, Platform } from 'react-native';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:872:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at /Users/jberlage/toto/unit-tests.js:750:684
at Object.<anonymous> (/Users/jberlage/toto/unit-tests.js:842:3)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
Regression, or should I just lose the :node-test target entirely for react-native projects? The tests are limited to stuff that would compile and run on node, but perhaps I can’t avoid importing something that will break.import()?shadow.cljs.devtools.api, is there a way to get the number of build warnings? I would like to assert they’re zero{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "53203b32373c247e303f392013617d6b7d666b"}, :content ("[email protected]")} adds :compiler-options {:warnings-as-errors true} or :compiler-options {:warnings-as-errors #{:undeclared-var}} to only error out on specific ones$jscomp wasn’t in scope:output-wrapper true in the main bundle so $jscomp is never in the global scope:output-wrapper true could work with modules?$jscomp$jscomp but :advanced compilation got rid of it or renamed it$jscomp?:something #{ns.with.warnings} wouldn't error out for warnings in that ns. could allow wildcards like some-lib.*.:warnings-as-errors {:ignore #{ns.*} :warning-types #{:undeclared-var}}:ignore-warnings-in-ns #{ns.*} instead of adding the :ignore in :warnings-as-errors? We also have a dep that causes warnings and we can't really do anything about them, so I'd prefer just to ignore those warnings altogether and then let all other warnings throw errors.:defaults {:compiler-options ...} at the top level. so config that applies to all buildsreact-bootstrap, i'm hoping someone can help. when i require react-bootstrap:
(ns myproject.core (:require ["react-bootstrap" :as bs]))i get the following runtime exception:
TypeError: (0 , _uncontrollable.default) is not a functioni think last time i asked about this error regarding another npm module, the cause had to do with a transitive dependency conflict?
0.8.0 and 0.9.0-rc1 in my shadow-cljs.edn :dependencies(ns demo.foo)
(defn hello [who]
(str "Hello, " who "!"))
(defn generate-exports []
#js {:hello hello})
and this config
:builds
{:lib {:target :node-library
:output-to "package/lib.js"
:exports-fn demo.foo/generate-exports}}
and this command: shadow-cljs release lib
I’m getting a “lib.js” size of 98k. Does that seem right?cljs.core and stuff/js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$$emotion$core$dist$core_browser_cjs shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:36 shadow$provide.module$node_modules$react_select$dist$react_select_browser_cjs @ /js/cljs-runtime/module$node_modules$react_select$dist$react_select_browser_cjs.js:3 shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:34 shadow.js.require @ /js/cljs-runtime/shadow.js.js:55 eval @ /js/cljs-runtime/doublethedonation.integrations.records.js:9 goog.globalEval @ mp360.js?updated=20190805:827 env.evalLoad @ mp360.js?updated=20190805:2174 (anonymous) @ mp360.js?updated=20190805:2633 /js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$react_select$dist$react_select_browser_cjs
[:> Select {:options [{:value "Chocolate" :label "Chocolateee"}]}]<undefined options="[object Object]"></undefined>
clj->js?.clj and failed due to different dependencies under different profiles. What's the advantage of not splitting them? Why does splitting "make things harder to use"?.clj files yet are meant for CLJS. so do you put them in src/clj or src/cljs or src/cljc?src/frontend src/backend or whatever. I just don't like splitting by file extension. feels pointless IMHO.user.clj is picked up by shadow-cljs, and mine included other .clj files. I'm having trouble setting up a similar situation with shadow. Is this possible?:devtools {:devtools-url ""} in the build config unless you enable SSL in shadow-cljs?failed to load aclaimant.dashboard_v2.pages.tasks.list.js TypeError: re_frame.std_interceptors.fx_handler__GT_interceptor is not a functionRequiring module "build/index.js", which threw an exception:Module Entry "wish.worker.core" was moved out of module ":worker".
It was moved to ":app" and used by #{:app :worker}.wish.worker.core and the entry for the :worker module. But something from the :app module also did a direct require for wish.worker.core.(:require [wish.worker.core ....]) somewhereload-file and such☁ wish [dhleong/shadow-cljs] ag wish.worker.core
shadow-cljs.edn
44: :worker {:entries [wish.worker.core]
project.clj
136: :compiler {:main wish.worker.core
146: :compiler {:main wish.worker.core
src/cljs-worker/wish/worker/core.cljs
1:(ns wish.worker.core
It’s not required anywhere(in-ns 'wish.main) and then do (require '[wish.worker.core :as x])shadow.cljs.devtools.client.browser.ws_connect(); in the browser consolespecter, for example, produces: ------ WARNING #2 - :undeclared-var -------------------------------------------- Resource: com/rpl/specter.cljc:1275:19 Use of undeclared Var com.rpl.specter/java -------------------------------------------------------------------------------- ------ WARNING #3 - :undeclared-var -------------------------------------------- Resource: com/rpl/specter.cljc:1288:19 Use of undeclared Var com.rpl.specter/java --------------------------------------------------------------------------------
:compiler-options {:warnings {:that-type false}}lein clean is the default fix allweavejester/impi with shadow-cljs? I’m a little lost about the setup of pixi.js[weavejester/pixi "4.2.3-0"], which I think should be from cljsjs, but why it’s a separate package in clojars? I mean, there’s already a cljsjs/pixi on clojars, then why do we need another weavejester/pixi?shadow-cljs classpath should do the trick in newer versionsUnresolved var p/alet (https://github.com/funcool/promesa/blob/3.0.0/src/promesa/core.cljc) in one build but in another build where I’m also using that macro there is no warning.cljs.nodejs.require = require; would appear in a compiled file when the target is :karma?cljs.nodejs ns:main {:target :browser
:asset-path "/js/main"
:modules {:main {:entries [demo.client]}}
:devtools {:watch-dir "resources/public/styles"
:after-load demo.client/restart
:preloads [fulcro.inspect.preload demo.development-preload]}}
:watch-dir "resources/public" as the path your css uses is likely /styles/foo.css:node-library should suffice(shadow.cljs.devtools.api/watch-compile! :app) quickly it seems like it compiles using "old" code. is there a function I could call to force it to use "fresh" sources?(Thread/sleep 500)? 😛watch from the clj-repl?:require an NPM module and it results in an empty js object?shadow-cljs handles browser connections - I experimented with connection an app to chromium and firefox, the chromium app was the one running, when I did (shadow/repl :main) and later I opened the same localhost in the firefox one.
Curiosity
I was wondering whether there’s a way to inspect the network calls in both browsers. From my initial experimentation it seems that the level of integration is definitely tighter with the first browser where I connected with (shadow/repl :main).
I read the shadow-cljs user guide but couldn’t find any config as such - please let me know if it’s possible or not.Uncaught ReferenceError: $jscomp is not defined
at statsBar (stats_bar.js:13)
at Constructor.eval (d3.cljs:25)
at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:189)
...
getRequiredKeyconst [width, height] ... (probably):output-feature-set :es6 or up so it doesn't rewrite those at allstatsBar and getRequiredKey will actually be global functionsvar or so){:target :browser
:modules {:main {:entries [amperity.web.dev
amperity.web.prod]}}
:output-dir "resources/public/js/compiled/"
:asset-path "js/compiled/"
:compiler-options {:language-in :es6
:output-feature-set :es6
:devcards true}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}}
:preloads [day8.re-frame-10x.preload
devtools.preload]
:external-config {:devtools/config {:features-to-install
[:formatters :hints :async]}}}
var $jscomp$destructuring$var0 = $jscomp.makeIterator(getRequiredKey(options, "dimensions"));:build-hooks(get-in build-state [:compiler-env :cljs.analyzer/namespaces 'the.ns :your/key]):dev-http {8000 {:handler }} as a cheap way to test out client-server interactions. However, when eval’ing server functions, I’m finding that they aren’t picked up until I “bump” the shadow-cljs.edn file, causing shadow to restart the server. Is there a better way to reload server changes?cider-connect-sibling-clj in emacs, would that have the http server in-process? After reloading the ns with my handler in it, subsequent HTTP requests from the cljs app don’t appear to invoke the newly eval’d code.Exception in thread "async-dispatch-5" java.lang.RuntimeException: java.lang.Exception: Not supported: class cljs.tagged_literals.JSValue
at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:65)
at cognitect.transit$write.invokeStatic(transit.clj:167)
at cognitect.transit$write.invoke(transit.clj:164)
at shadow.cljs.devtools.server.common$fn__15653$fn__15654.invoke(common.clj:59)
at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
at clojure.core.async.impl.channels$chan$fn__1714.invoke(channels.clj:300)
at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj:83)
at clojure.core.async.impl.ioc_macros$put_BANG_.invokeStatic(ioc_macros.clj:992)
at clojure.core.async.impl.ioc_macros$put_BANG_.invoke(ioc_macros.clj:991)
at shadow.cljs.devtools.server.web.api$eval36151$fn__36154$fn__36208$state_machine__6737__auto____36227$fn__36229.invoke(api.clj:82)
and so forth. Seems to happen during the flush stage…UI says:
Compiling ... Flush: cljs/core.cljs
shadow.module.shared.append.js:189 Uncaught TypeError: Cannot read property 'env' of undefined
at shadow.module.shared.append.js:189
which is on:
shadow.cljs.bootstrap.env.set_loaded(["goog.i18n....
And when running the after-load hook I get:
Uncaught Error: Namespace "goog.debug.Error" already declared.
shadow.cljs.bootstrap.env is one of your :entries of the :shared module#js ... value creeps into a websocket message when it shouldn't. not sure how it would get there. do you have #js literals in some metadata maybe? ns/def/defn?... ["react-columned" :as Columned] ...
and mount the component like this:
[:> Columned
[:img {:alt "Image 1" :src ""}]
[:img {:alt "Image 2" :src ""}]
[:img {:alt "Image 3" :src ""}]]
But it doesn't work... what I'm doing wrong?No Clojure project was detected. The refactor-nrepl middleware was not enabled. I have not had much luck chasing this down on the interweb and was wondering if anyone here might be able to point me add a helpful answer or at least in the right direction. Seems pretty obvious but I can't reconcile the error message with my shadow-cljs.edn configuration, which looks correct to me. I can DM the configuration to anyone that is willing to help should that be necessary. Thanks!shadow-cljs.edn is a project rootrefactor-nrepl.shadow-cljs.edn file i dont see any clojurescript version or dependence. i understand shadow-cljs use webpack. but it dont need any clojurescript api to compile clojure code?package.json:dependencies listed in shadow-cljs.edn have [thheller/shadow-cljs "..."] added automaticallyshadow-cljsforce dev to use the latest clojurescript versionnode_modules/<package>/dist/css into resources/public/css and adding it to my index.html as an asset?node-sass but just copying might be enough as wellmain.scss that includes all the other stuff I want. so @import "node_modules/foo/bar.css"Makefile will do 😉normalize.scss from npmyarn add xxxlib and a record is added to package json
4 to add/remove dependencies I have to restart the shadow-cljs server
5 to connect to repl in Cursive I created a Clojure configuration in IntelliJ with the specified nrepl port
6 once the server is started I launch the configuration and then start a repl command from the context menu to start cljs node repl
I do find it a rather verbose process, especially when I need to add new dependencies, to repeat the steps 3-6 every time. Is there a simpler way?yarn add dependencies. The guide does still recommend a restart on adding new CLJ/CLJS :dependencies, thoughshadow-cljs.edn, so you may want to use either :deps true (my preference) or :lein true.
4-5-6. Personally, I rarely use CLJS repl - with hot reload, I find it simple enough to just make a change and see how it works. With that being said, I embed shadow-cljs so that when I start my app in dev environment, shadow-cljs is already running.:dependencies change is the only way to ensure everything works reliably. I have been experimenting with adding them dynamically but it hasn't been worth the hassle to be honestlog-style option, to fix the unreadable text in dark mode. I’m not sure how to use it though - env var?2.8.59(goog-define shadow.cljs.devtools.client.env/log-style "color: white")?(set! shadow.cljs.devtools.client.browser/devtools-msg
(fn devtools-msg [msg & args]
(js/console.log.apply
js/console
(into-array
(into [(str "%cshadow-cljs: " msg) "color: #5981D8;"]
args)))))
🙂:devtools {:log-style "color: green;"} in your build config2.8.60 where :devtools {:log-style "color: green;"} should workshadow.cljs.devtools.server/start! and shadow.cljs.devtools.api/watch with the required arguments.load-cljs-edn and its callers are still used in many places.shadow-cljs was giving me just the same errors.
But maybe that's because I embed the whole shadow-cljs server process, I don't know.juxt/aero.:js-options via CLI options? Because I only want some of them enabled iff I have to debug the compiled JS and not for the regular development.
As an alternative - is it possible to inherit builds, in a way? So that I can have two builds with exactly the same config except for the :js-options value.:js-options from the command lineshadow-cljs release app --config-merge '{:js-options {:whatever true}}'(shadow/release :app {:config-merge [{:js-options {:whatever true}]}) but note the extra vectordissoc values(shadow/release :app {:config-rewrite some-fn}) if that would make senseshadow-cljs release app --debug or --pseudo-names meant to aid debugging:js-options it isn't currently setting I'm happy to change that:compiler-options {:pretty-print true :pseudo-names true} for --pseudo-names:config-merge already looks a bit sketchy to me, let alone :config-rewrite. 🙂 At this point, I cannot really say if that will be more useful for the tool in general.
As you have probably guessed by now, my personal choice would still be to allow heavy customization and adopt the caveat emptor principle. It should scale well and if something leaks and becomes popular enough and remain broken enough to cause a lot of angry noises, it may just be useful enough to actually include it in the main tool. Or create a separate tool/plugin with a separate maintainer.
But that's all just thinking out loud, don't take it to heart.shadow.cljs.devtools.graph.builds use shadow-cljs.edn and it's impossible to override this behavior. But I have no clue what the resolvers and mutations do (the graph functionality seems to be used only in tests and the dev webserver), so maybe it's completely justified.
2. NREPL :init-ns cannot be changed. But that's not really an issue since, I think, it's possible to write and use a custom middleware that does it.
3. Impossible to embed build report generation because it reads the EDN config. Right now I have to generate a shadow-cljs.edn file specifically for this feature every time I need.
4. The code from compile, release, check, make-runtime, with-runtime could be reused if it accepted an optional config map. Right now I have a copy of these functions in my own code that just adds a single config argument.
That's pretty much all I could find and/or had experience with. As I mentioned before, I don't use shadow's CLJ[S] REPL at all, so maybe there are some things there as well.
Given these, and all potential cases where the EDN file could be assumed to exist, "allowing heavy customization" probably means something like "make the config customizable with with-bindings".
BTW it seems there's a support for plugins but it's undocumented. Is it something internal?:init-ns can be changed via :nrepl {:init-ns the.ns}?
3. happy to add a function that takes a build config and creates a build report for it
4. compile,release,check are functions that are meant to be used directly from the REPL. compile*, release* take a config directly and don't touch shadow-cljs.edn(let [config
(config/load-cljs-edn)
init-ns
(or (get-in config [:nrepl :init-ns])
(get-in config [:repl :init-ns])
'shadow.user)]
...)
3. Awesome!
4. Indeed, and that's exactly what I'm doing. However, order to make sure that nothing breaks, I still have to do exactly what release and similar methods do under the hood: call rt/init, rt/start-all, runtime/set-instance!, runtime/reset-instance!, rt/stop-all in the correct way. And preserving the logging is also nice. It's about 40 lines in total if I preserve the original code as much as possible.rt/start-allapi namespaces, right? OK, let's see.
This is the code for the api/release function:
(defn release
([build]
(release build {}))
([build opts]
(try
(with-runtime
(let [build-config (config/get-build! build)]
(release* build-config opts)))
:done
(catch Exception e
(e/user-friendly-error e)))))
So, I can provide my custom config to the release* function, that's good. But release also calls with-runtime which in turn calls make-runtime, so let's look at its code:
(defn make-runtime []
(let [config (-> (config/load-cljs-edn!)
;; just in case someone gets the idea to put :server-runtime true into their config
(dissoc :server-runtime))]
(log/debug ::runtime-start)
(-> {::started (System/currentTimeMillis)
:config config}
(rt/init (common/get-system-config config))
(rt/start-all)
)))
Notice that cheeky (config/load-cljs-edn!) that spoils the fun.load-cljs-edn!(shadow.cljs.devtools.server/start! the-config-map)release buildmake-runtime doesclojure.core code that has quite a few dynamic vars.
And I always just pass some sort of a context around instead. But I only develop applications - I've never written anything that other developers would use.release build that obviously isn't very useful and a hinderence in the API#?(:cljs
(defsc ErrorBoundary [this {:keys [body-fn]}]
{:shouldComponentUpdate (fn [np ns] true)
:getDerivedStateFromError (fn [error]
{:error true
:cause error})
:componentDidCatch (fn [error info]
(log/error :componentDidCatch (ex-message error)))}
(let [{:keys [error]} (comp/get-state this)
error-msg (div :.ui.error.message
(div :.header "Error Encountered")
(dom/p "Please try again or contact support if error persists."))]
(if error
error-msg
(try
(body-fn)
(catch :default error
(log/error error :render-try-catch)
error-msg))))))
#?(:cljs (def ui-error-boundary (comp/factory ErrorBoundary)))
#?(:clj (defn error-boundary* [[first-arg :as body]]
`(let [real-parent# comp/*parent*]
(ucv.util/ui-error-boundary
{:body-fn (fn [] (comp/with-parent-context real-parent#
~(if (css-k? first-arg)
`(divs (error-boundary ...)(div :.ui.container
(util/error-boundary :.ui.basic.segment :.ui.middle.aligned.celled.list.massive
(map ui-tax-list-item (sort-by :tax/title entities))))
div in react-nativeui/block instead of dom/div / rn/View, makes sense?src/ui-rn/my_project/ui.cljs, src/ui-dom/my_project/ui.cljs#?(:react-native (do-one-thing) :browser (do-that-other-things) :cljs (the-default-thing))(def runtime-config (atom {}))(defn init [] (swap! runtime-config assoc :error-boundary some-fn)):require?(div :.ui.container
(util/error-boundary :.ui.basic.segment :.ui.middle.aligned.celled.list.massive
#(map ui-tax-list-item (sort-by :tax/title entities))))# 😉interface too much in the pastenv you pass arround anyways (like in pathom) things are even easier since you don't need to "interface" ns:source-paths is of course similar to this as it replaces the concrete implementation without defining an actual interface(defn add "Add Two numbers" [a b ] (+ a b)) => nil (defn add [a b ] (+ a b)) => #'io.example/addnil being returned from defn when a docstring is present but the var returned when no docstring?
goog.DEBUG to conditionally run code in dev, but what’s a good way of conditionally requiring something?:preloads are meant for stuff like thatstrip-type-prefixes(ns foo.bar
(:require [dev.library :as d]
[goog :as g))
(defn thing []
(when g/DEBUG
(d/some-function)))
dev.library and the code behind the DEBUG not to be there(when ^boolean g/DEBUG ...):advanced(defn thing []
(when g/DEBUG
(js/console.log "thing debug wasn't removed")
(d/some-function)))cljs.pprint is 96KB!/**
* foo
*/
(function() {
cljs.user.x = function cljs$user$x(a) {
return a;
};
return new cljs.core.Var(
function() {
return cljs.user.x;
},
new cljs.core.Symbol("cljs.user", "x", "cljs.user/x", -156439873, null),
cljs.core.PersistentHashMap.fromArrays(
[
new cljs.core.Keyword(null, "ns", "ns", 441598760),
new cljs.core.Keyword(null, "name", "name", 1843675177),
new cljs.core.Keyword(null, "file", "file", -1269645878),
new cljs.core.Keyword(null, "end-column", "end-column", 1425389514),
new cljs.core.Keyword(null, "source", "source", -433931539),
new cljs.core.Keyword(null, "column", "column", 2078222095),
new cljs.core.Keyword(null, "line", "line", 212345235),
new cljs.core.Keyword(null, "end-line", "end-line", 1837326455),
new cljs.core.Keyword(null, "arglists", "arglists", 1661989754),
new cljs.core.Keyword(null, "doc", "doc", 1913296891),
new cljs.core.Keyword(null, "test", "test", 577538877)
],
[
new cljs.core.Symbol(null, "cljs.user", "cljs.user", 877795071, null),
new cljs.core.Symbol(null, "x", "x", -555367584, null),
"cljs/user.cljs",
8,
"x",
1,
1,
1,
cljs.core.list(
new cljs.core.PersistentVector(
null,
1,
5,
cljs.core.PersistentVector.EMPTY_NODE,
[new cljs.core.Symbol(null, "a", "a", -482876059, null)],
null
)
),
"foo",
cljs.core.truth_(cljs.user.x) ? cljs.user.x.cljs$lang$test : null
]
)
);
})();(defn x "foo" [a] a)(function() {
cljs.user.y = function cljs$user$y(a) {
return a;
};
return new cljs.core.Var(
function() {
return cljs.user.y;
},
new cljs.core.Symbol("cljs.user", "y", "cljs.user/y", 558816894, null),
cljs.core.PersistentHashMap.fromArrays(
[
new cljs.core.Keyword(null, "ns", "ns", 441598760),
new cljs.core.Keyword(null, "name", "name", 1843675177),
new cljs.core.Keyword(null, "file", "file", -1269645878),
new cljs.core.Keyword(null, "end-column", "end-column", 1425389514),
new cljs.core.Keyword(null, "source", "source", -433931539),
new cljs.core.Keyword(null, "column", "column", 2078222095),
new cljs.core.Keyword(null, "line", "line", 212345235),
new cljs.core.Keyword(null, "end-line", "end-line", 1837326455),
new cljs.core.Keyword(null, "arglists", "arglists", 1661989754),
new cljs.core.Keyword(null, "doc", "doc", 1913296891),
new cljs.core.Keyword(null, "test", "test", 577538877)
],
[
new cljs.core.Symbol(null, "cljs.user", "cljs.user", 877795071, null),
new cljs.core.Symbol(null, "y", "y", -117328249, null),
"cljs/user.cljs",
8,
"y",
1,
2,
2,
cljs.core.list(
new cljs.core.PersistentVector(
null,
1,
5,
cljs.core.PersistentVector.EMPTY_NODE,
[new cljs.core.Symbol(null, "a", "a", -482876059, null)],
null
)
),
null,
cljs.core.truth_(cljs.user.y) ? cljs.user.y.cljs$lang$test : null
]
)
);
})();
(defn y [a] a)2.8.61shadow-cljs and it's ability to work with package.json essentially accomplishes the same thing you would get using cljsjs libs with :foreign-libs and :global-exports?
I'm trying to figure out if I can find some way to get intellisense with material-ui and was thought maybe the cljsjs path would get me that, but from what I've looked at it looks like cljsjs is just another way to package js libraries into your clojurescript app. Is that right?(ns your.namespace (:require [cljsjs.material-ui :as mui])) (mui/Grid ...)or something
.d.ts files to generate all the function definitions and stuffnode_modules (let's call it lul). whenever I modify the contents of lul, and then trigger a compile using (shadow.cljs.devtools.api/watch-compile! :app), it seems that it won't "recompile" lul. is there something I can do to fix this? 🙂manifest.edn during development.:output-dir in their config?Cache-Control: private, no-cache at the very leastconnected to server ... on startupshadow-cljs stop$ shadow-cljs node-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.8.61 node: v10.13.0 shadow-cljs - connected to server cljs.user=>
shadow-cljs - config: /home/chris/Projects/its-nancy-land-app/shadow-cljs.edn cli version: 2.8.61 node: v10.16.3 shadow-cljs - server not running<- that's what i get after stopping
shadow-cljs - server version: ... running at do you get? 🙂> shadow-cljs watch frontend server shadow-cljs - config: /home/chris/Projects/CloudRepo/its-nancy-land-app/shadow-cljs.edn cli version: 2.8.61 node: v10.16.3
2.8.45, you didn't actually upgradeproject.clj is probably enoughclass Foo extends Bar {} that compiles to $jscomp.inherits(Foo, Bar); which means that it needs $jscomp (which is the es6 closure runtime polyfill) defined. This runtime is only included with simple optimizations (and up) per https://github.com/google/closure-compiler/issues/1138 but shadow-cljs in development mode is in :none mode thus $jscomp is undefined.$jscomp polyfill into a js file (as this guy suggested https://github.com/google/closure-compiler/issues/1138#issuecomment-347902571 ). Is there any way I can include this in my dev build?:compiler-options {:output-feature-set :es6} or :dev {:compiler-options {:output-feature-set :es6}}$jscomp runtime but it fails with weird errors:dev builds is tricky and buggy.shadow-cljs/builds cache:output-feature-set(prn "foo") executes but i can't see the output - can i configure something to get print output ?shadow-cljs cljs-repl the-build and (prn :foo)(enable-console-print!) after shadow-cljs initialized its loggingshadow-cljs cljs-replset-print-fn! in any way? directly or indirectly via enable-console-print! or some such?(enable-console-print!) in our codebase 😊:before-load-async in your build configuration:devtoolsError: No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object]
at Object.cljs$core$missing_protocol [as missing_protocol] (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:312:3)
at Function.cljs$core$IFn$_invoke$arity$4 (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:854:1)
at Function.cljs$core$IFn$_invoke$arity$4 (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:4509:6)
at Object.cljs$spec$alpha$def_impl [as def_impl] (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/spec/alpha.cljs:312:5)
at /ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/spec/alpha.cljs:1384:1
at global.SHADOW_IMPORT (/ClojureProjects/shadow-cljs-serverless/api/graphql.js:70:44)
spit it to this file". It's because the hiccup is embedded in the hook clj code that means it doesn't "see" the changes until I restart the watcher. I am kind of leaning towards just running different watch processes for each thing now. I think I was more or less here just to see if somebody was going to say, "oh, just set :reload-hooks true in the build config" 🙂.
The interesting thing though is both @isak and myself are really just looking for ways to embed our own little jobs into the watcher process. This does somewhat support my previous idea that there might be a space for a generic watcher application into which jobs can be configured. i.e. "if these files change, pass them through shadow-cljs, if these ones change, pass them through the garden compiler" etc etc. I've had this effect before actually. The delights gain by a solid live reload / watcher process are so great that you want the process to do "all the things" 🙂:build-hook things "leaks". it is never shutdown if you edit the build config file while watch is runningshadow-cljs run dev/setup and (ns dev
(:require
[shadow.cljs.devtools.api :as shadow]))
(defn setup
{:shadow/requires-server true}
[]
(start-your-watcher)
(shadow/watch :your-build)) seems like a better choice?mk-watcher starts a background thread that will never exit?ws is never closed. all associated threads will continue running:start fn is called when the server starts, and :stop is called when it endsserver-moderelease buildsshadow-cljs release your-buildshadow--cljs run example I posted aboveclj -mclj with shadow on the classpath or is there more to it than that?deps.edn you can use: https://github.com/Olical/depot:local/root. I switch between that and normal version when working on Fulcro bugs. It does it under the following conditions (so far, these seem the only way I get it): Build target is :react-native, and I’m using a dependency that has heavy use of CLJC through :local/root in deps.:transit-str
{:depends-on []
:start
(fn []
(fn [data]
(let [out (ByteArrayOutputStream. 4096)
w (transit/writer out :json)]
(try
(transit/write w data)
(.toString out)
(catch Exception e
(log/warn-ex e ::transit-str-failed {:data data})
(throw e))))))
:stop (fn [x])}log/warn-ex stuff(let [update-fn (fn [component f args]
#?(:cljs (.setState component
(fn [prev-state props]
#js {"fulcro$state" (apply f (gobj/get prev-state "fulcro$state") args)}))))]
(defn update-state!
"Update a component's local state. Similar to Clojure(Script)'s swap!
This function affects a managed cljs map maintained in React state. If you want to affect the low-level
js state itself use React's own `.setState` directly on the component."
([component f]
(update-fn component f []))
([component f & args]
(update-fn component f args))))
and I do get a warning about .setState…it’s the warning thta is being passed through:resources 269, :compiled 4, :warnings [{:source-excerpt {:start-idx 452, :before [" (get-in cst (if (sequential? k-or-ks) k-or-ks [k-or-ks])))))" "" "(let [update-fn (fn [component f args]"], :line " #?(:cljs (.setState component", :after [" (fn [prev-state props]" " #js {\"fulcro$state\" (apply f (gobj/get prev-state \"fulcro$state\") args)}))))]" " (defn update-state!" " \"Update a component's local state. Similar
:extra {:warn-type :target, :form (. component setState (fn [prev-state props] #object[cljs.tagged_literals.JSValue 0x7713c25e ":extra is warning data and the :form it warns about is probably something like (fn [prev-state props] #js{:foo ...}):local/root the :infer-externs :auto logic kicks in and starts warnings about stuff.jar those warnings are not triggered:form isn't used for anything anyways(:import [ ErrorCode]) and then use something like (.-EXCEPTION ErrorCode) without a ^js meta marker I get a warning about Cannot infer target type in expression (. ErrorCode -EXCEPTION)…I expected imports to “just work”{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4b38232a2f243c66282721380b796573657d79"}, :content ("[email protected]")}------ WARNING #3 - :protocol-invalid-method ----------------------------------- Resource: instaparse/gll$macros.cljc:51:4 Bad method signature in protocol implementation, CharSequence does not declare method called charAt
[instaparse.core :as insta :refer-macros [defparser]]
The required namespace "instaparse.macros" is not available, it was required by "instaparse/core$macros.cljc". "instaparse/macros.clj" was found on the classpath. Should this be a .cljs file?
:bootstrap build is controlling what is available to use in self-hosted code eval'd in the browser:entries?shadow-cljs discussion. Thank you for the article - I will finish reading it.resources/public/css/main.css, and my HTTP server serves it at /assets/css/main.css. What do I need to set as the values of :watch-dir and :watch-path so that CSS reloading works?:watch-dir "resources/public" :watch-path "/assets"$ shadow-cljs watch app
shadow-cljs - config: /path/to/shadow-cljs.edn cli version: 2.8.61 node: v10.16.3
..... (after a while ) ....
[:app] Compiling ...
[:app] Build completed. (68 files, 1 compiled, 0 warnings, 0.04s)
shutting down ...
Worker shutdown.
Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at nrepl.transport$bencode$fn__5929.invoke(transport.clj:116)
at nrepl.transport.FnTransport.send(transport.clj:41)
at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159)
at nrepl.middleware.print$send_nonstreamed.invoke(print.clj:138)
at nrepl.middleware.print$printing_transport$reify__6306.send(print.clj:174)
at nrepl.middleware.caught$caught_transport$reify__6341.send(caught.clj:58)
at shadow.cljs.devtools.server.nrepl_impl$send.invokeStatic(nrepl_impl.clj:32)
at shadow.cljs.devtools.server.nrepl_impl$send.invoke(nrepl_impl.clj:19)
at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invokeStatic(nrepl_impl.clj:49)
at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invoke(nrepl_impl.clj:45)
at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941$fn__6943.invoke(nrepl_impl.clj:207)
at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941.invoke(nrepl_impl.clj:205)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2860.invoke(ioc_macros.clj:986)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__655.invoke(channels.clj:265)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more:target :node-script and :target :browser. The shadow-cljs watch app command is still running there though.:jvm-opts ["-Xmx1G"] to limit it to 1gig of RAM (either in shadow-cljs.edn or project.clj in case you use lein)shutting down ... Worker shutdown.means the shadow-cljs instance shut down
:log {:level :debug} in shadow-cljs.edn? the exception should be logged and might provide a clue?node process opens a TCP socket that the JVM process frequently connects to and checks if its still theree = nulllein install. So far so good for the last 20minutes.-Xmx512M?dmesg | grep -E -i -B100 'killed process'Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed )npm link to use the <repoDir>/packages/shadow-cljs and shadow-cljs-jar packages in our app
- Rebuild our app and step through the less minified code :crossed_fingers:
Does that sound like it’d work?watch or compile builds? only release builds and those won't contains the client/browser.cljs?watch build on the app end, yea.browser.cljs is compiled as part of your project/js/cljs-runtime/shadow/cljs/devtools/browser.cljs and set a breakpointbrowser.cljs and add it into one of your :source-paths if you want to make modifications.cljs file.js code.js variant of that namespace and a .cljs variant(no domain)::compiler-options {:source-map true}:watch-dir or the http root. lets say public. You have a public/css/foo.css. it will attempt to reload /css/foo.css. you can specify :watch-path "/x" which would make it try to reload /x/css/foo.css:watch-path to the PATH of the .css file it is trying to reload yes<link doesn't already use that path, it won't reload because it will think it is a different file<link rel="stylesheet" href=""> it is never going to reload that CSS<link href="/css/foo.css"/>.(no domain)? I only have the .js files there too<link href="/css/foo.css"/>. that means it will only reload files that have :watch-dir + /css/foo.css, so if :watch-dir "public" then public/css/foo.css{:type :asset-watch, :updates #{"/css/foo.css"}}link path then nothing happens:watch-path "/foo/bar". I think my trouble was caused by missing the leading / on the :watch-path. :man-facepalming:
4. It also needed to have :watch-dir "dist" ’cause we weren’t using the default public folder.TypeError: Cannot read property 'prototype' of undefinedconst { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { OAuthStrategy } = require('@feathersjs/authentication-oauth');
class AzureB2CStrategy extends OAuthStrategy {
constructor(...args) {super(...args);}
authenticate({error}, params) {
super.authenticate(error, params);
}
}
module.exports = AzureB2CStrategy
["./azureb2c.js" :as AzureB2CStrategy]OAuthStrategy might just be nil/undefined?["@feathersjs/authentication-oauth" :as auth] then (def OAuthStrategy (obj/get auth "OAuthStrategy")):compiler-options {:output-feature-set :es7}?:es8 might be fine for node:es6super in constructor.shadow-cljs/builds/<the-id>/dev/out/cljs-runtime/*.js:output-dir? or is it not :node-script?:npm-module its just your :output-dirmodule$...degree9.auth.azureb2c ns:es6 output.shadow-cljs/builds cache:output-feature-set?shadow$provide.module$degree9$auth$azureb2c = function(
global,
process,
require,
module,
exports,
shadow$shims
) {
require("shadow.js.shim.module$$feathersjs$authentication");
var OAuthStrategy = require("shadow.js.shim.module$$feathersjs$authentication_oauth")
.OAuthStrategy;
global = function(args) {
for (
var $jscomp$restParams = [], $jscomp$restIndex = 0;
$jscomp$restIndex < arguments.length;
++$jscomp$restIndex
)
$jscomp$restParams[$jscomp$restIndex - 0] = arguments[$jscomp$restIndex];
return (
OAuthStrategy.apply(
this,
$jscomp.arrayFromIterable($jscomp$restParams)
) || this
);
};
$jscomp.inherits(global, OAuthStrategy);
global.prototype.authenticate = function($jscomp$destructuring$var2, params) {
OAuthStrategy.prototype.authenticate.call(
this,
$jscomp$destructuring$var2.error,
params
);
};
module.exports = global;
};...args, it node supports that natively bump it to whatever language version that is 😛:output-feature-set changeses-next as output-feature-setsuper in my js files failsshadow$provide.module$demo$test = function(global, require, module, exports) {
require("shadow.js.shim.module$$feathersjs$authentication");
({
OAuthStrategy: global
} = require("shadow.js.shim.module$$feathersjs$authentication_oauth"));
class AzureB2CStrategy extends global {
constructor(...args) {
super(...args);
}
authenticate({ error }, params) {
super.authenticate(error, params);
}
}
module.exports = AzureB2CStrategy;
};
//# sourceMappingURL=module$demo$test.js.map
index.html to the target directory where main.js file is generated? Eg.
Reference to main.js without cache busting
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script src="main.js"></script> <--- no cache busting </body> </html>In webpack there is a plugin where you can add hash
main.[hash].js and define a path where your index.html template is located, and it will copy it to the target directorymanifest.edn, you read your input index.html. you str/replace the data or however fancy you want to getoutput-dir?
Then inside the index.html template, we can define text that can be replaced by an actual value later.
For instance any text that starts with $<NAME>.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>$__DOC_TITLE</title> </head> <body> $__SCRIPTS <-- will include all scripts </body> </html>The naming conventation is just an example. Also, on how to get the value needs further thought.
shadow-cljs release app for the first time (in a while at least). Now when I go back to watch I'm getting loads of errors where it seems the JS objects for the CLJS namespaces don't exist. e.g. Cannot set property 'global' of undefined, where global is the first defn in that namespace. I've tried clearing everything in .shadow-cljs, and in the js/out dir, but it's still broken. Any ideas?(:require ["./some.js" :as x])? with some.js being some generated code?goog.provide('proto.example.high_score.Ponycopter'); (lol)(:require [proto.example.high_score.Ponycopter :as lol])release build. I'd suspect that it does.react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:transformClassesWithDexBuilderForDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See
20 actionable tasks: 2 executed, 18 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 31s
error Failed to install the app. Make sure you have the Android development environment set up: . Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 31s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Command.handleAction (C:\Users\thheller\AppData\Roaming\npm\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)
react-native run-android a second time and that workedexport const foo = "foo";. no clue what the protoc generated files look like:closure-defines {goog.DEBUG true}?2.8.64:output-dir "app"<project>/proto next to <proto>/app(def x (js/require "../proto/whatever.js")):advanced compatible and result in a way way smaller build:closure-defines should only be symbol keys but in case you have strings also the merge rules might delete one value if there is a conflict:exclusions in Leiningen, perhaps?)
I’m getting this:
NPM version conflict for "react" in deps.cljs (will use A) A: "16.9.0" from jar:file:/Users/xxxx/.m2/repository/reagent/reagent/0.9.0-rc1/reagent-0.9.0-rc1.jar!/deps.cljs B: "16.8.6" from jar:file:/Users/xxxx/.m2/repository/re-com/re-com/2.6.0/re-com-2.6.0.jar!/deps.cljs
deps.cljs specified different versionsreact (in package,json).
But I if I had conflicts in the transitive dependencies of my :dependencies, might I have to specify (as a top-level dependency) which version I want? And live with the warnings?deps.cljs is kinda dirty anywaysshadow-cljs check app and I am seeing a bunch of places that have the following warning:
ShadowJS expressions are not callable
This could totally be because I’m doing some weird shit with npm/cljsjs transition. what exactly does this warning pertain to, though?(-> (js/$ ".floating-scrollbar") (.floatingScroll "destroy"))
check output. the closure typechecking isn't really meant to be used the way I'm using it(defmacro str->int [s] `(js/parseInt s))
$ clj Clojure 1.10.1 (defmacro str->int [s] `(js/parseInt s)) #'user/str->int
18 | (js/console.log (str->int "1")) -------------------------^------------------------------------------------------ Use of undeclared Var server.macros/s BUILD-WARNING in server/main.cljs at [18:19] Use of undeclared Var server.macros/s
server.macros/s(defmacro str->int [s] `(js/parseInt ~s))
(js/parseInt server.macros/s) since it is just expanding the regular s symbol~s (look up unquote)package.json:
{
"name": "zenroom-example",
"version": "0.0.1",
"private": true,
"devDependencies": {
"shadow-cljs": "2.8.64"
},
"dependencies": {
"core-js": "^3.2.1",
"core-util-is": "^1.0.2",
"create-react-class": "15.6.3",
"react": "16.8.6",
"react-dom": "16.8.6",
"regenerator-runtime": "^0.13.3",
"zenroom": "0.9.5"
}
}
The required JS dependency "core-util-is" is not available, it was required by "node_modules/readable-stream/lib/_stream_readable.js".
Note: this only happens when I change a file and shadow-cljs pushes changes to the browser.npm i core-util-is or npm i --save core-util-is the error remains[zenroom] import in the view(ns zenroom-example.views (:require [re-frame.core :as re-frame] [zenroom] [zenroom-example.subs :as subs]))
lein dev I see this:
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".You probably need to run: npm install readable-stream/writable.js
npm install readable-stream/writable.js npm ERR! Error while executing: npm ERR! /usr/local/bin/git ls-remote -h -t npm ERR! npm ERR! ERROR: Repository not found.
module.exports = Stream;
var EE = require('events').EventEmitter;
var inherits = require('inherits');
inherits(Stream, EE);
Stream.Readable = require('readable-stream/readable.js');
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js". exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info. when runningfailed to load shadow.module.app.append.js TypeError: "module$node_modules$zenroom$index.script is not a function". So this approach is not the right one. I wonder how to run it in a browser at all 🙂(:require [zenroom :default zenroom])
(js/Object.getOwnPropertyNames zenroom) lists all its properties
scriptkeysconfdataprintsuccessverbosityzenroom_execzencode_execerrorinitreset__debuguncaught exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info. might be due to limitations of shadow-cljs?.wasm is just a file. it is normally loaded at runtime via some JS calls.css file or sonode_modules/whatever/foo.wasm to your public/wasm/foo.wasm or so/wasm/foo.wasmrequire("./foo.wasm") or import("./foo.wasm").js filesmodule$demo$foo) so it’s “clumsy” when you need to call this from a native web view in iOS/Android.
Thanks for sharing your thoughts!.js files. those files you can include uberjars like normal. you can run that as part of lein uberjar yes, although I typically recommend doing something like shadow-cljs release app && lein uberjar insteaddeps.edn :local/rootdeps.edn doesn't support.java files that need to be compiled, which lein does but deps.edn doesn'tlein maybe?compiler.clj:881 isn't par-compile-cljs-sources)"Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n"
shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app
[2019-10-14 11:03:20.312 - WARNING] provide conflict for #{minorodata.app.subs} provided by cljs/minorodata/app/subs.cljs and {"/minorodata/app/subs.cljs" #{minorodata.app.subs}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.db} provided by cljs/minorodata/app/db.cljs and {"/minorodata/app/db.cljs" #{minorodata.app.db}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.events} provided by cljs/minorodata/app/events.cljs and {"/minorodata/app/events.cljs" #{minorodata.app.events}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.app.router} provided by cljs/minorodata/app/router.cljs and {"/minorodata/app/router.cljs" #{minorodata.app.router}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.core} provided by cljs/minorodata/core.cljs and {"/minorodata/core.cljs" #{minorodata.core}}
:source-paths configured badly? maybe :source-paths ["src" "src/cljs"]?{:lein {:profile "+cljs"} in the shadow-cljs.ednsrc/cljs folder:source-paths outside :profiles? otherwise I believe it defaults to :source-paths ["src"]?:source-paths []. or :source-paths ["src/clj" "src/cljc"]src[:main] Compiling ... [:main] Build failure: Closure compilation failed with 10 errors --- main/gsv/ui/HighPitchMapController.js:1 Requested module does not have an export "clamp". --- main/gsv/ui/HighPitchMapController.js:2 Requested module does not have an export "Controller". --- main/gsv/ui/HighPitchMapController.js:3 Requested module does not have an export "WebMercatorViewport". --- main/gsv/ui/HighPitchMapController.js:3 Requested module does not have an export "normalizeViewportProps". --- main/gsv/ui/HighPitchMapController.js:4 Requested module does not have an export "LinearInterpolator". --- remaining errors ommitted ...
:source-paths [] fixed the problem )) Thanks 👍import { Controller } from "something" maybe?import { Controller } only works if the "something" was actual ESM codenode_modules code differently it never is actual ESM codeimport X from "something" and then X.Controllerlein dependency rules?import statements.:resolve are you messing with?:resolve for node_modules packages?:js-options {:resolve {"util" {:target :npm
:require "./util"}
"querystring" {:target :npm
:require "query-string"}}}
shadow-cljs installed in the projectnpm install shadow-cljs in your project so that it brings in the node-libs-browser package. which provides browser polyfills for util as well as querystringnode built-in packages that don't run in the browser)shadow-cljs in the project doesn't fix it then you may just have a dependency conflict on the npm side(:require ["jstest" :as jstest]) however none of js/jstest, src/js/jstest or /src/js/jstest with or without a ".js" extension worked. From my reading of the docs I thought it should be prefixed by 'src/js/` as this is the folder the .js file is in within my project. If anyone can tell me what I missed I'd be grateful. Thanks (and thanks @isak for suggesting i post here because I had to re-try several things to write up what I had done so far and then thought to try with no path!)lein dev compilation phase is not erroring out anymore about the dependency, Cursive is still not resolving it. But maybe it can't from where it lives. Yep, I can find my code in the app.js file. Looks good from here.shadow-cljs and ptaoussanis's Sente. Using re-frames lein template to generate a new project with: lein new re-frame re-learn +10x +cider +handler +re-com. Have a minimal app where I want to send a message back and forth between client and server. But i get failed: Error during WebSocket handshake: Unexpected response code: 500 and ERROR [taoensso.sente:1058] - WebSocket error: [object Event] all the time. Have used Sente with lein and figwheel before without any hassle. Anyone got an idea?src/js is exactly the wrong thing to do. I tried explaining the classpath https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath and https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-jssrc/js/jstest.js file then :source-paths needs to include src/js and you include the file via /jstest.jssrc/clj/re_learn/server.clj is created(def dev-handler (-> #'routes
wrap-reload
ring.middleware.keyword-params/wrap-keyword-params
ring.middleware.params/wrap-params
(ring.middleware.defaults/wrap-defaults
ring.middleware.defaults/site-defaults)
))
It looks to me like the ws request is to the correct host and port. lein run -m shadow-sente.server separatelyshadow-cljs watch app ? This seems to be caused by code signing requirement enforced by OSX catalina (root cause seems to be the dynamically loaded https://github.com/gjoseph/BarbaryWatchService). I suspect this might cause issues with figwheel as well.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: dlopen(/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp, 1): no suitable image found. Did find: /private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: code signature in (/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.Has anyone faced the same issue ?
:fs-watch {:hawk false}. It'll use the default JVM watcher thenhawk or the underlying BarbaryWatchService is only used on macOS because the default JVM file watch is kinda slow and has a 2sec delay which bothered people:fs-watch {:watcher :polling}.:fs-watch {:hawk false} didn't work?:polling is basically telling hawk to use the JVM watcher ... which is kinda the same as not using hawk in the first place:fs-watch {:hawk false} didn't work?
Just realised that I had downgraded to shadow-cljs 2.6.0 to test something.
:fs-watch {:hawk false} works with 2.8.64, but not with 2.6.0
:fs-watch {:watcher :polling} works with both versions 🙂:source-paths you are talking about project.clj rather than shadow-cljs.edn. My :source-paths doesn't include src/js, only src/clj and src/cljs, perhaps I missed an instruction or implied good practice there. However I can reference the files using :js-options :resolve and (:require ["foo" :as foo]) (where my JS file is src/js/foo.js). From what you are saying it seems what I've done shouldn't work, or is only working accidentally perhaps.:source-paths:js-options, that is wrong for what you are trying to doshadow-cljs.edn as you indicated, removing js-options and adding a source-paths including ['src/js'] (I think my confusion here was that using the re-frame template doesn't include source-paths). However every variant of the :require statement I tried ("/jstest", "/jstest.js", "jstest", "jstest.js") gets "The required JS dependency "jstest" is not available". The file in question is src/js/jstest.js.:lein true or some form of :lein in shadow-cljs.edn yes?:source-paths in shadow-cljs.edn have no effect whatsoever. lein is in charge of managing them, so you need to adjust it there:source-paths ["src/clj" "src/js" ...]?:source-paths?:source-paths and :dependencies requires a full restart of shadow-cljs(:require ["/jstest.js" :as x]) should do it (with no additional config in :js-options at all)node_modules:hawk?:dependencies or :deps in case you are using deps.ednpretty-print and psuedo-namesjs->clj if you use that:output-wrapper truega global will clash with one of the variables the CLJS outputs creates:output-wrapper is the easy quick fix:compiler-options?core.cljs:111 Uncaught ReferenceError: $APP is not defined
shadow-cljs watch [build-name], I don't see logging from the app like I do when I do a shadow-cljs compile [build-name] && node app.js -- any idea why?node app.js? you don't seem to be doing that for the watch? shadow-cljs does not run node for you.watch? :build-hooks?cider-jack-in-cljs and I get a complaint that I'm not in a Clojure project even though I'm editing a CLJS file in a directory which has the shadow-cljs.edn at parent. Just trying to confirm that one should not be having to jump hoops here and it should "just work".npx shadow-cljs etc. from command-line worksshadow-cljs release prod --source-maps to compile our clojurescript to javascript. We now need to compile the code to make it IE-proof too. The usage of Babel was suggested by a javascript developer here. Is this idiomatic to do in cljs too? If so, how do we include it in the build pipeline?nomodule and type="module" then that is not currently supported:js-options {:babel-present-env {:targets {:ie 8}} is probably all you need:js-options {:babel-preset-config {:targets {:ie "8"}}} and use the sentry stuff from npm then everything will likely work as expected(go (let [response (<! (http/get ""
{:with-credentials? false
:query-params {"since" 135}}))]
(prn (:status response))
(prn (map :login (:body response)))))
i test the code, it output the error
TypeError: Cannot read property 'chan' of undefined
at eval (eval at <anonymous> (), <anonymous>:1:53)
at eval (eval at <anonymous> (), <anonymous>:108:3)
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$react_native$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$react_native$handle_message ()
at eval ()
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
at WebSocket.eval ()
ns properly too?17 | (defn register-componnet [name root] 18 | (.registerComponent ^js app-registry name #(r/reactify-component root)))
app-registry?(:require ["react-native" :as rn]) (rn/AppRegistry.registerComponent name ...):infer-externs^js tag added:infer-externs it really isn't useful anymore IMHO(rn/AppRegistry.registerComponent name ...) just take this examplern is a namespace alias for "react-native"AppRegistry and registerComponent to the externs:compiler-options. So there’s that 😄rn["AppRegistery"](defn gen-key-get [obj key]
(case (config/key-get-mode)
:core `(~'js* "(~{}[~{}])" ~obj ~key)
:goog `(goog.object/get ~obj ~key)))
Another pro of using it though - you can write selector like :a.?b.c instead of its cumbersome equivalent.
Would the issue be remedied if cljs-oops emitted code like x.y instead of x["y"]?(some-> a .-b .-c) seems fine to me but thats subjective I guessx.y! "punch" access.
Why not? Can't it write something like (~'js* "(~{}.~{})" ~obj ~key) when key contains a valid JS identifier?
Sorry, I've never dealt with such macros that emit JS code.(defn get-obj [name] (oget+ ReactNative name))+ variety at all. I don't think externs inference would work here either if the names of keys are truly dynamic.AbstractSingletonProxyFactoryBean with all of the consequences. Sometimes it's much easier and simpler to just get a key with a check that it exists, in a dynamic manner.:advanced and you need to understand what that is doing. you simply cannot mix using x.y in one place and x["y"] in another(defn f1 [k]
(oget+ js/Lib k))
(defn f2 [k]
(case k
:a (.-a js/Lib)
:b (.-b js/Lib)
:c (.-c js/Lib)))
We know what js/Lib is, so we can write f2, easy. But look at how it compares to f1, how much more code there is. And if we want all of the keys to be accessible, we have to keep f2 and js/Lib in sync. Unless there's some option that I'm missing.
Note that replacing (f1 :a) with just (.-a js/Lib) is not possible in the general case. E.g. because it immediately removes the ability to iterate over keys.
> the problem is :advanced and you need to understand what that is doing
Yep, guilty here. I assume that I have some superficial knowledge, but at the same time it completely contradicts what I see - despite all the advanced compilations, I still see my code working with the x["y"] kind of access. To be fair, I just checked all of the instances of oget in one of my projects, and about 90% of them access fields that GCC cannot change (DOM API, external libraries). But the rest 10% access fields that come from NPM libraries. And they still work just fine for some reason! Again - maybe I'm just lucky.
> you simply cannot mix using x.y in one place and x["y"] in another
If x.y is a known extern (either via externs inference or via explicit externs) and if my understanding of the concept of externs is anywhere near correct, GCC will not rename y to anything. In this situation, using x["y"] should be just fine.
When x.y is not a known extern, GCC can rename it to anything under :advanced. And that's exactly where using cljs-oops can bite me, right?
I'm more and more interested in why my usage of NPM libraries doesn't explode...k = 'age', p[key] with a.key but it doesn't replace that a.key with a.a.(.-field lib) where lib comes from NPM. Why do we even need externs here? Let GCC rename field to something else both in CLJS and in JS code. Or is it simply because GCC cannot really tell without the externs that field in CLJS is the same field as in JS?:simple level of optimizations is used. Which is exactly why cljs-oops is able to work at all. OK, I think I understand now, thanks!
And consequently, now I see why using cljs-oops indeed adds something to the set of moving parts. Although I'm still unsure whether it's worth it to dump it at this point or not.:simple in a separate compilation step. thats why we still need externs in the CLJS parts. running everything through advanced doesn't work.aget eithernode-script target? I thought that was a known issue but don't remember any details/src). GCC Advanced? (assuming the CLJS is advanced)cider-jack-in-cljs?cider-jack-in-clj and then start the build, but I had many builds in my projectcider-jack-in-cljs should workshadow-cljs.edn file, CIDER should pick it upnpx create-cljs-project acme-app
2. Add build to shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:builds
{:backend
{:target :node-script
:main
:output-to "target/backend.js"
}}}}
3. Create
(ns ) (defn init [] (prn "init"))4. in CLJS buffer,
M-x cider-jack-in-cljs
5. Select shadow for REPL type. type backend for build ID.
6. In a terminal, run node target/backend.jscider-jack-in-cljs does not find the project/src/main/shadow_test/core.cljs?clj-refactor , comment it out in my .emacs, restart emacs, doesn't work
uncomment clj-refactor in .emacs then start emacs and let it reinstall clj-refactor, now it workscider-jack-in-cljs works in shadow-cljs project iff I have just reinstalled clj-refactor Emacs packagedelete-package and restart without it, doesn't worknode_modules, so no :advancedrequire it goes with commonjsimport/export it is treated as ESM and advancedindex.html and replaces the script paths{"/img/foo.png" "/actual/path/img.hash.png"} or more complex if needednowhaikussrc/api/fn -> api/fn/index.js:target abstraction in shadow-cljs:target :browser responds to browser.clj in that dir:target my.custom/stuff{ "src": "/api", "dest": "/my-api.js" },
{ "src": "/users", "methods": ["POST"], "dest": "/users-api.js" },
{ "src": "/users/(?<id>[^/]*)", "dest": "/users-api.js?id=$id" },
module.exports = function(req) ... or whatever?{
"src": "/api/(.*)",
"dest": "/api/$1"
}
/my-api.js has to be self-contained without require of its own?browser.clj vs node_script.clj or so:flush:modules config:node-script basically just is syntax sugar for :modules {:main {:entries [that.main.ns] :append-js "that.main.ns.main(process.argv)"}}TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
clj->js^js tagging that one method call worksnode_modules/.console.log in shadow-cljs vs upstream ClojureScript (e.g. figwheel) with large and complex nested data structures. Are you aware of any issues regarding that ? I think it has to include vectors to trigger the issue i.e. heavily nested {:key [ { ... } ...]} and not just {:key {... { ... }}. We are working on a reproducible test case but just wanted to get feedback from you before we work more on that.cljs-devtools (just add the dependency) or :devtools {:console-support false}console.log slow:after-load fire for :node-script apps? I get :before-load-async but not :after-load?:before-load-async? otherwise it won't proceed.:dependencies. last time I tried changing how that was handled (and downloaded less) you complained about it not working with the chinese firewall and stuffnode_modules you have installed I guess it is probably fine 🙂(done) directly?:js-options {:resolve {"react-dom" {:target :npm :require "react-dom/profiling"}}} https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolvecp node_modules/basscss/whatever.css public/css/bass.css:repl {:middleware} doesn’t get applied from the global config.edn to every project?.cpcache and .shadow-cljs folders./workspaces/js/main.js instead of /js/workspaces/main.js. Editing index.html solved it.SHADOW import error .shadow-cljs/builds/renderer/dev/out/cljs-runtime/shadow.js.shim.module$react_dnd_html5_backend.js. I'm trying to import the npm package react-dnd-html5-backend version 9.4.0. I'm importing other packages without problemnode-library.import HTML5Backend and that syntax isn't supported for node-library?node:node-library just uses require and lets node resolve it. which seems to fail because of the importbrowser build because some of the other packages required are node specific and aren't supported in the browser. I'll add another build and see if I can find a way to separate out the code into a browser package and a node package.import and stuffrequire directly in the "renderer". so in the browser.$ npm i react-dnd-html5-backend npm WARN
:keep-native-requires true and :keep-as-require #{"the-libs" "that-work"}react-dnd-html5-backend/dist/cjs insteadcjs approaches 👍["react-dnd-html5-backend/dist/cjs" :default HTML5Backend] seems to be working 🎉(js/require "./assets/images/my-image.png") wouldn’t work in a react native project? I’ve checked that the file exists. Getting an error that it “doesn’t exist in the Haste module map”:output-dir "target", for me I would typically need “../assets/images…
... Good call!amperity.admin.ui.srv.authn.logout_BANG_ = (function amperity$admin$ui$srv$authn$logout_BANG_(){
if(cljs.core.truth_(amperity.admin.ui.srv.authn.web_auth)){
return .logout(({"clientID": amperity.admin.ui.srv.env.auth0_client_id, "returnTo": amperity.admin.ui.srv.authn.current_root_uri()}));
} else {
return null;
}
});
offending CLJS code:
(defn logout!
"Log the user out of Auth0."
[]
(when web-auth
(.logout ^js web-auth
#js {:clientID env/auth0-client-id
:returnTo (current-root-uri)})))
.logout(...)when fixes it 😵master. can't remember the ticket number, something related to type-inferenceThe required namespace "grpc.web.GrpcWebClientBase" is not available
src/protobuf dirgrpc-web stuff into a .jar and publish it as a regular libraryadvanced optimized codetypeUrl incorrectly in your own code?externs/app.txt with typeUrl(let [{:keys [typeUrl]} (js->clj ..)])js->clj just for the destructuring is a really bad idea. performance and code wise:advanced:advanced optimizations is really the ultimate goal since it makes your code sooooo much smaller which is good in pretty much all environments:compiler-options {:property-renaming false} will turn off the renaming globally:compiler-options {:optimizations :simple} will be substantially bigger:simplemetro packager also had issues with :simple I believe:property-renaming should only add like 20% or so:none is worse than :simple 😛js->clj:advanced won't be able to identify that you are actually using the propertyexterns/app.txt:advanced can be tough sometimes(:require ["grpc-web" ...])(let [username (r/atom "")] (swap! username "admin"))i eval this, it outputs
TypeError: f.call is not a function
at Object.eval [as cljs$core$ISwap$_swap_BANG_$arity$2] ()
at Function.eval [as cljs$core$IFn$_invoke$arity$2] ()
at Function.eval [as cljs$core$IFn$_invoke$arity$2] ()
at cljs$core$swap_BANG_ ()
at eval (eval at <anonymous> (), <anonymous>:2:29)
at eval (eval at <anonymous> (), <anonymous>:3:3)
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$react_native$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$react_native$handle_message ()
swap! expects a function. You probably wanted to use reset!.(shadow.cljs.devtools.api/stop-worker :main) and then run the watch againnpm install or so while the watch is running?shadow-cljs - config: C:\Users\Ethan\Development\vrtest\shadow-cljs.edn cli version: 2.8.64 node: v10.16.3 shadow-cljs - socket connect failed, server process dead? shadow-cljs - server version: 2.8.64 running at shadow-cljs - nREPL server started on port 49330 shadow-cljs - watching build :frontend [:frontend] Configuring build. [:frontend] Compiling ... [:frontend] Build completed. (134 files, 1 compiled, 0 warnings, 3.18s)
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:builds
{:frontend
{:target :browser
:dev-http {8080 "public"}
:modules {:main {:init-fn vr/init}}}}}
npx shadow-cljs watch frontend(init) Hello World => nil (js/console.log "A") Syntax error compiling at (REPL:1:1). No such namespace: js
:js-provider recently which may become handy for this. basically you set :js-options {:js-provider :external :external-index "foo/index.js"}}foo/index.js with all JS requires used in the buildfoo/index.js with whatever external tool you prefer (so in your case react-native metro, but could be webpack, parcel, etc)["react-native-reanimated"
:default Animated
:refer
[Easing
Easing.inOut
Easing.ease
Transition
Transition.Together
Transition.Change
Transition.Sequence
Transition.Out
Transitioning
Transitioning.View]]Animated.View which is in the default export (Animated). is causing some problems152 | [Animated.View {:style (merge (s [:absolute-fill :bg-ui0])
------------^-------------------------------------------------------------------
Use of undeclared Var buoyancy.entry-point/Animated(def animated-view (.-View Animated)). isn :refer is also kind of problematic:default as it does with :as but the handling of . is already quite bad and even worse in normal CLJS. interop in CLJS is a bit undefinedAnimated.View should just work and I might add a change that enables that.js filerequire results (so all JS dependencies, shadow-cljs doesn't process any of them for rn)goog.string/format isn't making it into the buildUncaught TypeError: ne.format is not a functiongoog.string/format is an alias to goog.string.format ?goog.string.format is an actual "provided name" which you require via (:require [goog.string.format]) but since it isn't an actual namespace we have to use it via (:require [goog.string.format] [goog.string :as gstr])) (gstr/format ...){:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:entries [orgpad.client.core]
:init-fn orgpad.client.core/init}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:main}
:web-worker true}}
:compiler-options {:infer-externs :auto}
:devtools {:after-load orgpad.client.core/mount-root
:watch-dir "resources/public"}}
The code in orgpad.client.core/init:
(let [layout (js/Worker. "/js/compiled/layout.js")]
(.addEventListener layout "message" (fn [e] (js/console.log "Layout message recieved:" e)))
(.postMessage layout "Hello World!"))
The Web Worker code:
(ns orgpad.client.layout.webworker.core)
(js/self.addEventListener
"message"
(fn [^js e]
(js/postMessage (.-data e))))
The runtime error:
Uncaught ReferenceError: Node is not defined
at Object.hickory$core$node_type [as node_type] (core.cljs:37)
at core.cljs:39
at layout.js:2937
at Array.forEach (<anonymous>)
at Object.env.load (layout.js:2933)
at layout.js:2969
to the line (aget js/Node (str type "_NODE"))) where js/Node is not known. It points to one of my dependencies [hickory "0.7.1"], not used in Web Worker at all.:depends-on #{:main} which means all the code from :main will be loaded in the worker:shared module and have :main and :layout depend on that:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}:entries empty for shared which means all code used in both :main and :layout will be moved thereshared.js?shadow-cljs watch test with a config such as
{...
:builds
{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true}}}
run the tests on every rebuild?shadow-cljs compile test building and running the tests, but shadow-cljs watch test only seems to build and rebuild, but not run themshadow-cljs server (or other watch) running elsewhere*out*/*err* bindings, so it'll use the default of the server*out* at all:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"}{:source-paths ["src"]
:dependencies [[reagent "0.8.1"]
[reagent-utils "0.3.3"]
[re-frame "0.10.6"]
[day8.re-frame/http-fx "0.1.6"]
[hickory "0.7.1"]
[binaryage/devtools "0.9.10"]
[bidi "2.1.5"]
[com.taoensso/sente "1.14.0-RC2"]
[venantius/accountant "0.2.4"]
[com.cemerick/url "0.1.1"]]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"}}}}require("core-js/stable");
require("regenerator-runtime/runtime");
var _zenroom = _interopRequireDefault(require("../dist/lib/zenroom.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var C = (0, _zenroom.default)();
Which loads some file via a relative path. It might be the case that this does not work with shadow-cljs?
I had to include the npm packages core-js and regenerator-runtime in the packages.json before I got to this error.
I noticed that shadow-cljs minifies all the npm packages and serves it under for example /js/compiled/cljs-runtime/module$node_modules$zenroom$dist$wrapper.js. So just to be sure I also served the wasm under js/compiled/cljs-runtime/zenroom.wasm, but that does not change anything.
Is this problem related to the wasm not compiling? Or due to the relative path?
I changed the relative path loading to _interopRequireDefault(require("/js/compiled/cljs-runtime/module$node_modules$zenroom$dist$lib$zenroom.js")); but that did not fix hte problem.
Can anybody help me include this package with wasm and requires?
Full source code is at: https://github.com/transducer/zenroom-example:http -> :port is only for the host, but on the device the ws port changes everytime and I don't know how to forward the port with adb. As a result I get an error about ws not able to connect from 192.x.x.x:3449 (desktop) to 192.x.x.x:random-port (device)adb isn't involved in this. The running app will need to connect to the shadow-cljs instance. shadow-cljs is never trying to connect to anything, so there is no port to forward?shadow-cljs watch app --verboseadb receiver tcp:3449 tcp:3449adb but I don't know much about android so should be fineadb for any of this. Just using the wlan in my local network(defproject mininal-cljs "0.0.1" :dependencies [[thheller/shadow-cljs "2.7.8"]])
project.clj only for Cursive purposes or do you actually intent to use :lein true?shadow-cljs pom and then using the generated pom.xml to create the Cursive project:dependencies you just re-run shadow-cljs pomproject.clj you'll need to manually copy the :dependencies so Cursive knows about thempom.xml. you don't lose anything and it much easier to keep updatedshadow-cljs pompom.xml in cursive to create your projectproject.clj at allnew project from existing sources -> pom.xmlmaven plugin in cursivepom.xml changes, which you do by just calling shadow-cljs pom again:shadow or :require :js-provider with AWS Lambda. On the other hand I’d like to minimize “upload time” to lambda but on the other hand I don’t want to make the lambda to do too much work on initialization. I’m a bit tempted to just shove all my deps into the output js-file, which I guess :shadow would do?:require and post-process with ncc or similar tools* ns* maybe. In any case, the change happens between 2.8.52 and 2.8.53. Shall I file an issue? I might not have a super clean repro…clj -m shadow.nrepl-debug 5000 5001Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/nrepl_debug__init.class, shadow/nrepl_debug.clj or shadow/nrepl_debug.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
shadow-cljs run shadow.nrepl-debug 5000 5001 too of course. just used clj as an example$ shadow-cljs run shadow.nrepl-debug 5000 59546 shadow-cljs - config: /Users/pez/Projects/calva/shadow-cljs.edn cli version: 2.8.64 node: v12.8.1 shadow-cljs - connected to server [:server-ready 5000 59546] [:client-accepted #object[java.net.Socket 0x196e2f92 "Socket[addr=/127.0.0.1,port=59714,localport=5000]"]] [:msg :client 36] [:msg :client 23] [:msg :client 90] [:msg :client 72] [:msg :client 72] [:msg :client 87] [:msg :client 160] [:msg :client 72] [:msg :client 87]And in the tab where I start the watcher:
$ npx shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.1 watch :calva-lib :test shadow-cljs - config: /Users/pez/Projects/calva/shadow-cljs.edn cli version: 2.8.64 node: v12.8.1 shadow-cljs - server version: 2.8.64 running at shadow-cljs - nREPL server started on port 59546 shadow-cljs - watching build :calva-lib shadow-cljs - watching build :test [:calva-lib] Configuring build. [:test] Configuring build. [:test] Compiling ... [:calva-lib] Compiling ... [:calva-lib] Build completed. (83 files, 2 compiled, 0 warnings, 3,14s) ========= Running Tests ======================= Testing calva.fmt.editor-test Testing calva.js-utils Testing calva.fmt.formatter-test Testing calva.fmt.util-test Ran 21 tests containing 88 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (78 files, 1 compiled, 0 warnings, 4,10s) [:msg :target 115] [:msg :target 79] [:msg :target 133] [:msg :target 180897] [:msg :target 133] [:msg :target 133] [:msg :target 1953] [:msg :target 88] [:msg :target 79] [:msg :target 180897] [:msg :target 97] [:msg :target 112] [:msg :target 79] [:msg :target 269351] [:msg :target 133] [:msg :target 79]
[:msg :client 129] [:msg :client 237]And this:
[:msg :target 98] [:msg :target 197] [:msg :target 80]
*ns*, I get this:
[:msg :client 129] [:msg :client 101] [:msg :client 130] [:msg :client 131] [:msg :client 104] [:msg :client 118] [:msg :client 132] [:msg :client 104] [:msg :client 240]And this:
[:msg :target 2530] [:msg :target 530] [:msg :target 150] [:msg :target 299] [:msg :target 350] [:msg :target 391] [:msg :target 150] [:msg :target 350] [:msg :target 113] [:msg :target 80]
[:msg :client 129] [:msg :client 130] [:msg :client 131] [:msg :client 132] [:msg :client 240]And this:
[:msg :target 57121] [:msg :target 57121] [:msg :target 57121] [:msg :target 57121] [:msg :target 113] [:msg :target 80]
target/nrepl-debug/*.log.ednclone requests?clone requests are from Calva, though. There are three, right?;; ----------------------------------------
;; -- FROM :client
;; ----------------------------------------
{:op "eval",
:session "8f0aa4a2-fb9e-4419-b032-45736496c675",
:code "nil",
:id "9"}nil? was that for the test?ns-list so much although nothing changed2.8.65. I think your issue should be fixed.bigdec does not exist.
4. Evaluate a cljs/js thing at the CLJS REPL prompt (E-CLJS), this does not work as expected.
5. Evaluate a clj thing at the CLJ REPL prompt (E-CLJS), this does not work as expected: bigdec exists.
6. For good measure I evaluate some clj things at the CLJ REPL prompt (B-CLJ), and they work as expected
I hope I got all this right now…1 in one session and then 2 in the cloned one*1 in the original and see what you get1 I'd be surprised1 but maybe figwheel/piggieback does some magic I'm not aware ofbinding support)build.clj as per the doc (https://github.com/thheller/shadow-cljs/wiki/Custom-builds):
(ns build
(:require [shadow.build :as build]
[shadow.build.targets.browser :as browser]))
(defn custom [{::build/keys [stage mode config] :as state}]
(let [state (browser/process state)]
(println "hello" stage)
state))
I placed it in src/clj since that is in the :source-paths.
My shadow-cljs.edn prod build is as follows:
{:lein true
:nrepl {:port 8777}
:builds {:prod {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:entries [zenroom-example.core]}}}}}
When I do shadow-cljs release prod this custom build step is not called.
How do I include the custom build step?:target controls that? so :target build/custom:build-hooks. they are way easier than custom buildscider-set-repl-type to cljs{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "42312a23262d356f212e283102706c7a6c7477"}, :content ("[email protected]")}cider-connect-cljscider-switch-to-repl-buffer while in .cljs files.
I just noticed that the repl buffer says "clojure" and not "clojurescript". Is that an evidence of something?"WARNING: No Clojure Project was detected"
Still can't switch to repl buffer/evaluate code in source files. What versions of cider and shadow-cljs are you using? @UEQGQ6XH7
Screen Shot 2019-10-21 at 10.17.19 (3).pngacme sample app from shadow-cljs:
npx create-cljs-project acme-appcider-set-repl-type and change the repl to cljs, it works for a while, but then it goes back to clj mode and stops working on cljs files:dependencies [[cider/piggieback "0.4.2"] [cider/cider-nrepl "0.23.0-SNAPSHOT"]]
2.8.64 and see if those problems are still there?2.8.66? I think it should be fixed but I have no clue how to use emacs so I can't test myself2.8.64 and that was working on one project, but on a different project I am getting
CompilerException: java.lang.RuntimeException: Unable to resolve symbol: read+string in this context, compiling:(shadow/cljs/devtools/server/repl_system/clojure.clj:113:32)still works when I manually include 2.8.16 (which was what I was using before iirc) so I not a big issue right now.
org.clojure/clojure {:mvn/version "1.9.0"}, kinda old.process and I had to npm install it, I'm thinking that was the thing you mentioned earlier when I said I had to include js-options to get my build to work. e.g. npm install shadow-cljsfeatures to install [:formatters :hints] to my devtools map:compiler-options {:external-config {:devtools/config ...}} not :devtools:compiler-options {:source-map true}defmodule MyAppWeb.UserController do use MyAppWeb, :controller ...
ns is, so not surens a regular macro in CLJS?ns does is not really possible from the outside. it already is complicated enough as it isnpm install a-thing for clj(s), so we always add :dependencies manuallyshadow-cljs - starting ... Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
lein when you use :lein true or so2.8.66 is the latesstshadow-cljs.edn?node_modules/shadow-cljs/package.json, maybe that is outdated?2.8.67 that includes what the videos showsshadow.remote.runtime.browser or shadow.remote.runtime.node in your build (via :preloads or the REPL)cljs.analyzer API I believe which means shadow-cljs can't intercept anythingclj repl -> piggleback mw (or whatever) -> websocket in browser/node.
2. For diract its clj repl -> dirac mw -> dirac agent -> websocket in chrome devtools -> program being debuggedcljs.repl stuff that might be a lot of workshadow.remote stuff would be relevant for dirac. right now it isn't capable of eval but it will hopefully be soon.js/require or import "as a library" in :require from ns?
- Use (js/require "./../../resources/img.png"):target :node-script in your build:compiler-env statesdirac repl command:
https://github.com/binaryage/dirac/tree/master/examples/figwheel-main#you-can-control-figwheel-main-via-diracdef something(fn [the locals listed as args] (whatever-you-need-to-eval-using locals)):locals is supported cljs state config, why not use it? I have to mess with env anyways, for example to set current nsreturn statements maybe, not sure if this would be a real issuecljs.repl API and doesn't support itcljs.repl is supported. some of it could be but most of it can'tlein with-profiles +cljs repl(require '[shadow.cljs.repl-test :as x]) then (test-repl-anon-fn):repl-actions
[{:type :repl/invoke,
:name "<eval>",
:js "(function (foo){\r\nreturn foo;\r\n})",
:source "(fn [foo] foo)",
:source-map-json
"{\"version\":3,\r\n \"file\":\"<eval>\",\r\n \"sources\":[\"<eval>\"],\r\n \"lineCount\":1,\r\n \"mappings\":\"AAAA,AAAKA;AAAL,AAAUA\",\r\n \"names\":[\"foo\"],\r\n \"sourcesContent\":[\"(fn [foo] foo)\"]}\r\n",
:warnings []}]}in-ns code, but :locals would be better than wrapping it with fn, also need support for source maps somehow{:shadow.cljs.repl/repl-state true,
:current-ns cljs.user,
:repl-sources
[[:shadow.build.classpath/resource "goog/base.js"]
[:shadow.build.classpath/resource "goog/debug/error.js"]
[:shadow.build.classpath/resource "goog/dom/nodetype.js"]
[:shadow.build.classpath/resource "goog/asserts/asserts.js"]
[:shadow.build.classpath/resource "goog/reflect/reflect.js"]
[:shadow.build.classpath/resource "goog/math/long.js"]
[:shadow.build.classpath/resource "goog/math/integer.js"]
[:shadow.build.classpath/resource "goog/string/internal.js"]
[:shadow.build.classpath/resource "goog/string/string.js"]
[:shadow.build.classpath/resource "goog/object/object.js"]
[:shadow.build.classpath/resource "goog/array/array.js"]
[:shadow.build.classpath/resource "goog/structs/structs.js"]
[:shadow.build.classpath/resource "goog/functions/functions.js"]
[:shadow.build.classpath/resource "goog/math/math.js"]
[:shadow.build.classpath/resource "goog/iter/iter.js"]
[:shadow.build.classpath/resource "goog/structs/map.js"]
[:shadow.build.classpath/resource "goog/uri/utils.js"]
[:shadow.build.classpath/resource "goog/uri/uri.js"]
[:shadow.build.classpath/resource "goog/string/stringbuffer.js"]
[:shadow.build.classpath/resource "cljs/core.cljs"]
[:shadow.build.classpath/resource "clojure/walk.cljs"]
[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"]
[:shadow.build.classpath/resource "clojure/string.cljs"]
[:shadow.build.classpath/resource "cljs/spec/alpha.cljs"]
[:shadow.build.classpath/resource "goog/string/stringformat.js"]
[:shadow.build.classpath/resource "cljs/repl.cljs"]
[:shadow.cljs.repl/resource "cljs/user.cljs"]],
:repl-actions
[{:type :repl/invoke,
:name "<eval>",
:js "(function (foo){\r\nreturn foo;\r\n})",
:source "(fn [foo] foo)",
:source-map-json
"{\"version\":3,\r\n \"file\":\"<eval>\",\r\n \"sources\":[\"<eval>\"],\r\n \"lineCount\":1,\r\n \"mappings\":\"AAAA,AAAKA;AAAL,AAAUA\",\r\n \"names\":[\"foo\"],\r\n \"sourcesContent\":[\"(fn [foo] foo)\"]}\r\n",
:warnings []}]}:current-ns. you can just assoc :current-ns 'whatever.sym:source-map-json looks like what I need:locals support in your repl? IMO you should just pass it through to analyzer(defn please-generate-js-for-me [in-this-ns the-cljs-code-as-string])*out*?tap> in a production build?:strip-type-prefixes #{"cljs.core.tap_GT_"}tap> variant that is automatically removed in release builds(tap> something) will just do nothing so thats totally fine without any overhead(tap> {:some thing :foor "bar"}) or so would however still construct that map, and then throw it away which is overhead we don't need/wantnode-repl (without a build) via the Cursive nREPLshadow-cljs server(shadow/node-repl)node target.js separately I'd have to mess with process.stdout and process.stderrprn or console.log for debugging output but tap> instead:module-hash-names changes actual file names. I'm thinking how to handle the same issue with my CSS files.
Another approach would be to add a dummy query parameter so I don't have to rename anything or create some convoluted logic on my web server.
But changing actual file names is more robust and explicit as it's a 1-to-1 match (for practical reasons only, because MD5) to the actual code.
Do you have any thoughts on how it should be handled with CSS? Do you any example source code that deals with this issue?manifest.json which the server reads so it knows about the names:node-test targets on windows only{:e2e
{:autorun true,
:ns-regexp "e2e.*",
:output-to "out/e2e.js",
:target :node-test},
Run yarn e2e yarn run v1.19.1 $ shadow-cljs compile e2e shadow-cljs - config: D:\a\create-cljs-app\create-cljs-app\shadow-cljs.edn cli version: 2.8.67 node: v12.13.0 shadow-cljs - connected to server [:e2e] Compiling ... ========= Running Tests ======================= Testing e2e.core shadow-cljs - socket connect failed, server process dead? [:e2e] Compiling ... ========= Running Tests ======================= Testing e2e.core rm: could not remove file (code EBUSY): test-app/node_modules/clj-kondo/unpacked_bin/clj-kondo.jar rm: could not remove directory (code ENOTEMPTY): test-app/node_modules/clj-kondo/unpacked_bin rm: could not remove directory (code ENOTEMPTY): test-app/node_modules/clj-kondo rm: could not remove directory (code ENOTEMPTY): test-app/node_modules rm: could not remove directory (code ENOTEMPTY): test-app
shadow-cljs start:autorun:autorunshadow-cljs compile e2e && node out/e2e.js or so:autorun (boolean, optional) Run the tests via node when a build completes. This is mostly meant to be used in combination with watch. The node process exit code will not be returned as that would have to forcefully kill the running JVM.
The node process exit code will be set to 0 when successful and 1 on any failures. (The node process exit code will not be returned when using :autorun.)
:autorunautorun 😄compile finishes you can even shutdown shadow-cljs before running the tests. it won't be required for the actual tests:node-test targets via watch, but without autorun? Is it to have some node watcher waiting to rerun the out file?chokidar out/e2e.js -c "not out/e2e.js":autorun if you really need to, I just don't recommend it:autorun-in-watch-only true or so:autorun with compile:autorun for the same target? e.g. shadow-cljs watch test --autorun or somethingshadow-cljs watch test --config-merge "{:autorun true}""test": "shadow-cljs watch test --config-merge \"{:autorun true}\"",
"test:once": "shadow-cljs compile test && node out/test.js",
"e2e": "shadow-cljs compile e2e && node out/e2e.js",
"test" and "test:watch"?test to do a test once:autorun alreadywatch I'd be pretty annoyedhttpurr: http://sprunge.us/dhCr7W — is this something that should be addressed at the library level or an issue with Shadow CLJS?.gitlibsrefactor-nrepl working in a tools.deps project? I'm getting an error on cider startup that says:
WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.0-SNAPSHOT and n/a, respectively.Looking at the jack in command:
[nREPL] Starting server via /usr/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.4 serverAnd I've even got them explicitly listed as dependencies:
refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"}
cider/cider-nrepl {:mvn/version "0.22.4"}
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module 'babel-core'
Require stack:
- /project/.shadow-cljs/babel-worker/babel-worker.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
...
...
code: 'MODULE_NOT_FOUND',
requireStack: [
'/project/.shadow-cljs/babel-worker/babel-worker.js'
]
shadow-cljs watch mainrequire("babel-core")at /Users/baruchberger/work/nursico/.shadow-cljs/babel-worker/babel-worker.js:399:229
at Object.<anonymous> (/Users/baruchberger/work/nursico/.shadow-cljs/babel-worker/babel-worker.js:404:3)shadow-cljs - starting via "clojure" Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. at clojure.lang.RT.load(RT.java:466) at clojure.lang.RT.load(RT.java:428) ...
thheller/shadow-cljs dep in deps.edncider master, does it mean that has to change too?cider auto-inject is not maybe a q for you I know :D)js/:devtools-url in the docsfrontend/ and lein in backend/src/main/clj and src/main/cljssrc/main/my/company/frontend/app.cljs or so with a src/main/my/company/server.clj:source-paths works but IMHO gets annoying as soon as you have code that you want to use on both platformslein new reagent <project name> +shadow-cljs from lein. and it worked pretty well. it run a backend and also compile cljs to javascript with shadow-cljs. Now i include Karma to the project and suprisely it run fine!java -v and verify version > 8
2. run node -v and verify version > 6
3. do <this thing> to make sure your paths are set correctly
4. run npx shadow-cljs init
5. edit shadow-cljs.edn and set :source-paths to values <something>
6. verify configuration by doing <this smart thing>
7. start emacs, open shadow-cljs.edn
8. start the n-repl and connect from cider by running M-x cider-jack-in-cljs
9. everything else…
Looking for something that’s going to stop me before I go to far without having the basics correct.npx create-cljs-project t2 works fine and creates a skeleton directory.
npx shadow-cljs node-repl starts and produces a working (seeming) REPL and a web-page available on .cider-jack-in-cljs and it should work. and node your-script.js or whatever to have the runtime*Messages* [nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server... error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: env: node: No such file or directory
error in process sentinel: Could not start nREPL server: env: node: No such file or directory
➜ ~ which node /Users/dreno200/n/bin/node
➜ ~ node --version v10.17.0
exec-path that's emac's path. you need to add node to the emacs path in the same way you do it for shells(getenv PATH) doesn’t show /Users/dreno200/n/bin, working on finding right zsh file to add it to…(add-to-list 'exec-path "/Users/dreno200/n/bin")setenv to put it in the path and got this now:
[yas] Prepared just-in-time loading of snippets successfully. Loading /Users/dreno200/.emacs.d/.cache/company-statistics-cache.el (source)...done [nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server... error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn cli version: 2.8.67 node: v10.17.0 shadow-cljs - connected to server server already running [2 times] error in process sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn cli version: 2.8.67 node: v10.17.0 shadow-cljs - connected to server server already runningWill need to play with it a bit.
npx shadow-cljs node-repl from CLI, now getting this in *Messages*: error in process sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn cli version: 2.8.67 node: v10.17.0 ===== ERROR ================= Executable 'java' not found on system path. =============================However, I java is in
/usr/bin:
➜ t2 which java /usr/bin/java ➜ t2 java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode) ➜ t2and I have it set in emacs as the first item in the PATH environment variable with
(setenv). Seems to clearly be a path problem though..spacemacs.env. Even though it’s documented to append multiple PATH statements, it seems it was somehow confused. By reducing the statements to one and shortening, I got the right path in there (i.e. one with node and java).
Now when running cider-jack-in-cljs it seems to work by prompting for a REPL type (I chose node), and starting a browser window pointing to .
*Messages*:
[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server... [nREPL] server started on 50825 [nREPL] Establishing direct connection to localhost:50825 ... [nREPL] Direct connection to localhost:50825 established Visit '' in a browser? (y or n) y helm: Error: Trying to run helm within a running helm session Quit [3 times]I’ll try to find a shadow-cljs troubleshooting doc and a place where I can add advice about verifying that
node and java are in the path as reported by (getenv PATH).
Thanks for your help!shadow or shadow-select.dev which I suppose corresponds to whatever is in the shadow-cljs.edn file.npx shadow-cljs watch [build] this choice is asking you which shadow build you want to run"react-native" with "react-native-web"
Here’s how the react native base docs suggest doing it with webpack
https://github.com/GeekyAnts/NativeBase-KitchenSink/tree/web-support#to-create-new-react-app:js-options {:resolve {"react-native" {:target :npm :require "react-native-web"}}}addAlias stuff basically. dunno what the rest of it does though(defun cider-shadow-select-cljs-init-form ()
"Generate the init form for a shadow-cljs select-only REPL.
We have to prompt the user to select a build, that's why this is a command,
not just a string."
(let ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s))")
(options (or cider-shadow-default-options
(completing-read "Select shadow-cljs build: "
(cider--shadow-get-builds)))))
(format form (cider-normalize-cljs-init-options options))))
(defun cider-shadow-cljs-init-form ()
"Generate the init form for a shadow-cljs REPL.
We have to prompt the user to select a build, that's why
this is a command, not just a string."
(let* ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch %s) (shadow/nrepl-select %s))")
(options (or cider-shadow-default-options
(completing-read "Select shadow-cljs build: "
(cider--shadow-get-builds))))
(build (cider-normalize-cljs-init-options options)))
(format form build build)))
shadow-cljs.edn(shadow.cljs.devtools.api/node-repl)browser-replbrowser-repl or node-repl?browser-repl and node-repl to be reservedlein repllein uberjar and java -cp that-uberjar.jar clojure.main -rshadow-cljs.edn?npx shadow-cljs server won't start without a configbrowser-repl is basically just a hardcoded :target :browser build:node-repl and the node-repl using the leading :. But, yeah, it is inviting confusion to name your build like that. 😃(shadow.cljs.devtools.api/watch :browser-repl) since that'll just complain about build not foundshadow-cljs browser-repl is running externally(...api/nrepl-select :browser-repl)shadow.remote is basically a new REPL protocolyarn start after a while I get this warning: WARNING in /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Performance/Systrace.js 1:2947-2954 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/react-native/react-native-implementation.js @ /Users/pez/Projects/rn-rf-shadow/app/index.js @ multi /usr/local/lib/node_modules/expo-cli/node_modules/react-dev-utils/webpackHotDevClient.js /Users/pez/Projects/rn-rf-shadow/app/index.jsAnd after that a lot of errors like this one
ERROR in /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components/AnimatedImage.js Module not found: Error: Can't resolve '../../../Image/Image' in '/Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components' @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components/AnimatedImage.js 1:23-54 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/Animated.js @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableRow.js @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/react-native/react-native-implementation.js @ /Users/pez/Projects/rn-rf-shadow/app/index.js @ multi /usr/local/lib/node_modules/expo-cli/node_modules/react-dev-utils/webpackHotDevClient.js /Users/pez/Projects/rn-rf-shadow/app/index.jsAny idea where I should look for the source of these? Things still work, but it is hard to develop with all those errors…
shadow-cljs start from command line works without warnings, but when I try to run (shadow.cljs.devtools.server/start!) from my test runner I get a ton of warnings about “<xxx> provide conflict for <yyy>”
I made sure I’m running it from the same dir, not sure where would be a difference. Thanks for help.start, they just end up in the .shadow-cljs/*.log filesstart starts in the background, you'd get them with shadow-cljs server too:lein option in shadow-cljs.edn, it works from command-line, but seems to be ignored when running as a library:source-paths and :dependencies or :lein in shadow-cljs.edn don't matter at allshadow-cljs itself to start things?shadow.cljs.devtools.api/watch etc. seems to be reading shadow-cljs.edn as-is, without looking at :lein or doing anything about it:lein, it is already running?watch will read the config file yes, it must get the :builds entriesserver/start!:lein correct?:lein even have at that point?start! in:source-paths and :dependencies apply from however you started YOUR JVMlein or boot or clj. basically anything where shadow-cljs wasn't in full control of the JVM:locals and querying current ns:preloads but also in the release build? I have some (extend-type ...) calls that I want to be available everywhere in the browser environment without having to require the ns. Or would the preferred way just be to require the ns in each of the "init" namespaces that Shadow knows about?:entries will be preserved in your config:modules {:main {:entries [that.side-effect-ns ]}}npx shadow-cljs compile npm.figwheel to shadow-cljs. My macro (defmacro assert ...) lives in kunagi_base/utils.cljc. I have no :require-macros or anything like that in my code. With figwheel this worked fine. Shadow-cljs gives me this error: Use of undeclared Var kunagi-base.utils/assert. Any suggestions? Thank you!ReferenceError: shadow$provide is not defined:npm-module defaults to :runtime :browser but you are using it in node:builds {:npm {:target :npm-module :runtime :node :output-dir "node_modules/shadow-cljs"}}#?(:cljs (:require-macros [kunagi-base.utils])) is likely missing in that nsrelease, I get Uncaught TypeError: Cannot read property 'g' of undefined. Wasn't there a way to create release output with hints to the real (not shortened) names?shadow-cljs release app --pseudo-names will make the names slightly more recoginizable but you probably want to turn on https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs if you haven't alreadypom.xml method. Should Cursive be able to resolve references to node modules (or javascript references such as (.log js/console "...")), or is it expected that it doesn’t?TypeError: module$node_modules$react$index.createContext is not a function
at eval (routes.cljs:10)
at eval (routes.cljs:10)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:827)
at Object.env.evalLoad (main.js:2174)
at main.js:2412TypeError: _react.default.createContext is not a function, TypeError: React.forwardRef is not a function, TypeError: module$node_modules$react$index.memo is not a function and similar.cljs-runtime.npm-module variant. The docs say that I can use the default shadow-cljs.edn via the ‘covenience mode’. https://shadow-cljs.github.io/docs/UsersGuide.html#_convenience_mode .:entries [hi] to the build config?:builds :app:npm-module? :node-library and :node-script are much better generallyglobal.shadow$provide = {} before running the require in nodenode-script, but node-library may be appropriate. I have no intention of actually creating an npm module.node-library.node-library has a better structure and better "output".cljc files, is there a way to tell shadow to ignore that dep during cljs compilation? I don’t intend to use it from cljs, but do want it on my classpath at the clj REPL..cljc files in that dep are causing cljs compilation to fail in some way.:require a filedeps.edn :local/root or gitlibs and use a test target?{:deps {:aliases [...]}}:local/root or gitlibs was the important bit 😛:mvn/version style dependency*-test.cljs files that the warnings point to… 🤔deftest macros with an undeclared var warning, for example:
(deftest entity-ids->lookup-set Use of undeclared Var my-app.client-test/entity-ids->lookup-set
datahike[io.replikativ/datahike "0.2.0"] https://github.com/replikativ/datahike.cljc files in that repo fails with all kinds of exceptions, because the cljs support isn’t there yet. My thought was those files were somehow tripping up my own compilation. But:
>it doesn’t matter whats on the classpath UNLESS you actually :require a file.cljc:browser-test build target. I can open the resulting build up in the browser and see All tests passed.
b) I add the datahike dependency to my deps.edn file, and then rerun my :browser-test build, which results in a bunch of warnings, but I just found that there is one interesting one:
Resource: datascript/core.cljc:586:36 Use of undeclared Var cljs.reader/register-tag-parser!c) Correct. None of my code has made any attempt to require or use datahike yet. So, there seems to be some conflict between datascript and datahike that I think is likely unrelated to shadow (apologies for the noise here). The key thing missing from my understanding of shadow was this: >it doesn’t matter whats on the classpath UNLESS you actually
:require a fileshadow-cljs clj-repl and ( "cljs/reader.cljs")#object[java.net.URL 0x72d5daf9 "jar:file:/Users/calvin/.m2/repository/org/clojure/clojurescript/1.10.520/clojurescript-1.10.520.jar!/cljs/reader.cljs"]Seems to exist and load just fine. Likely a dep conflict like you mentioned. I’ll keep investigating. Thanks for your help 🙏
/private something you did?datahike dependency causes all of these conflicts to disappear…this /private folder doesn’t exist in the datahike jar file either 🤔( "private/js/out/cljs/reader.js") which dependency include thathasch lib is the culprit for that specific conflict:
( "private/js/out/cljs/reader.js") #object[java.net.URL 0x698e4e6c "jar:file:/Users/calvin/.m2/repository/io/replikativ/hasch/0.3.5/hasch-0.3.5.jar!/private/js/out/cljs/reader.js"]
dist/ when run npm run build? I understand this might not be shadowcljs’ job, but wonder how people do it.npm run build?"scripts": {
"start": "shadow-cljs watch app",
"build": "shadow-cljs release app"
},
"build": "shadow-cljs release app && cp dist somewhere" or so?public/js/, then do you commit this folder in VCS, say git? I do want to commit the release version, but then I will always see it changing in git status when I dev.shadow-cljs release app && cp dist somewhere would work, but then before I copy, I assume I need to clean up the dev files? But shadow-cljs doesn’t have a clean command, so…"start": "shadow-cljs watch app",
"build": "yarn clean && shadow-cljs release app",
"clean": "rimraf public/js"
dist/, I don't want to include the non-prod js files that get produced there:dev-http config{:builds
{:app
{:asset-path "/js",
:devtools {:http-port 3000, :http-root "public"},
:modules {:main {:init-fn app.core/main}},
:output-dir "public/js",
:target :browser},
:e2e
{:ns-regexp "e2e.*",
:output-to "out/e2e.js",
:target :node-test},
:test
{:ns-regexp "app.*-spec$",
:output-to "out/test.js",
:target :node-test}},
:dependencies [[reagent "0.8.1"]],
:nrepl {:port 3333},
:source-paths ["src" "e2e"]} you do {:builds
{:app
{:asset-path "/js",
:modules {:main {:init-fn app.core/main}},
:output-dir "public/js",
:target :browser},
:e2e
{:ns-regexp "e2e.*",
:output-to "out/e2e.js",
:target :node-test},
:test
{:ns-regexp "app.*-spec$",
:output-to "out/test.js",
:target :node-test}},
:dependencies [[reagent "0.8.1"]],
:nrepl {:port 3333},
:dev-http {3000 "public"}
:source-paths ["src" "e2e"]}, and incorrect indentation 😛:dev-http instead of nested :devtools {:http...} is the newer format:http-resource-root and :preloads fit into this new pattern?:dev-http {3000 "classpath:public"}:preloads stay were they are since they are actually build related:moduleszprint-clj https://github.com/kkinnear/zprintclj -m zprint.main <deps.edn examples in the zprint readmeshadow-cljs run zprint.main would be the same<deps.edn would be a problemshadow-cljs run lets me run a given function in a clj namespace I haverun zprint.main without any modification to shadow-cljs.edn besides adding the dependency, and it seems to print the formatted output
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1c777d7175775c4e595831442d5f2a"}, :content ("[email protected]")}dev:http change is now published)shadow-cljs start in the background to speed up further commands.shadow-cljs server yes// node_modules/lib/foo.js
shadow$provide["module$node_modules$lib$foo"] = function(module, global, process, exports, require) {
var foo = 1;
exports.hello = function() { return foo; };
}
// node_modules/lib/bar.js
shadow$provide["module$node_modules$lib$bar"] = function(module, global, process, exports, require) {
var foo = require("module$node_modules$lib$foo");
foo.hello();
}
// node_modules/lib/foo.js
shadow$provide["module$node_modules$lib$foo"] = function(module, global, process, exports, require) {
exports.hello = function() { return 1; };
exports.world = function() { return 2; };
}
@angular/core. It is published in ES2015 among other formats. It is also annotated for GCC via tsickle (a TS wrapper to annotate TS output for GCC).node_modules/@angular/core/esm5/* to src/main/angular or so(:require ["/angular/index.js" :as angular])var PlatformRef = /** @class */ (function () {class? 😛:advanced parts need externs for the code not part of the advanced compilation (ie. npm code)module, esm, or es0215import { aThing } from "some-common-js" can't work in strict modeimport foo from "some-common-js" + foo.aThingrequire('something.css') and defaulting resolving .wasm extensions by defaultrequirerequire.asset("something.css") or so would have been bettermodule.exports (and variants thereof) and collects the exported names as externs(:require ["some-npm-lib" :refer (foo bar)])(defn wrap-baz [x] (.baz x))
baz is safe to rename or requires externs:browser builds:js-provider :external not too long agoimport()await:shadow-js to just :js 😛try {
moduleFn.call(
module,
goog.global,
shadow.js.jsRequire,
module,
module["exports"]
);
} catch (e) {
console.warn("shadow-cljs - failed to load", name);
throw e;
}main.cljs:105 Uncaught TypeError: nosco.routes.start_routing_BANG_ is not a function
at Object.nosco$views$main$start [as start] (main.cljs:105)
at admin:14
nosco$views$main$start @ main.cljs:105
(anonymous) @ admin:14main.js:2176 failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function
at Object.shadow$provide.module$node_modules$react_redux$lib$components$Context (Context.js:11)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_redux$lib$components$Provider (Provider.js:15)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_redux$lib$index (index.js:8)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_beautiful_dnd$dist$react_beautiful_dnd_cjs (react-beautiful-dnd.cjs.js:14)
at Object.shadow.js.jsRequire (js.js:63)
at Object.shadow.js.require (js.js:97)
at eval (/js/cljs-runtime/nosco.views.page_list.js:8)failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function that seems to be the actual errorconnected to server on startupshadow$provide["module$node_modules$react_redux$lib$components$Context"] = function(global,require,module,exports) {
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.ReactReduxContext = void 0;
var _react = _interopRequireDefault(require("react"));
var ReactReduxContext = _react["default"].createContext(null);
exports.ReactReduxContext = ReactReduxContext;
var _default = ReactReduxContext;
exports["default"] = _default;
};shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn cli version: 2.8.55 node: v12.9.0 shadow-cljs - starting via "clojure" INFO [main] org.xnio - XNIO version 3.7.3.Final INFO [main] org.xnio.nio - XNIO NIO Implementation Version 3.7.3.Final INFO [main] org.jboss.threads - JBoss Threads version 2.3.2.Final shadow-cljs - server version: 2.8.53 running at shadow-cljs - nREPL server started on port 61137
[:main] Build completed. (852 files, 851 compiled, 0 warnings, 31,49s)
.shadow-cljs/builds/main/dev/. I have the original files around.lein clean practice before compiling ... just because ... I'll consider this project failed.[:main] Build completed. (851 files, 1 compiled, 0 warnings, 5,92s)Cache-Control: private, no-cache, no-store:modules or just one?.js file that is loaded I presume?{:target :browser
:output-dir "dev-resources/public/main/js"
:asset-path "/js"
:modules {:main {:entries [nosco.views.main]}}
:compiler-options {:infer-externs :auto}
:devtools {:watch-dir "dev-resources/public/main"
:loader-mode :eval}
:release {:output-dir "gamma-dist/main/js"
:closure-defines {nosco.routes/WORMHOLE-EXIT true
nosco.controllers/ALL-FEATURE-FLAGS-ENABLED false}
:module-hash-names true
:cache-blockers #{gamma.translate}
:build-hooks [(gamma.translate/write-pot-file "translations/gamma.pot")
(gamma.translate/clear-messages)]
:build-options {:manifest-name "manifest.json"}}}dev-resources/public/main/js/main.js filenosco.views.main?(start)?<script src="/js/main.js"></script>
<script>
nosco.views.main.start(document.getElementById("main"))
</script>(defn ^:export start [el]
(reset! EL el)
(add-watch nosco.controllers/app-state :main-render
(fn [_ _ _ s]
(js/console.log "new state is " s)
(let [{:keys [user siteConfiguration]} s]
(when (and user siteConfiguration)
(js/console.log "initial render")
(react-dom/render
(hx/f [Main])
el)))))
(routes/start-routing!))start call for a second?nosco.views.page_list do?(ns nosco.views.page-list (:require [hx.react :as hx :refer [defnc]] [hx.hooks :refer [useState useContext]] [nosco.ui.table :as table] [nosco.ui.components :as components] [cljs-bean.core :refer [bean ->clj ->js]] ["react-beautiful-dnd" :refer [DragDropContext Droppable Draggable]])) (def initial-items (mapv #(hash-map :order % :id (str "oid-" %) :title (str "Item " %)) (range 10)))
SHADOW_ENV.evalLoad("module$node_modules$React$index.js"SHADOW_ENV.evalLoad("module$node_modules$react$index.js"(:require ["React" ...] somewhere in your code or is that caused by some library?nosco.controllers seems to be it ["React" :as React] -- in all other files, there is ["react" :as React]force compile help?.shadow-cljs/builds/main? Is that the "root" cache?"react" onlydate-fns/parseIso (wrong) vs date-fns/parseISO (correct) was breaking. The funny thing is that: (:require ["date-fns/parseIso" :as parseIso]) was returning something (an empty js object), which then broke downstreams consumers.:build-hooks
[(shadow.html/copy-file
"out/demo-browser/index.src.html"
"out/demo-browser/public/index.html")]
<script src="/js/base.js" defer></script> with <script src="/js/base.<hash>.js" defer></script>shadow.html directly in shadow-cljs.edn?--verbose{:type :shadow.html/source-does-not-exist, :source "public/js/index.src.html", :shadow.build.log/level :info}(:require ["bezier-js" :as bezier])
(bezier/Bezier. x1 y1 x2 y2 x3 y3)The object is from this library: https://pomax.github.io/bezierjs/#constructor. I am getting this error:
TypeError: module$node_modules$bezier_js$index.Bezier is not a constructor
at orgpad$client$util$geom_link$create_quadratic_bezier_from_control_point (orgpad/client/util/geom_link.cljs:39:9)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js), <anonymous>:1:73)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:16)
at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:838:44)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:145:108)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:836:46)
at shadow$cljs$devtools$client$browser$handle_message (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:921:37)
at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:294:151)
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:273:90)
(.quadraticFromPoints bezier ...)
new in this situation?(js/console.log bezier) to see what the exported object isbezier as the constructor but it’s hard to know for sure(bezier. x1 y1 x2 y2 x3 y3)var Bezier = require('bezier-js')The required JS dependency "moment" is not available, it was required by "node_modules/pikaday/pikaday.js".However, the GitHub library page says "No dependencies (but plays well with Moment.js)". Why does shadow think it needs it?
You probably need to run: npm install moment
:js-options {:resolve {"moment" false}} in your build configThe required namespace "shadow.remote.runtime.browser" is not available, it was required by "xxxxx/main.cljs".shadow.remote.runtime.cljs.browsershadow-cljs - server version: 2.8.52. so you are still an old version. need to update deps.edn when using thatError from :frontend java.io.IOException: Stream closed{:tag :err :msg "No available JS runtimes!"} currently before kicking:ConjureUp):ConjureUp) i get disconnected immediatelynpx shadow-cljs node-repl with what I think is some super basic config {:builds
{:demo
{:target :node-script
:modules {:main {:init-fn conjure-demo.main/init}}}}
:prepl {:demo 36751}}
It starts up okay but I get the no runtimes error. If you think I'm just configuring / starting it wrong I'll go dig through docs now. If you think this looks okay then maaaaybe something is wrong?node-repl. that isn't related to :demo in any way:prepl {:node-repl 36751}watch demo or something too.[:repl-unknown {:type :repl/session-start, :id "67bcbfa5-55...$ nc localhost 12345
(js/console.log "foo")
{:tag :ret :ns cljs.user :form "(js/console.log \"foo\")" :ms 1 :val nil}:val is coming back as data, it needs to be a string.pr-str it in the eval environment but then you need to turn it into a string to make sure the prepl data is parseable in ANY environment.
Then the prepl client can decide to keep treating the response as just a string or it can try to parse it in whatever way it deems correct.:val as a string (output of Throwable->map I think?) then set :exception to true on the top level of the message.:exception flag.fs = require('fs');(ns (:require ["fs" :as fs]))react-bootstrap. when building with the :browser target, the build fails because react-bootstrap has the dependency @restart/hooks, which we dont find since we arent traversing child node_modules directories.
what is the correct way to handle this? do i install @restart/hooks in the parent node_modules directory? if so, are upgrades of sub dependencies like @restart/hooks expected to be handled manually?@restart/hooks in the same package.json where you installed react-bootstrap<script>s and use the created global object), I have never had any problems with it.
The thing is, BokehJS relies on another library called FlatBush and requires it like this:
- TS: import FlatBush = require("flatbush")
- Distributed JS: var FlatBush = require("flatbush")
- Compiled JS: var FlatBush = __webpack_require__(/*! flatbush */ "./node_modules/flatbush/index.js");
- Compiled JS in CDN: var FlatBush = require(394)
On the other hand, FlatBush uses:
- Source JS: export default class Flatbush
- Distributed JS: a bunch of boilerplate that tries to use module.exports, define, and just global
- Compiled JS: __webpack_require__.d(__webpack_exports__, "default", function() { return Flatbush; });
- Distributed JS in BokehJS CDN: same boilerplate as in just distributed JS.
Because of this difference, it's easy to use BokehJS as a CDN library but not that easy when you want to have it in your build. Namely, it results in TypeError: FlatBush is not a constructor because __webpack_require__(/*! flatbush */ "./node_modules/flatbush/index.js") returns the whole module, which is an object with a field default.
We spent a few hours on this. Apparently, one must use a Babel plugin called add-module-exports in such situations, but it also proves to be not an easy task for all sorts of reasons.
Finally, I decided to give it a go in shadow-cljs, expecting to come up with a few new questions.
And it... just worked? Heh. Awesome, thank you!
BTW would it work in vanilla CLJS, without shadow-cljs?Evaluating file: nodemap2.cljs
symbol re-frame2.items.nodemap2 already provided by [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], conflict with [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]
{:provide re-frame2.items.nodemap2, :conflict [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], :resource-id [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]}
ExceptionInfo: symbol re-frame2.items.nodemap2 already provided by [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], conflict with [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]
shadow.build.data/add-provide (data.clj:91)<script> tags will work with vanilla CLJS yes?:npm-deps tries to but is basically never worksgenerate-extern/the webclient always seem to more or less do the trick, but ive encountered a new one that seems like it should be straightforward, but is failing spectacularly. whats strange to me is that its failing at b.createReactClass. reagent/react was obviously working just fine prior to adding the new library (which is ES6, no less!), so its throwing me off that it seems like that would be any problem. for some detail:
;; imports look like:
(ns some.ns
(:require ,,,
["gsap/TextPlugin" :refer [TextPlugin]] ;; these are coming from npm/node_modules
["gsap" :refer [gsap]]))
;; auto-generated externs look like:
var gsap = {
// ... long, seemingly correct list
}
;; node_modules/gsap/dist/gsap.js module looks like:
// ...
exports.default = gsap;
exports.gsap = gsap;
Object.defineProperty(exports, '__esModule', { value: true });
let me know if anything pops out.:infer-externsnode_modules code at allb is nil where b is some munged name, and then when i click into the error, the line that triggers the error (at least says firefox) is a call to b.createReactClass:infer-externs outputshadow-cljs release app --pseudo-names:all there are ~245 of them (as you warn in the manual 😂), but let me get that instead:all:infer-externs :auto:
------ WARNING #1 - :infer-warning ---------------------------------------------
File: /Users/nolan/dev/nuid/site/src/nuid/site/routes.cljs:59:16
--------------------------------------------------------------------------------
56 | js/location.search
57 | js/location.hash)]
58 | (js/ga "send" "pageview" #js {"page" p}))
59 | (route! (.-token event))))
----------------------^---------------------------------------------------------
Cannot infer target type in expression (. event -token)
--------------------------------------------------------------------------------
60 | (.setEnabled true)))
61 |
--------------------------------------------------------------------------------
which i suppose is relatively straightforward, but whats interesting is that that code has been the same for a long time and hasnt caused release issues in the pastevent looks to be from goog.History or so. which means no externs are needed, but the compiler can't tellshadow-cljs release app --pseudo-names will likely help morefunction $reagent$impl$template$vec_to_elem$$ is the top-level function that failsTypeError: "$JSCompiler_temp$jscomp$1970_JSCompiler_temp$jscomp$2730_JSCompiler_temp_const$jscomp$1971_c$jscomp$inline_1109_comp$jscomp$12_f$jscomp$inline_2750_jsprops$jscomp$inline_1100_n$jscomp$186_props$jscomp$inline_1098_tag$jscomp$18_temp__5737__auto__$jscomp$inline_1105$$ is undefined"is what im seeing
undefined errors always point to something being undefined BEFOREgsap is doing. its pretty hsyterical how different the package size is with and without pseudo-names:externs and :infer-externs:
:compiler-options {:externs ["externs/isotope.ext.js"
"externs/gsap.ext.js"
"externs/gsap.textplugin.ext.js"
"externs/gsap.easepack.ext.js"]
:infer-externs :auto}
:auto. it'll just confuse you more than actually help.:infer-externs :auto and work through themtoken error you can fix by adding (.-token ^goog event) or (.-token ^js event)release warns about the first lib (`isotope`) that i think will get rid of the need for that first manual extern entry. but doesnt seem to find any problems with the rest. let me see what the error looks like now:infer-externs output is way, way cleaner. its awesome to start getting a better understanding of how to act on this#js { ,,, } in there.shadow-cljs release app --debug which will give you pseudo-names + source maps#js { } w.r.t. compilation and hinting? or does that play a role:infer-externs will warn you about thoseshadow-cljs server instance running if you call shadow-cljs release repeatedlyshadow-cljs slack are just innumerableratom, which is actually super helpful because that limits the space of where things could be going wrong pretty significantly. the bummer is that the trace doesnt even touch any of my files:
TypeError: "<that monster name> is undefined"
$reagent$impl$template$vec_to_elem$$ component.cljs:338
$reagent$impl$template$as_element$$ template.cljs:409
$reagent$impl$template$make_element$$/</< template.cljs:483
$cljs$core$IKVReduce$_kv_reduce$arity$3$ core.cljs:5649
$cljs$core$_kv_reduce$$ core.cljs:700
$cljs$core$reduce_kv$$ core.cljs:2562
$reagent$impl$template$make_element$$ template.cljs:481
$reagent$impl$template$native_element$$ template.cljs:359
$reagent$impl$template$vec_to_elem$$ template.cljs:385
$reagent$impl$template$as_element$$ template.cljs:409
$reagent$impl$component$wrap_render$$ component.cljs:104
$reagent$impl$component$static_fns$$</</< component.cljs:128
$reagent$ratom$deref_capture$$ ratom.cljs:37
$reagent$ratom$run_in_reaction$$ ratom.cljs:504
$reagent$impl$component$static_fns$$< component.cljs:143
React (12) ...
[undefined ...]? so not a regular [:div ...]?[<thing> ,,,] anywhere, but i do make pretty heavy use of fragments, which could be easily changed0.8.1"create-react-class": "^15.6.3", "react": "^16.10.2", "react-dom": "^16.10.2"[undefined ,,,] comment got me thinking[something {undefined "foo"} ...]?RESOLVED!(when ^boolean js/goog.DEBUG ,,,) and well…:closure-defines
{"shadow.cljs.devtools.client.env.ssl" true}
This configuration works perfectly for me. I’m doing this because whilst I have an SSL section in my shadow-cljs.edn (my dev-http at https://<hostname>:3000 works), my REPL/devtools connection was using ws://<hostname>:9630 rather than wss://<hostname>:9630. I’m reverse port forwarding onto the real host. Any chance that someone could point out the error in my config? I tried reading a bunch of places in the shadow-cljs source, but wasn’t sure how to pull off this behaviour in particular.
https://gist.github.com/tekacs/95e2e78f806bc72c9695504426c930a4
Intended behaviour:
- Bind to localhost:3000 over SSL for my dev-http
- Bind to localhost:9630 over SSL for my main server
- Visit https://<hostname>:443 for my dev-http server (due to ssh -R '*:443:localhost:3000 <hostname>`
- Have the client use wss://<hostname>:9630 for devtools connections (due to another -R to that SSH):devtools {:devtools-url ""}, see https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-supportssh could be used for https proxying:node-test target?node out/test.js) it will run the tests and exit immediately, leaving no running process for the repl to useshadow-cljs node-repl (require 'your.test-ns) (cljs.test/run-tests 'your.test-ns):node-test is meant to run all tests and then exit the processnode-repl, but you had to run the process manuallynode-repl(require 'your.test-ns) (cljs.test/run-tests 'your.test-ns) right?:node-test the tests run ONCE and then exit(require 'your.test-ns) (cljs.test/run-tests 'your.test-ns)
- have tooling support in vscode
the node-script way:
- jack in
- select node-script target
- select node-script target repl
- run node the-output.js and leave running
- have tooling support in vscodenode the-output.jsnode-repl and run the tests separately (if you just want completion and stuff):node-test is only meant to be supplemental to an actual other build that does stuff{:builds
{:test-dev
{:main async-interop.interop-tests/main
:output-to "out/test-dev.js"
:target :node-script}
:test
{:ns-regexp "async-interop.*-tests$"
:output-to "out/test.js"
:target :node-test}}
:dependencies [[org.clojure/core.async "0.4.500"]]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src/main" "src/test"]}
and this namespace with tests
(ns async-interop.interop-tests (:require [async-interop.interop :refer [p->c]] [async-interop.interop :refer-macros [<p!]] [cljs.test :refer-macros [deftest is]])) (deftest interop (is true)) (defn main [])I jack in, select
test-dev to build, select the test-dev repl connectionCalva: run all tests command{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "97fcf6fafefcd7c5d2d3bacfa6d4a1"}, :content ("[email protected]")}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f19a909c989ab1a3b4b5dca9c0b2c7"}, :content ("[email protected]")}test-dev is running{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d3b8b2bebab893819697fe8be290e5"}, :content ("[email protected]")}(deftest some-test ...) is callable as (some-test)cljs.test. I think it is implemented in a needlessly complex way which makes it really annoying to use$ yarn list shadow-cljs yarn list v1.17.3 warning Filtering by arguments is deprecated. Please use the pattern option instead. └─
{:builds
{:test-dev
{:main async-interop.interop-tests/main
:output-to "out/test-dev.js"
:target :node-script}
:test
{:ns-regexp "async-interop.*-tests$"
:output-to "out/test.js"
:target :node-test}}
:dependencies [[org.clojure/core.async "0.4.500"]]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src/main" "src/test"]}
shadow-cljs - config: d:\sandbox\async-interop\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - socket connect failed, server process dead? shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.69 running at shadow-cljs - nREPL server started on port 3333 shadow-cljs - watching build :test-dev
(ns foo.bar) is first eval'd at the REPLrequire itselfnode-repl from this windowauto-run but stay connected to my app-build. So I start both my app build and my test build at jack-in and then connect to the app build. auto-run keeps watching the files and reruns the tests when the files change.shadow.cljs.devtools.api/nrepl-select on browser-repl or node-repl? This is meant only for a named build?:browser-repl and :node-repl yesshadow-cljs server browser-repl ?shadow-cljs server(shadow.cljs.devtools.api/browser-repl)This kind of CLJS REPL is very helpful for cases when you are already watching one or more shadow builds in shadow either after having launched the server in a terminal or from within Cider. This patch also refactors option normalization out of figwheel-main so that it can be reused by every other function.
/usr/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT server and then running (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch <build>) (shadow/nrepl-select <build>))browser-repl, it doesn't watch and select, just shadow/browser-replbrowse-repl is basically watch+select in onebrowser-repl repeatedly it'll just select:browser-repl the above startup command doesn't work. So I understood that you had to not do watch and nrepl-select for the built in repls but just call shadow.cljs.devtools.api/special-repl insteadnpx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT clj-repl (shadow.cljs.devtools.api/watch :browser-repl) Execution error (ExceptionInfo) at shadow.cljs.devtools.config/get-build! (config.clj:153). no bulid with id: :browser-repl
watch the "special" buildsnrepl-select the "special" builds?nrepl-select it again yes(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :browser-repl) (shadow/nrepl-select :browser-repl))(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/browser-repl)):cljs/quit which will drop the session back to CLJnrepl-select :browser-repl to get back to it(shadow.cljs.devtools.api/nrepl-select :browser-repl) -> [:no-worker :browser-repl](do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/browser-repl)) first?#shadow/env "NREPL_PORT" however it's failing because it's gettting a string and expecting a number.shadow-cljs/nrepl.port to get the actual portinit fn that is called on startup<script>your.app.init({db: "some-url"});</script><script>var MY_CONFIG = {url: "some-url"};</script> and :init-fn and it accessing js/MY_CONFIGindex-test.html and index-dev.html:push-state/index is ignored completelytarget:browser but not on target:node-library
i'm curious to understand why 🤔:browser it will actually process all JS and gather externs while processing:node-library it doesn't process and JS and lets node provide itval{:infer-externs :auto} as default would be good enough to warn the developper):target node-script buildimport createAuth0Client from "@auth0/auth0-spa-js";(require '["@auth0/auth0-spa-js" :default createAuth0Client]) results in createAuth0Client being nil:default here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports:as or :refershadow-cljs server still gives me shadow-cljs - server version: 2.8.67 running at instead of expected 2.8.69/usr/local/bin/shadow-cljs it tries to require code from node_modules first:as did it:target :node-script standard out seems to be set to the node process, but I'd like it to go to the repl if possible(println "hello") I'd like "hello" to show up in the repl 🙂node-repl (not the build repl):target :node-library with only ^:export to denote exports?(shadow/repl-runtime-select ...) to switch between them, but what if I want to keep a repl open to each runtime at the same time, instead of switching?(shadow/nrepl-select :the-build {:runtime-id ...}):reql/quit
(shadow/repl-runtime-select :browser-extension
(:runtime-id (first (shadow/repl-runtimes :browser-extension))))
(shadow/repl :browser-extension)
:runtime-id to nrepl-select, so I'll try that.:runtime-id to the nreplnrepl-selectperformRefresh or renderbefore-load/`after-load` fns can be given to help with this?def and defns are exported by default, I don't think I can rely on that heuristic to ensure only the React components in a particular file are used elsewhere.
I'm thinking right now if I could annotate an ns with some metadata, and get fed that in my after-load hook, then I could rely on the programmer to reasonably discern if a ns is safe to just refresh and add the meta themselves(ns ^:react/refresh my-app.components ,,,)
a, b and c where a requires b requires c:
a -> b -> c
then if I change c, only b is reloaded.c -> b - a then I think things would work correctly. I don't know how heinous that would be in large apps 😬:npm-module + webpack?(def ^:export QuestionnairePage
(r/reactify-component
(fn [a]
(println "questionnaire page is" a)
[:div "questionnaire page"])))
and in js
const { QuestionnairePage } = window.pages.dashboard.questionnaire
and i can use the component like this
<QuestionnairePage a="b" c={style} />
.clj file with a macro in it under src/asciidocs/core.clj, and then I have src/asciidocs/app.cljs file which declares (:require-macros [asciidocs.core :as core]). When I try to use the macro the shadow-cljs complains:
6 | (println (core/load-asciidoc "resources/docs/cv.asc")) ------------------^------------------------------------------------------------- No such namespace: asciidocs.core, could not locate asciidocs/core.cljs, asciidocs/core.cljc, or JavaScript source providing "asciidocs.core" --------------------------------------------------------------------------------I am not sure why this doesn't work. I thought I was supposed to have my cljs macros in a clj file like this.
#?(:clj blocks? I don’t want to compile the required NS into CLJS just to get rid of an error, as it’s not otherwise used in this file.#?(:cljs [clojure.string :as pc]) to get around it, or create a dummy NS to include for this purpose.:clj blocks but then fix it in :cljs block?.cljc 😉:clj blocks. it is just trying to read and for that is must resolve the ::pc/input aliasdefmutations for both frontend and backend to the same file for fun and profit.::pc/input resolves to in those cases:node-test script?shadow-cljs node-repl (require '[your.test-ns :as x]) (x/that-test).catch and am looking into the error now:node-script output could take additional command line args toonode the-output.js --only some.test/foo or so. if someone is interested in working on thatdep-b and dep-c namespace where core depends on dep-b, and dep-b depends on dep-c.
if I change the greeting in dep-c to be "Bonjour!", it won't pick up the change on hot reload until the next renderreact-hmr.core has the example usage(when goog/DEBUG ...react-refresh require though 😉alter-var-root / global JS shenanigansReact.render instead (and blow away the state)after-load hookantd directlyperformReactRefresh is run, it then goes through the React tree from the root and re-renders all of the components marked as dirty.
if the hooks “signature” has changed since the last refresh, it will re-mount the component instead of re-rendering.:compiler-options {:external-config {:your/key ...}}shadow-cljs release your-buildshadow-cljs release, it overwrites the same main.js as shadow-cljs watch - is that expected?:compiler-options {:external-config {:your/key ...}}:release {:output-dir "somewhere/else"} would change itrm -rf public/js && shadow-cljs release app && copy-public-js-to-server(get-in @cljs.env/*compiler* [:options :external-config :logging])release builds don't share any cache with the watch/compile builds so they usually don't interfere:lein option outside of the top level? context is that im trying to use lein with shadow and specify a different lein profile for :dev and :release within a buildlein with-profiles +release run -m shadow.cljs.devtools.cli release appshadow-cljs release app (just with the extra profile):dev/after-load make it dirty yourselfregister! call somewhere already(def set-my-component-signature! (create-signature)) (def my-component ...) (set-my-component-signature! my-component "hooks signature goes here") (register! my-component "my-app.core/my-component")
identity? like regular react or does react-refresh have different rulres?(register! my-component "my-app.core/my-component" (fn [new-component] (set! my-compoent new-component)) maybe(defn actual-component* ...) and (defn component [...] (actual-compoent* ...))react-refresh-runtime/register a new functionshadow-cljs startshadow-cljs start followed by jacking in, nrepl and server information is never shown
$ yarn shadow-cljs start yarn run v1.17.3 $ D:\work\learn-re-frame-course-files\cheffy\node_modules\.bin\shadow-cljs start shadow-cljs - config: D:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - server starting ..................................... ready! Done in 10.14s.
> Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.4 watch :app < shadow-cljs - config: d:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - connected to server shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (691 files, 690 compiled, 0 warnings, 46.46s)
shadow-cljs start at all, which shows full server information> Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.4 watch :app < shadow-cljs - config: d:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.69 running at shadow-cljs - nREPL server started on port 3333 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (691 files, 1 compiled, 0 warnings, 9.60s)
shadow-cljs watch figures out that the server is running?start runs the server in the background and exits. the output is still logged but to a logfile in the .shadow-cljs dirshadow-cljs server will start in the forground and not exitwatch will use a running server if there is one, otherwise it'll become the server.shadow-cljs/server.stdout.log (and .stderr.log) files^:dev-reload with shadow-cljs, so far so good, but I randomly get the following error whenever I update my app. (It happens with material-ui, so not sure it is something on reagent/shadow-cljs or material-ui) component.cljs:338 Uncaught TypeError: Cannot read property 'call' of undefined
at new transparency.components.drawer.drawer_react (component.cljs:338)
at constructClassInstance (react-dom.development.js:14240)
at updateClassComponent (react-dom.development.js:18351)
at beginWork$1 (react-dom.development.js:20109)
at HTMLUnknownElement.callCallback (react-dom.development.js:363)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:412)
at invokeGuardedCallback (react-dom.development.js:467)
at beginWork$$1 (react-dom.development.js:25731)
at performUnitOfWork (react-dom.development.js:24639)
at workLoopSync (react-dom.development.js:24615)
transparency.components.app_bar.app_bar_react @ component.cljs:338
constructClassInstance @ react-dom.development.js:14240
updateClassComponent @ react-dom.development.js:18351
beginWork$1 @ react-dom.development.js:20109
callCallback @ react-dom.development.js:363
invokeGuardedCallbackImpl @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:467
beginWork$$1 @ react-dom.development.js:25731
performUnitOfWork @ react-dom.development.js:24639
workLoopSync @ react-dom.development.js:24615
performSyncWorkOnRoot @ react-dom.development.js:24183
eval @ react-dom.development.js:12239
exports.unstable_runWithPriority @ scheduler.development.js:816
runWithPriority$2 @ react-dom.development.js:12189
flushSyncCallbackQueueImpl @ react-dom.development.js:12234
flushSyncCallbackQueue @ react-dom.development.js:12222
scheduleWork @ react-dom.development.js:23602
updateContainerAtExpirationTime @ react-dom.development.js:26946
updateContainer @ react-dom.development.js:27076
legacyRenderSubtreeIntoContainer @ react-dom.development.js:27680
render @ react-dom.development.js:27757
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:43
eval @ dom.cljs:38
eval @ core.cljs:77
transparency$core$mount_app @ core.cljs:21
eval @ VM47974:1
shadow$cljs$devtools$client$browser$global_eval @ browser.cljs:233
eval @ browser.cljs:236
shadow$cljs$devtools$client$env$repl_call @ env.cljs:106
shadow$cljs$devtools$client$browser$repl_invoke @ browser.cljs:236
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:288
eval @ env.cljs:185
shadow$cljs$devtools$client$env$process_next_BANG_ @ env.cljs:173
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:186
eval @ browser.cljs:368component.cljs:338 Uncaught TypeError: Cannot read property 'call' of undefined
at new transparency.components.drawer.drawer_react (component.cljs:338)(something 1 2 3) when something is nil(defn create-class
"Creates JS class based on provided Clojure map.
Map keys should use `React.Component` method names (),
and can be provided in snake-case or camelCase.
Constructor function is defined using key `:getInitialState`.
React built-in static methods or properties are automatically defined as statics."
[body]
{:pre [(map? body)]}
(let [body (cljsify body)
methods (map-to-js (apply dissoc body :displayName :getInitialState :constructor
:render :reagentRender
built-in-static-method-names))
static-methods (map-to-js (select-keys body built-in-static-method-names))
display-name (:displayName body)
get-initial-state (:getInitialState body)
construct (:constructor body)
cmp (fn [props context updater]
(this-as this
(.call react/Component this props context updater) <<<<------------------------ THIS LINE
(when construct
(construct this props))
(when get-initial-state
(set! (.-state this) (get-initial-state this)))
this))]at new transparency.components.drawer.drawer_react (component.cljs:338)[react :as react] as ["react" :as react]at new transparency.components.drawer.drawer_react (component.cljs:338) is called from reagenttransparency.components.drawer.drawer_react this part is what I'm asking abouttransparency.components.drawer.drawer_react is(defn drawer-react
"The main components of the drawer. Refactor this tab to provides the tabs as
argument."
[{:keys [classes tabsPublic]}]
(let [tabs-public tabsPublic
tabs [[tabs-public (or @(subscribe [::drawer-displayed-sublists]) #{})]]]
[:> mui-drawer
{:open true
:variant :persistent
:class (cs (.-drawerPaper classes))
:ModalProps #js {:onBackdropClick #(dispatch [:close-drawer])}
:PaperProps #js {:class (cs (gobj/get classes "drawerPaperPaperProps"))}}
[:div {:style {:width drawer-width}}
[:div {:class (.-toolbarIcon classes)}
[:> mui-icon-button {:onClick #(dispatch [:toggle-drawer])}
[:> ic-chevron-left {:style {:color "white"}}]]]
[list-divider classes]
[:> mui-list {:style {:padding-top 0}}
(into [:div] tabs)]]]))
js/React in some way?react/Component is undefined?module$node_modules$react$...react/Component should be accessing?transparency$core$mount_app from the REPL?(defn ^:dev/after-load start [] (rf/clear-subscription-cache!) (mount-app))
shadow$cljs$devtools$client$env$repl_call @ env.cljs:106 shadow$cljs$devtools$client$browser$repl_invoke @ browser.cljs:236 shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:288
ReferenceError: $jscomp is not defined with google closure compiler?lein new re-frame foo +10x +re-frisk +handler and then run a lein with-profile prod uberjar I get this error:
[:app] Build completed. (95 files, 46 compiled, 0 warnings, 29.20s) Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method, or the namespace has not been AOT-compiled.any ideas?
:uberjar target in project.clj as is, i.e.:
:uberjar {:source-paths ["env/prod/clj"]
:dependencies [[day8.re-frame/tracing-stubs "0.5.3"]]
:omit-source true
:main foo.server
:aot [foo.server]
:uberjar-name "foo.jar"
:prep-tasks ["compile" ["prod"]]}
lein prod would populate that path? even if I run lein prod (which runs -m shadow.cljs.devtools.cli release app), then env/prod/clj remains empty.lein clean. So right after the "compile" :prep-task finished, it cleans its results, and then, naturally, the class cannot be found. Thanks for taking the time to take a look!(and #_(contains? compiled resource-id):always-load bit there? is that something I can annotate an ns with?and must remaincompiled checknpm sources won't have the :from-jar flag(str/starts-with? (str ns) "module$node_modules")msg data the handle-build-complete fn receives you should find everything you could possibly needregister function with a stable ID and a component. when you call register with a new component (not === to the last one), it marks it as dirty in the react refresh runtime and tells the react reconciler to re-render it or re-mount itc isn’t a component, then the components that use it to implement some behavior aren’t reloadeduseState hook data (and others)React.render again you lose all state and re-mount everything<A> <B /> <---- uses `moduleC.foo` </A>when moduleC gets reloaded, but the module that contains components A and B are not reloaded, then B will not be refreshed
moduleC.foo?core ns as :dev/always(start) after the (react-refresh/reload)?:dev/always might not be enough. that’s why I’m experimenting if I can reload all dependent namespacesReact.render=== on the component type fails then that is an easy fixregister with a type and ID for each component you want to refresh, each time you perform a refreshbrowser target, cant figure it out
------ WARNING #4 - ----------------------------------------------------------- Resource: node_modules/buffer/index.js:2 constant module$node_modules$buffer$index assigned a value more than once. Original definition at externs.shadow.js:3 --------------------------------------------------------------------------------
calva-lib. I have tried some older versions of VS Code, but it is the same. Also some older versions of shadow-cljs, but same… I need some tips on how I can track this down. Totally horrible to be back in compile->restart land.:node-library so the hot-reload doesn't work for exported vars?:node-library?var something = require(".../calva-lib.js")something will be the {whatever: some-function)something:npm-module?:npm-module basically tries to expose the CLJS namespaces to JS:node-library lets you collaps namespaces down to one single object:node-library should be preferred in almost all cases (output is more efficient/compact):npm-module.:npm-module is the way but it has other issues that makes it more complicated to work with:node-library. Will stay with it. Hopefully grow it a bit faster so that you start liking Calva more. 😃cider-jack-in-clj&cljsshadow-cljs.edn to match this call: (shadow.cljs.devtools.api/watch :app {:autobuild false}) when running shadow-cljs watch app?:autobuild false in various places in shadow-cljs.edn but haven't been able to figure it outModule not provided: shadow.js.shim.module$lodash. That file, shadow.js.shim.module$lodash.js is in my cljs-runtime dir.(:require ["./some.js" :as x]) and in that JS const x = require("lodash");?import X from "lodash"goog is not defined. Do you know anything about this? I imagine getting to the bottom would require in-depth knowledge in either jest or closure or both.:node-library code isn't loaded properly then it may do some kind of processing that breaks the already brittle output 😛require function. The other testing framework I tried, mocha, doesn’t have the same problem. But, its also interesting that jest seems to work fine with every other node library. I wonder if its related to closure’s heavy use of globals.:node-library target?:advancedIllegal UTF8 string in constant pool in class file jdk/nashorn/internal/runtime/linker/Bootstrapjava -version?openjdk version "13" 2019-09-17 OpenJDK Runtime Environment AdoptOpenJDK (build 13+33) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
lein or something work?lein with what command?lein repl maybe?jdk-13.0.1+9 release. maybe that fixes it? or just try the regular 13, not 13.0.1?(js/console.log "dsad") is not working from nRepl beacuse it says there's no js namespaceshadow.user> (shadow/repl :test-dev) To quit, type: :cljs/quit [:selected :test-dev] cljs.user>
npm install the-thing?(require '["the-thing" :as x]):target :browser?shadow-cljs cljs-repl the-build?(require '["@material/core" :as x]) or whatever the package for that is nowadaysrequire I just told you?require I told you?["@material-ui/core" :as x :refer [Button]](js/console.log "mui" x)shadow-cljs release your-build[:div {:on-click (fn [e] ...)}] but [:div {:on-click [::some-event! 1 2 3]](defc dummy1
{:init-state {:num 0}
::inc!
(fn [env e]
(sac/swap-state! env update :num inc))}
[props {:keys [num] :as state}]
[]
(<< [:div
[:button {:on-click [::inc!]} "click me: " num]]))
(defc dummy2
{:init-state {:num 0}}
[props {:keys [num] :as state}]
[::inc!
(fn [env e]
(sac/swap-state! env update :num inc))]
(<< [:div
[:button {:on-click [::inc!]} "click me: " num]]))[props state] is "magic" for hooks. you can think of it as a special let if that helps (defc dummy2
{:init-state {:num 0}}
[props {:keys [num] :as state}]
(let [::inc!
(fn [env e]
(sac/swap-state! env update :num inc))]
(<< [:div
[:button {:on-click [::inc!]} "click me: " num]])))(defnc my-refreshed-component
[props]
(let [[count set-count] (react/useState 0)
[name set-name] (react/useState "React Refresh")]
;; kept it's state!
($ react/Fragment
($ :div {:style {:background "pink"}}
($ :div (b/greet name))
($ :div ($ :button {:onClick #(set-count inc)} "+ " count))
($ :div ($ :input {:type "text"
:value name
:onChange #(set-name (.. % -target -value))})))
($ :br)
($ z/component {:name "child in another file"})
($ :br)
($ z/memo-component {:name "memoized child in another file"}))))
(defc my-refreshed-component [props]
[[count set-count] (react/useState 0)
[name set-name] (react/useState "React Refresh")
::inc! #(set-count inc)
::set-name! #(set-name (.. % -target -value))]
(<< [:div {:style {:background "pink"}}
[:div (b/greet name)]
[:div [:button {:on-click [::inc!]} "+ " count]]
[:div [:input {:type "text"
:value name
:on-change [::set-name!]}]]]
[:br]
[z/component {:name "child in another file"}]
[:br]
[z/memo-component {:name "memoized child in another file"}])):on-click (fn [e] ...)identical?(fn [e] ...) all over the placelet macro for certain purposes(defc dummy3 [props] [a (subscribe [:bar]) b (subscribe [:x a])] (<< [:div b]))
(defc dummy4 [{:keys [id] :as props}]
[{:keys [text]}
(-> (js/fetch (str "/some/" id))
(.then #(.json %))
(.then js->clj))]
[:div text])[all, the, deps] args you need to construct(def ^:export foo {...}) (defexported foo {...}:optimizations :simplecompile and doesn't need ^:exportfactui, but thats unmaintained last i checked40.9 KB todomvc build looks promising 🙂 no more chunky react-dom nonsense 😛(deftype ComponentConfig [component-name ...]) so it is constructed as (def x (ComponentConfig. "some.ns/foo-bar" ...))`(def ~(with-meta the-sym {:export true}) ...)(js/console.log ...) them like normalimport()import() creeping into libraries though. that seems like a horrible idea:modules can be quite tedious so I definitely see the appeal:modules. I assume it would rely on something shadow-cljs specific…shadow.build/stage. Is there additional support for other things like shadow.build/mode to control whether or not the hook activates in dev mode or release mode?react-beautiful-dnd and cry in my coffee.:prepend on a build hook, the compiler seems to ignore it and compile the js with the previous value of :prepend. So if it’s unset, nothing is prepended. If it’s some value, it’ll be that value. Is this use case explicitly unsupported by build hooks?:prepend? likely just in the wrong place(assoc-in build-state [:shadow.build/config :modules :main :prepend] licenses):configure and :compile-prepare:configure stage will already configure the modulesrelease(assoc-in build-state [:shadow.build.modules/modules :main :prepend] licenses):prepend-js would be a bit more complicated but :prepend should work like thatupdate-in, just so it doesn't overwrite if something is already there:shadow.build.closure/modules?:shadow.build.closure/modules is a copy of :shadow.build.modules/modules after optimizations. since that can adjust things:build-modules(assoc-in build-state [:build-modules 0 :prepend] licenses):shadow.build.modules/config with similar looking stuff 😄:module-id(assoc-in build-state [:build-modules 0 :prepend] licenses) and it still doesn’t work. I ran (keys build-state) and I can’t find any :build-modules in the list. Could it be that my version is too old? I’m on 2.8.66, and when i checked the recent commits, there was nothing that jumped out at me that signaled that i needed to update.:configure:compile-prepare:shadow.build.modules/config should have worked?:shadow.build.modules/config not :shadow.build.modules/modules:build-modules works in :compile-prepare. Will try it out in :shadow.build.modules/config now:build-modules is created (no longer a map):build-modules and creates :shadow.build.closure/modules (including some of the GCC compiler data) otherwise the same:flush then takes either of those keys to flush the output but :prepend must be set before so it doesn't mess with the source maps:optimize-prepare:shadow.build.modules/config works when i do it in :configure:node-library that I’d like to play with in a REPL, but I’m unsure how to load itshadow-cljs node-repl is good enough(require 'myapp.backend.parser) It says it can’t find it{:type clojure.lang.ExceptionInfo
:message "The required namespace \"myapp.backend.parser\" is not available, it was required by \"cljs/user.cljs\"."
:data {:tag :shadow.build.resolve/missing-ns,
:source-paths ["src/main"] and src/main/myapp/backend/parser.cljs:source-paths)Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
2.8.69(:require ["foo" :as foo])) I’m getting a spec error trying to load it into a repl:
Syntax error macroexpanding clojure.core/ns at (src/workspaces/app/demo_ws.cljs:1:1).
-- Syntax error -------------------
(... (:require
[com.fulcrologic.fulcro.components :as fp]
[nubank.workspaces.core :as ws]
[nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
[com.fulcrologic.fulcro.mutations :as fm]
[com.fulcrologic.fulcro.dom :as dom]
["reakit" :as rk]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:clojure.core.specs.alpha/ns-form:
(clojure.spec.alpha/cat
:ns-name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:attr-map
(clojure.spec.alpha/? clojure.core/map?)
:ns-clauses
:clojure.core.specs.alpha/ns-clauses)
-------------------------
Detected 1 error
(js/alert "foo")js namespace then you are in a CLJ REPLimport Storage from 'react-native-storage';in cljs, i use [“react-native-storage” :default Storage], but the browser output
shadow-cljs - failed to load module$node_modules$react_native_storage$lib$storage_cjs shadow.js.jsRequire @ js.js:74 shadow.js.require @ js.js:100 eval @ /js/compiled/cljs-runtime/core.js:6 goog.globalEval @ app.js:836 env.evalLoad @ app.js:2216 (anonymous) @ app.js:2901
(ns core
(:require [reagent.core :as r]
[starter.browser]
[utils.login]
["react-native-storage" :default Storage]
[pages.dashboard.questionnaire]))
(defn ^:export init
"auto init"
[]
(let []
(prn "thit is cljs init" ))
)
regeneratorRuntime is not defined is the actual error(shadow/repl :app) to enter in to the CLJS repl):
(use 'getfluentspanish.dom :reload)
Error in phase :compilation
Only [lib.ns :only (names)] and optionally `:rename {from to}` specs supported in :use / :use-macros; offending spec: [getfluentspanish.dom] at line 1 cljs/user.cljs
*ns* doesn't work either(require '[the.ns :as x] :reload) should workuse is generally not used in CLJSrequire should be working though. most people just use the hot-reload though(require '[getfluentspanish.dom :as dom] :reload)nil in the repl afterdom/new-function --> nillein shadow watch app, refresh the browser tab and restart the repllein shadow watch appapp?(shadow/repl :app)getfluentspanish.dom/new-function directly in the REPL[thheller/shadow-cljs "2.8.39" :scope "provided"]main.js:2218 failed to load devcards.system.js ReferenceError: React is not defined
at eval (system.cljs:321)
at eval (system.cljs:321)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2216)
at main.js:2413
env.evalLoad @ main.js:2218
(anonymous) @ main.js:2413
main.js:2218 failed to load devcards.core.js ReferenceError: React is not defined
at eval (core.cljs:117)
at eval (core.cljs:117)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2216)
at main.js:2418
(define-react-class DevcardsRoot (componentDidMount [this] (add-watch app-state :renderer-watch (fn [_ _ _ _] (.forceUpdate this)))) (render [this] (main-template app-state)))
cljsjs.react. that will create the React globalshadow-cljsjs? I saw some references to it in https://github.com/bhauman/devcards/issues/156 but I couldn't figure out how I should use itReact global, because it was always there when using cljsjs.reactcljsjs.react require somewheresystem.cljs:334 Uncaught ReferenceError: ReactDOM is not defined
at Object.devcards$system$renderer [as renderer] (system.cljs:334)
at eval (system.cljs:458)
cljsjs.react.dom[cljsjs.react-dom] and that failed, so that's it(shadow/repl :your-build) and that switches you to CLJS;; (require '[figwheel.main.api :as fig]) (fig/start "app")
(require '[shadow.cljs.devtools.server :as server]) (require '[shadow.cljs.devtools.cli]) ;; if you want to use the shadow-cljs command line tools (require '[shadow.cljs.devtools.api :as api]) (server/start!) (api/watch :app) (api/repl :app)
:lein true in my config:dev or :cljs or so?:dev profile, although i actually wasn't sure about that:failed-to-compare errors, but the build still completes successfullycheck_npm_versions(require '[shadow.cljs.devtools.server.npm-deps :as x])(x/make-engine*)nil from a clj REPL, although it was started with leiningen"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe":node-script builds(shadow/node-repl {:node-args ["--inspect-brk"]})Enable Remote JS Debugging is checked per https://facebook.github.io/react-native/docs/debugging (`CMD + M` on OSX.)
Nice work @thhellersrc/clj just because? src/cljc just makes sharing annoying too. I pretty much always use setups like src/main/my/amazing/frontend/* and src/main/my/amazing/server/*my/amazing/frontend*src/frontend and src/backend works toosrc/cljc folder is forsrc/main/my/amazing/shared works fine toofrontend and backend for example. I've never come across a situation where that wasn't a 1:1 mapping with file extension though:modules is needed too, thanks!2.8.68 to 2.8.69? If I do the update, my application doesn't connect to the repl anymore 🤔2.8.69 to me:
shadow-cljs: WebSocket connected! browser.cljs:26 shadow-cljs: REPL session start successful
2.8.69:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
This is what appears in 2.8.68:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
browser.cljs:26 shadow-cljs: WebSocket connected!
browser.cljs:26 shadow-cljs: REPL session start successful
Is there something I can do to provide more helpful context?shadow-cljs watch the-build?shadow.cljs.devtools.client.browser exists in the browser console?2.8.69, there is no websocket connection attempt on the network tab in the console, and shadow.cljs.devtools.client.browser.cljs is loaded in the browser (prints in the thread)shadow.cljs.devtools.client.browser.cljs in the console, I get an object back.cljs?.cljs suffix shadow.cljs.devtools.client.env.enabled?undefinedshadow-cljs clj-repl then ( "goog/base.js"). I'm guessing you have an old closure-library version0.0-20191016-6ae1f72flein here!
shadow.user=> ( "goog/base.js") #object[java.net.URL 0xdad8889 "jar:file:/Users/lucas.barbosa/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
.env/enabled is a goog-define and goog.define was changed in the latest closure compiler/library release;; test.clj (defmacro dummy [] `(defmulti x ~identity)) ;; test.cljs (dummy)The error:
------ ERROR ------------------------------------------------------------------- File: /.../test.cljs Error in phase :compilation -------------------------------------------------------------------------------- --------------------------------------------------------------------------------Not sure if that could be handled at all.
:shadow.build/modedebug-enabled? : https://github.com/day8/re-frame/blob/accc559010c8635020fb929f1a4b081b69f58d5f/src/re_frame/interop.cljs#L16 )(defn lazy-component* [loadable]
(React/lazy
(fn []
(js/console.log "still lazy?")
;; React lazy expects a promise, that returns an ES6 module with a React Component as default export
(-> (shadow.lazy/load loadable)
(.then
(fn [root-el]
(if-not js/goog.DEBUG
;; in production mode, just do that
#js {:default root-el}
;; in dev mode, we need wrap the loaded component one
;; extra level so live-reload actually works since React
;; will keep a reference to the initially loaded fn and
;; won't update it
#js {:default (fn [props]
(js/console.log "lazy render")
(js/console.log (@loadable #js {}))
(React/createElement @loadable props)
(hx/f [LazyComponentWrapper {:loadable loadable :props props}])
(hx/f [LazyWrap {:loadable loadable :props props}])
)}))))))):default (fn [props] is called ONCE on initial load(r/reactify-component (fn [props] [@loadable props]))(hx/defnc LazyComponentWrapper [{:keys [loadable props]}]
(js/console.log "LOADABLE dereffed" @loadable)
[@loadable (bean props)])memo stuffreact-native project, and use a js file in it. The project looks like:
src ├── main ├ ├── main.clj └── js_libs ├ ├── my.jsIf I run it in
product mode, works well. And I run it in development mode, then occurs an error:
Can't find variable: shadow$provide
eval
[native code]
globalEval
index.js:828:25
evalLoad
index.js:2082:24
<unknown>
index.js:2404:20
loadModuleImplementation
require.js:331:6
<unknown>
index.js:1
loadModuleImplementation
require.js:331:6
guardedLoadModule
require.js:197:45
global code
What's the shadow$provide? @thheller:devtools opt?:http-handler shadow.http.push-state/handle(defn make-handler [cfg]...)node_modules/date-fns/package.json is likely empty or doesn't exist at all@ is just because it concats (str package-name "@" version) or somethingnode_modules/date-fns/package.jsondate-fns is what I show now.node_modules/date-fns/parseISO/index.js vs node_modules/date-fns/_lib/setUTCDay/index.js -- there's a _lib prefix in the last one.js/goog.DEBUG result in DCE in release builds?^booleancljs-dev.$APP.l(!1)&&(JO.displayName="nosco.views.page-list/DeletePagesButton")Map so no polyfill can fix that 😞"main": "dist/react-beautiful-dnd.cjs.js", "module": "dist/react-beautiful-dnd.esm.js",it seems shadow prefers the cjs one. Does it make any practical difference?
:js-options {:entry-keys ["module" "main"]} to pick module over mainimport { Document } from 'react-pdf/dist/entry.webpack';import React from "react"; console.log(React);logs
undefined. I am able to require "react" in my CLJS ns' just fineimport * as React. forgot my JS for a sec...import React would be correct but due to undefined CJS->ESM interop it is still import * for nowrequire statement in a cljs file?["react-pdf/dist/entry.webpack" :as some-cool-name] work ?println output from CLJS REPLs?shadow.cljs.devtools.api/node-repl I am not seeing any println output anymore.(shadow/node-repl) — if my reading of this issue is correct than println should at least work reliably on the first invocation of node-repl , but doesn’t for me. I will try reproducing with console shadow node-repl toonode-repl instance but doesn’t on subsequent invocations. (Just confirming what is written down in the issue already.)_react.default doesn't exist4.5.0 with no issues["@material-ui/core" :refer [Button]]"dependencies": {
...
"@material-ui/core": "4.5.0",
}["@material-ui/core/Button" :default button]. I wonder if that would work.["@material-ui/styles" :rename {ThemeProvider mui-theme-provider}](shadow/repl :app)dev might still work. I'm not sure 😛watch isn't already running(ns foo.bar) and (goog-define SHA "some-default-to-compare-against")shadow-cljs release --config-merge "{:compiler-options {:closure-defines foo.bar/SHA actual-sha}}"["@material-ui/core/Button" :default Button] and using older versions of material-ui. I'm convinced I'm doing something wrong.14:09:56.270 [XNIO-1 I/O-7] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1 [2019-11-18 14:09:56.269 - WARNING] :shadow.cljs.devtools.server/cli-checker-shutdown shutting down ... 14:09:56.273 [shadow-cljs-npm-process-checker] DEBUG io.undertow - stopping undertow server
.shadow-cljs/cli.check exists?.shadow-cljs/cli.check every 2sec and the JVM process will check it to see if it keeps getting updated{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c350674687e687177"}, :content ("[email protected]")} ... hope that variant is actually more reliable ... unless you are still on java 1.8 I guess 😛~/.shadow-cljs/config.ed.
- https://github.com/thheller/shadow-cljs/pull/600 for custom :log
- https://github.com/thheller/shadow-cljs/pull/601 for custom :nrepl
PTAL.:target configs, etc is way more important (IMHO)testing-library to shadowcljs and devcards and it seems to be okexports in package.json and so onimport {foo, bar} from "x"; will break if x is a commonJS packageimport X from "x"; and X.foo will be allowed:source-map true and :asset-path is likely the issue. looks like that should be /js?:npm-module project in a strange way.
The shadow-cljs compilation works normally, but later in the process the files are called/consumed by webpack and it fails with:
/path/filename.js:37939
if(COMPILED){
^
ReferenceError: COMPILED is not defined
at Object../build/cljs/cljs.core.js (/path/filename.js:37939:1)
at __webpack_require__ (/path/webpack:/webpack/bootstrap:19:1)
...
I'm comparing the generated cljs.core.js and the /path/filename.js between the two versions, but sifting through 5.1mb of js will probably take a little while given the spurious (gensym) differences 😬COMPILED2.8.73/path/webpack:/build/cljs/cljs_env.js:181
throw new Error('Namespace "' + name + '" already declared.');
^
Error: Namespace "goog.math.Long" already declared.
at Object.module.exports../build/cljs/cljs_env.js.goog.module (/path/webpack:/build/cljs/cljs_env.js:181:1)
at /path/webpack:/goog/math/long.js:143:5
at Object.module.exports../build/cljs/cljs_env.js.goog.loadModule (/path/webpack:/build/cljs/cljs_env.js:474:1)
at Object../build/cljs/goog.math.long.js (/path/filename2.js:50051:6)
:npm-module a bit more:maven {:local-repo "maven"} or so in shadow-cljs.edn~/.shadow-cljs/config.edn:asset-path controls that, just stick the entire URL in there(shadow/release :main {:asset-path "something"}):release {:asset-path "//foo.com/js"}?(shadow/release :main {:config-merge [{:asset-path "something"}]})shadow-cljs - failed to load – 329, how to debug this? is this a case for pseudo-names?--debug ?$jscomp is not defined, which I see in the main module wrapped inside an IIFE, so that's probably the culprityour not viewing the latest compilation output^:dev/after-load metadata?(reagent/render ...), most probably the function you call to start your applicaiton.hx(defonce EL (atom nil))
(defn ^:dev/after-load -render []
(when @EL
(react-dom/render
(hx/f [Main])
@EL)))defonce then yes. If it's local state (react hooks) it will be gone.Main is just the root component in that case.$jscomp issue -- I see a bunch of code in my lazy module that does things like $jscomp.arrayFromIterable, $jscomp.makeIterator and so on -- but no $jscomp definition in it. The main module almost immediately starts with (function(){
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl .... :output-wrapper false then I get over my issue, $jscomp is public and everything works again, with the downside of having a ton of global variables.:output-wrapper false or :prepend-js "var $jscomp = {};" in the base module to pull it into the global scopevar $jscomp just becomes $jscomp that isn't exported:prepend-js ? It doesn't seem to work, and I don't see how it could since it would run through optimisations. I tried :prepend to get it as a plain string but apparently due to JS scoping rules, the IIFE expression will still not "see it".:prepend not :prepend-js :append "window.$jscomp = $jscomp;The required namespace "cljsjs.codemirror.addon.edit.closebrackets" is not available, it was required by "klipse/ui/editors/editor.cljs". The namespace was provided via :foreign-libs which is not supported. Please refer to for more information.I'm trying to shim that addon namespace as described in the shadow guide, but I'm having trouble figuring out the things i need to require and export. There's also a few more addons in that klipse namesace that will have to be shimmed.
sourceMappingURL in a file appears to be a relative path, is that how's it supposed to work?
//# sourceURL=js/cljs-runtime/edu.unc.applab.clem.views.js //# sourceMappingURL=edu.unc.applab.clem.views.js.map
:asset-path. if you set :asset-path "js" then yes it will be a relative path/js otherwise your paths won't resolve properly as you use any kind of "routing"/some/thing then the browser will try to resolve /some/thing/js/js you force it to actually use /js//# sourceURL=/js/cljs-runtime/edu.unc.applab.clem.views.js //# sourceMappingURL=edu.unc.applab.clem.views.js.map
/js/cljs-runtime/edu.unc.applab.clem.views.js.map Will that setup find it properlycljs$core$IFn$_invoke$arity$6 /js/cljs-runtime/cljs.core.js:13306
cljs$core$IFn$_invoke$arity$5 /js/cljs-runtime/cljs.core.js:13288
cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13276
cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13564
list_errors /js/cljs-runtime/edu.unc.applab.clem.views.js:102
res /js/cljs-runtime/reagent.impl.component.js:134
reagent$impl$component$wrap_render /js/cljs-runtime/reagent.impl.component.js:153
reagent$impl$component$do_render /js/cljs-runtime/reagent.impl.component.js:201
render /js/cljs-runtime/reagent.impl.component.js:227
Which doesn't give me much help in where to look in my own fileconsole.warn(ex) then it won't have source mapping(js/setTimeout
(fn []
(throw (ex-info "omg" {})))
2000)"Error: omg
at new cljs$core$ExceptionInfo (/js/cljs-runtime/cljs.core.js:36930:10)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/cljs-runtime/cljs.core.js:36991:9)
at Function.eval [as cljs$core$IFn$_invoke$arity$2] (/js/cljs-runtime/cljs.core.js:36987:26)
at eval (/js/cljs-runtime/demo.browser.js:19:29)"Source map error: Error: request failed with status 404 Resource URL: line 827 > eval Source Map URL: cljs.core.js.mapI wonder if my routing is messed up. Anyway for me to tell what url it's looking for the source-map at?
localhost:3000? properly?<script src="/js/main.js">?:devtools {:loader-mode :script} in your build configgoog.math.Long error you ran into yesterday. is it possible you are including two separate builds using the closure library in some way?requires to be de-duped by webpack, for example)2.8.74, maybe that fixes it for reasons I can't explain 😛- cljs.core._STAR_print_newline_STAR_ = false; + (cljs.core._STAR_print_newline_STAR_ = false;)
goog.math.Lang is wrapped/provided differently
;;;;;;;;;;;;;
;; Old
goog.provide("goog.math.Long");
...
goog.math.Long = function(low, high) { ...}
...
goog.math.Long.getMinValue = function() { ... }
;;;;;;;;;;;;;
;; New
goog.loadModule(function(exports) {
...
goog.module("goog.math.Long");
...
var Long = function(low, high) {...}
...
Long.getMinValue = function() { ... }
...
exports = Long;
return exports;
});
module.exports = goog.math.Long;
:man-shrugging:
Will keep digging....npx tailwind build styles.css -o output.css This command works normally but inside a folder that has a shadow-cljs project it doesn't??styles.css which is
@import "tailwindcss/base"; @import "tailwindcss/components"; @import "tailwindcss/utilities";and outputs the same content into
output.css@import syntax requires postcss?M-x cider-jack-in-cljs) with the runtime in the Android VM, then all REPL commands result in:
example.repl> (js/alert "test") REPL command timed out.Is there a way to recover from this state? Reloading the app via
CMD+M (in the emulator) doesn't re-establish the connection from Emacs to the in-process nREPLjs/alert timeout or any command (given that you haven't executed js/alert before it).
The thing is - js/alert is blocking. The execution will not continue till you interact with the pop-up dialog.REPL command timed out unfortunately(shadow.cljs.devtools.api/repl-runtime-clear) to get rid of "stale" connections like that but it has to be called from a CLJ REPLmyapp.core> (js/alert "test") REPL command timed out.To recover this you'll need to: 1) Quit the CLJS REPL 2) Tell shadow-cljs to clear its REPL connection 3) Reconnect the CLJS REPL The following commands should achieve this.
cljs.user> :cljs/quit ;; wait at least 5 seconds for session cleanup user> (shadow.cljs.devtools.api/repl-runtime-clear) user> (shadow/repl :app)
repl-runtime-clearReload . That's after I tank the app with something bad like (js/require "foo")main option for node-test targets... given this namespace:
(ns app.core-spec (:require [cljs.test :refer-macros [deftest is]])) (deftest something (is true))and config:
:test {:ns-regexp "app.core-spec"
:output-to "out/test.js"
:target :node-test}}
running the tests works:
$ shadow-cljs compile test && node out/test.js shadow-cljs - config: D:\sandbox\devcards-test\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - socket connect failed, server process dead? [:test] Compiling ... [:test] Build completed. (47 files, 2 compiled, 0 warnings, 2.04s) Testing app.core-spec Ran 1 tests containing 1 assertions. 0 failures, 0 errors. Done in 13.20s.but if instead I require the test runner:
(ns app.core-spec
(:require [cljs.test :refer-macros [deftest is]]
[shadow.test.node :as stn]))
(deftest something (is true))
(defn main []
(stn/main))
and alter the config to use my main
:test {:main app.core-spec/main
:output-to "out/test.js"
:target :node-test}}
no tests will be found:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3f545e5256547f6d7a7b12670e7c09"}, :content ("[email protected]")}:main and :ns-regexp at the same time but that failed with a weird error:main?shadow-cljs server separately. waiting 12sec to a test to run is horrible:ns-regexp controls which namespaces are included yes"-test$"Testing app.core-spec-test?:main anymore without it trying to make it something else:ns-regexp is responsible for adding namespaces:main only controls running the tests and it loads the tests via a macro:main ns needs a {:dev/always true} annotation in the ns(ns app.core-spec
(:require [app.core-spec-two]
[shadow.test.node :as stn]))
(defn main []
(stn/main))
(ns app.core-spec-two (:require [cljs.test :refer-macros [deftest is]])) (deftest something (is true))
(ns app.core-spec
{:dev/always true}
(:require
[shadow.test.env :as env]
[cljs.test :as ct]
[shadow.test :as st]))
;; FIXME: add option to not exit the node process?
(defmethod ct/report [::ct/default :end-run-tests] [m]
(if (ct/successful? m)
(js/process.exit 0)
(js/process.exit 1)))
(defn main []
(-> (env/get-test-data)
(env/reset-test-data!))
(st/run-all-tests))$ shadow-cljs compile test && node out/test.js shadow-cljs - config: D:\sandbox\devcards-test\shadow-cljs.edn cli version: 2.8.69 node: v10.16.0 shadow-cljs - connected to server [:test] Compiling ... [:test] Build completed. (46 files, 1 compiled, 0 warnings, 0.82s) Ran 0 tests containing 0 assertions. 0 failures, 0 errors. Done in 1.83s.
:mountain:app.test-runner or so for :mainyarn test will run node-test test targets with ns-regexp, main pointing at a import of shadow.test.node, and main pointing at a copy of shadow.test.node:asset-path "/js" and likely need "js"/js implies absolute from the domain rootjs is relative to the current filejs/main.js loaded from index.html<script src="js/main.js"> :asset-path does nothing for the initial file, only if you use multiple :modules:asset-path is relevant too. still need to change the html for the initial load though:source-paths ["src" "env/dev"] (ns-es in "env/dev" are ignored for some reason).:lein true enabled, but i am not sure how those two interract.env/dev/tst/cards.cljs?env/dev/cljs/tst/cards.cljs . And source paths are defined in leiningen profile and i am able to build using lein.env/dev/tst/cards.cljs and not finding the filecljs directory then you need to add to the source-path instead:source-paths ["src" "env/dev/cljs"]:source-paths declared in lein config when :lein true is declared? Or it uses :cljsbuild\{build}\source-paths ?:cljsbuild are actually ignored.:lein true will use the source-paths defined in your leiningen config. it does not use anything to do with cljsbuild:lein true:devtools-url "`http://localhost:9630``"` should work and also use ws:// even if you serve the initial page over https?:profiles {:dev {:source-paths ["src" "env/dev"]}} with :lein true[cljsjs.react] and [cljsjs.react.dom] in your code somewhere before including devcards:npm-module please let me know what you use it for so I can better decide what to do about it. currently a good chunk of the open shadow-cljs issues are about problems with :npm-module and it is becoming harder to maintain with each new closure compiler release. https://github.com/thheller/shadow-cljs/issues/605var x = require("wherever/one.ns.from-your-app") for more than 1 namespace?require("./some-folder/one.simple.namespace") and require("./some-folder/another.namespace")?import { checkSchema } from "somewhere"?import * as userSchema from 'utilityboss/public/utilityboss.schema.users';
npm install googleapis and I am trying to require it in my .cljs file. This is my ns form:
(ns app.core
(:require [re-frame.core :as rf]
[reagent.core :as reagent]
["googleapis" :refer [google]]))
The browser outputs the following error:
shadow cljs watch app i get the following logs:
[:app] Build failure:
Module Entry "some.namespace.module.main was moved out of module ":module".
It was moved to ":main" and used by #{:module :main}.
I'm not sure what the logs are telling me. I understand there is a build failure. But is it saying the module move (i am trying to do code splitting) is the issue?:main directly required something from :module:main module on the :module entry point:main gets loaded without :module then it will break the code:depends-on setting up the relationshipsUnknown module: <module name> imply?:builds {:test {:target :browser-test
:test-dir "target/test"
:ns-regexp "-test$"
:devtools {:http-port 8021
:http-root "target/test"}}:http-port so you open reify is one of the other examples that would benefit by thisdef or interned in the namespacegensym solves that. just thinking out loud(gensym "fragment__")def out of the current scope .. no clue.reify is the prior art. it needs to do exactly this.exists? checkThe required JS dependency "@babel/runtime/helpers/interopRequireDefault" is not available, it was required by "node_modules/react-dates/lib/index.js". Search in: /Users/user/my-project/node_modules You probably need to run: npm install @babel/runtime/helpers/interopRequireDefaultWhen I run the npm install it gives me this
npm install @babel/runtime/helpers/interopRequireDefault npm ERR! code ENOLOCAL npm ERR! Could not install from "@babel/runtime/helpers/interopRequireDefault" as it does not contain a package.json file.
@babel/runtime. ie. react-dates depending on a different version than present in node_modules/@babel/runtime:local/root?lein javac in the :local/root dirlein with-profiles +cljs repl and (require 'repl) (repl/go)(shadow.cljs.devtools.api/watch :browser) or any of the other tests buildslein with checkouts works toolein install works if you have to. I've never really worked on shadow-cljs from inside another project:source-map true but not have //# sourceMappingURL=....map in the built JS file?sourceMappingURL doesn't really hurt but it produces an extra 404 error if there's no map when I open the dev tools.FIXME so I decided to ask here instead.manifest.edn contains a duplicated entry within :entries . Is this OK/normal?:entries [hgs.platform.core hgs.platform.core].:entries [hgs.platform.core] :init-fn hgs.platform.core/init or so?:entries if its just the same ns as :init-fn(.getSelection js/rangy) and (.init js/rangy)?npm i rangy and then in a file:
cljsjs/rang.cljs(ns cljsjs.rangy (:require ["rangy" :as rangy]) (set! js/rangy rangy)
in a shadow-cljs project.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
INTERNAL COMPILER ERROR.
Please report this problem.
null
Node(NAME LexicalGrammar): repl_interactor/webview/clojure_lexer.js:2:19
let toplevel = new LexicalGrammar();
Parent(NEW): repl_interactor/webview/clojure_lexer.js:2:15
let toplevel = new LexicalGrammar();
Node(SCRIPT): repl_interactor/webview/clojure_lexer.js:1:0
import { LexicalGrammar } from "/repl_interactor/webview/lexer.js";
Parent(ROOT): [source unknown]INTERNAL COMPILER ERROR is from the closure compiler ...npm link instead of putting it on the classpath, which seems to workclassclass out so it works fine then(require '[orchestra.spec.test :as stest] '[shadow.cljs.devtools.api :as api] '[shadow.cljs.devtools.server :as server]) (server/start!) (api/watch :app) (api/repl :app) (stest/instrument)This starts and restarts the compilation in my REPL with a single click. There's a lot of output at startup, but just the compilation result under normal operation. The backend (clojure) half of the application runs in a regular REPL and is used to serve the compiled files, so I'm not using the built-in webserver. My non-Cursive colleagues can easily start a REPL with
npx shadow-cljs watch app, although we haven't yet tried cider jack-in. I'm very happy with this setup, compilation is extremely fast (this is often a problem with WSL, figwheel is much worse) and the dev workflow has to be one of the best available in any language.{...
:builds
{:app
{:target :browser
:output-dir "public/js"
:closure-defines {app.core/URL #shadow/env "APP_URL"}
...}}}(js/console.log "This is the URL: " shadow.env/URL) This is where my current thoughts are but I can't seem to figure out how I am supposed to access it.(goog-define URL "some-default") in app.core and access that like any other (def URL ...) in that ns.env variables during a CI build. Or do the --config-merge thing. But I'm sure how I then access that in the app. I was just defining inline to test accessing it.(Test). that is invalid you must create a react element for that instead. so (r/createElement Test #js{}) or so:handler of the dev-server to conditionally proxy requests based on URI: https://gist.github.com/ian-moore/ddf9019f713e10dc5b62e065d0fcc8fcjs.js:74 shadow-cljs - failed to load module$node_modules$react_calendar$dist$entryThis prevents a required npm dep from loading causing the app to crash. Is there some new configuration required to get the latest shadow-cljs to work? I have tried
rm -rf .shadow-cljs as well, which does not fit it.js.js:74 shadow-cljs - failed to load module$node_modules$react_calendar$dist$entry shadow.js.jsRequire @ js.js:74 shadow.js.require @ js.js:100 eval @ /js/cljs-runtime/com…nents.calender.js:4 goog.globalEval @ main.js:836 env.evalLoad @ main.js:2216 (anonymous) @ main.js:3060
failed to load compute.ui.components.calender.js Module not provided: ./Calendar.css env.evalLoad @ main.js:2218 (anonymous) @ main.js:3060
2.8.75 should be ready to go2.8.76 in case you get some errors related to goog.define can't explain why that broke in the last release but AOT was behaving strangely before2.8.76 and generate a build report and then one with :compiler-options {:shadow-keywords true} looking to compare the gzip size before/after:compiler-options not :js-options[JS: 4.19 MB] [GZIP: 1019.18 KB]
• after: [JS: 3.99 MB] [GZIP: 960.59 KB] shadow-cljs work with lumo?shadow-cljs server and then shadow-cljs release app whenever you need while that is running you at least won't pay for the startup cost each timerelease twice produces different files. Seems like Closure renames some objects in different ways.
Is it possible to create the same output from the same input?release commands on my local machine. Removed only the js and js.map files in between.gensymgensym is in there somewhere. Although I would expect the order to be the same. But maybe that's not the case, or maybe the order doesn't matter.release, the numbers should've been the same. Unless there's some concurrent work being done.shadow-cljs release app --verbose if any actual CLJS compilation occurs.shadow-cljs/builds is preserved between the builds (which may require additional CI config)gensym and see if I can remove it. Is there anything else that I should look out for that could prevent a cached compilation result from being used?gensym usages in CLJS files. It's definitely used. Only those files are never recompiled.gensym or auto# uses it for yougensym. But only at some very particular places, and not the others. The same 6 files, each and every time.
The offending calls to gensym are made by doto and by cljs-oops. But I use them in a much greater number of files. It's interesting how only those 6 get different results.gensym returns different result in different runs.when uses gensym<- Cache read: hgs/platform/abc/core.cljs (8 ms) -> Compile CLJS: hgs/platform/abc/core.cljs [...] <- Compile CLJS: hgs/platform/abc/core.cljs (282 ms) [...] <- Cache write: hgs/platform/abc/core.cljs (32 ms)and the differences in variables' names in the cached JS in
{:output {:js "..."}}.-> Cache read: hgs/platform/abc/core.cljs <- Cache read: hgs/platform/abc/core.cljs (8 ms) -> Compile CLJS: hgs/platform/abc/core.cljs <- Compile CLJS: hgs/platform/abc/core.cljs (358 ms) -> Cache write: hgs/platform/abc/core.cljs <- Cache write: hgs/platform/abc/core.cljs (45 ms)
grep abc/core, the same output.requires some JS files. Both from NPM and from a dir relative to src.:compiled-at and some other timestamp-looking values (transit cached the keys, can't really tell without deserializing).(shadow.build.cache/read-file (io/file ".shadow-cljs/builds/foo/....")) in the REPL with the full path to the cache filehawk {:mvn/version "0.2.11"}<- Closure - Optimizing ... (46580 ms)
--verbose somehow didn't show it?shadow-cljs release app --skip-optimize-if-unchanged or something:module-hash-names trueUncaught Error: nth not supported on this type cljs.core/PersistentArrayMap
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:6349)
at eval (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.ops.js:23)
at Object.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:36362)
at Function.G__27279__2 [as cljs$core$IFn$_invoke$arity$2] (/js/compiled/cljs-runtime/cljs.core.js:14986)
at eval (/js/compiled/cljs-runtime/cljs.core.js:8044)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:8045)
at Object.eval [as cljs$core$IReduce$_reduce$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:10474)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:8198)
at Object.orgpad$client$layout$webworker$ops$apply_ops [as apply_ops] (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.ops.js:177)
at eval (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.handle.js:71):line it lists:js-errors [{:line 69565, :column 0, :message "Invalid delete operand. Only properties can be deleted."}]:js-errors above is the one causing the crash:target :react-native (based on the reagent-react-native template) and connecting to the cljs repl from emacs/cider. One unexpected behavior is that when I evaluate an expression over cider that throws an error, the trace is displayed in the simulator window, and no feedback is given in emacs/cider. Is that expected? Is there a way to get the exception to come back to emacs/cider so I can see it there?:target :browser shadow project, and a similar thing happens, it just prints the error in the repl buffer instead of popping up a *cider-error* buffer. So I'm guessing that this is actually something to do with how shadow emulates piggieback.*cider-error* even isimport DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css";
npm install without copy them into resources/public? should I use webpack? or there is a some simpler way?ln -s resources/public/styles.css node_modules/foobar/styles.cssdeps.edn together - what is the minimal amount of configuration necessary?
Reading https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn, it's suggested to use :deps true in the shadow-cljs.edn config file, but below that, it's stated that one must add thheller/shadow-cljs to deps.edn, and the example states to add it in :extra-deps, which in turn seems to require an alias, according to both the example and the deps ref: https://clojure.org/guides/deps_and_cli#extra_deps.
Using an alias in turn means that :deps true is not enough, since one need to specify the alias, eg :deps {:aliases [:cljs]} .
If this is correctly interpreted, I'd suggest removing the :deps true example for the next newcomer 🙂:deps true, it might be a blocker, especially for newcomers.node-target, but now I have some code that uses js/window and am trying to use jsdom in a sensible way. The best I’ve come up with so far is conditional initialization in src files, i.e., if there is no window present, make a fake one with jsdom . I’m curious if there’s a better way, though. Would build hooks be a possible alternative? Does anyone have any experience with this problem?/resources/definitions. The library parses these files and generates some Datomic/DataScript schemas + Clojure specs.
I want these files to be included in the library when used by downstream projects, but the way I wrote the "inlining" causes no files to be loaded at all in those projects.
My model library has this in deps.edn : :paths ["src/main/clojure" "resources"]
It "inlines" resources with the following code:
(defn list-resource-files
"Given a directory included on the classpath, returns seq of filenames"
[directory]
(let [in (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) directory)
reader (BufferedReader. (InputStreamReader. in))]
(loop [line (.readLine reader)
files []]
(if (some? line)
(recur (.readLine reader) (conj files line))
files))))
(defmacro inline-resources
"Given directory name in resources, returns coll of file contents"
[resources-path]
(->> (list-resource-files resources-path)
(map #(str resources-path "/" %))
(map #(slurp ( %)))
vec))
;; in consuming namespace
(inline-resources "definitions")/consuming-project/resources/definitions, which turns out to have zero files.
What I'm not clear on is how to workaround this. Short of just embedding the library's EDN in a .cljc file , is there any way to include resources/ from a library?lein did this and it "just worked". Also this might be a deps.edn question, can post there if it's more appropriate.
Worth mentioning is that I need to consume these resources from both clojure & cljs, hence why I was trying to "inline" it in the first place...jar files. you cannot "list" contents. you'll need to create an "index" file of some kind that lists the other files and then load them by name:devtools {:log-style "color: white;"} in your build config()?console.log#3390ffNPM dependency "react" has installed version "^16.12.0" "16.9.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
yarn, but Shadow doesn't appear to find its dependencies. I guess because yarn installs them in node_modules/@my-scope/my-package/node_modules? Anyone have any suggestions on how I could get these deps seen by shadow, aside from adding them all explicitly to my project's package.json?:js-options {:resolve {"mixpanel" false}} would cause (:require ["mixpanel"]) to not do anythingnode_modules dir? it usually only does this in cases on version conflicts which you'll need to resolvenode_modules after fixing diverged react versions.
What confused me was that the package it was complaining about wasn't depended on by anything else, and only existed in the one (nested) node_modules. But it seems that if any of the package's deps conflict, all of its deps go in the nested folder.["@my-scope/my-package/feature" :as my-feature] it works perfectly when accessing the page of my :npm-module build, but in the test (`:target :karma`) build I get: "The required JS dependency "@my-scope/my-package/feature" is not available ...". Not sure what I could be missing. 😕:npm-module you are likely using webpack or something as the final bundler that'll provide the JSyarn linked version. I guess something, somewhere, isn't getting correctly pointed to the package's dist/ subdir to find the compiled (yup, from TypeScript) JS files.:node-test ?:browser-test and :karma . Is there some easy way to exclude some (heavy) tests from the browser test suite only? Ideally on a test-by-test basis, not ns.(gobj/set shadow-js/process "nextTick" goog.async.nextTick). Updated shadow-cljs from 2.8.36 to 76 and shadow-js/process is now undefined, however I remove the monkey patch and the tests pass. Did that implementation change or are my tests broken?npx shadow-cljs classpath does not list the source path entries that shadow-cljs info produces. Is that normal? My understanding is that the classpath should be a combination of the given filesystem directory and .jar file entries, so if I have :source-paths ["src/main" "src/test"], I expect them both to be in the classpath.:deps or not?:source-paths and :dependencies in shadow-cljs.edn are ignored{:deps {com.fulcrologic/fulcro {:mvn/version "3.0.1"}}.:paths in deps.edn:deps {:aliases [:dev]}.{:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:module-hash-names true
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"}}:module-hash-names doesn't work when using workersshadow-cljs release app --config-merge '{:module-fingerprint "foo"}'shared.foo.js and layout.foo.js:devtools {:loader-mode :script} seems to fix thatimportScripts after the compilation though(my.ns
(:require [reagent.core :as r]
["vis-network" :as vis]
[clojure.string :as str]))
I run into https://github.com/visjs/vis-network/blob/c47be95c57caaa69ce31a6fca70fbf77f51fcac6/lib/network/modules/ManipulationSystem.js#L1206 this error with a release build so I am now doing a :simple build.
I also noticed the following warning with the release build, but not sure whether it is related
Resource: node_modules/vis-network/dist/vis-network.min.js:2 constant module$node_modules$vis_network$dist$vis_network_min assigned a value more than once. Original definition at externs.shadow.js:4Appreciate tips & pointers 🙂
if you posted? looks like its checking the arity of a function? maybe one you passed in? (fn [arg1 arg2] ..)?:advanced compilation will often remove function args if you don't use them. eg (fn [arg1 arg2] (use-only arg1))(fn [a] ...) since JS doesn't care if the arg is declared (usually)(callback) after you did the update?:release-version in 2.8.77 see https://shadow-cljs.github.io/docs/UsersGuide.html#release-version["clean" ["run" "-m" "shadow.cljs.devtools.cli" "release" "client"] "compile" ["less" "once"]]Any idea how to add the version there in the easiest way?
release fn described here https://shadow-cljs.github.io/docs/UsersGuide.html#clj-runrun -m my.build/release from lein(shadow/release :my-build {:config-merge [{:release-version "v1"}])--config-merge multiple times too):npm-module uses, but I'm finding that (from version 2.8.69) :closure-defines in shadow-cljs.edn isn't overriding the default values. Did something change in how that's configured? The documentation doesn't seem to differ from what I have.
Though for my current purpose I should be able to use goog.DEBUG, since that appears to still get set.(js/require "ardoq-sheet-load/build/npm/shadow.cljs.devtools.client.browser") to load the devtools while my module is embedded in our main app. This worked previously, but appears to no longer be enough/correct?[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
deps.edn right now$CLJS.CLOSURE_DEFINES contains myproject.core.EMBEDDED_DEV: true, but returning the value from a function within myproject.core returns false. 😕
To the devtools not working, I can see $CLJS.shadow.cljs.devtools.client.browser contains a bunch of functions and whatnot, so I guess it's being imported in some capacity, but none of the functionality is evident. Could the websocket be failing to connect silently? Not sure how to debug that. 😕2.8.68 is the most recent version where either of them work for me. Suggestions for fixing/debugging welcome, but otherwise I guess I'm going to have to stay on that release until I have more time/priority to investigate upgrading further. 😞2.8.77 should definitely work everything before .76 may have had a problem:asset-path configured correctly though:output-dir "resources/public/js/compiled" :asset-path "/js/compiled"
:optimizations :simple , and I’d expected that to produce a single JS file. But it’s producing my :output-to file in a way that references a ton of other files under .shadow-cljs/builds - is that normal? Can I make it produce a single file without going to advanced optimisations?2.8.76, but 2.8.77 also has the same behaviour - defines are not being overridden, and devtools are not active (I'd guess because the define/s to enable the devtools aren't being overridden).shadow-cljs work with lumo ?lumo is not "there" yet.lumo is an entirely different project with entirely different goals. dunno if it even supports "builds" nowadays, the focus was always scripting AFAICT2.8.68. In that version the websocket connects, but the browser doesn't appear to notice updates when shadow recompiles changed files. It appears that that stopped working for me in 2.8.56 . 😕:npm-module? I'm likely going to remove it given that it causes the most issues out of any builds2.8.78:deps {:aliases [:dev]} in shadow-cljs.edn
• :paths ["src/app" "src/test"] in the top level of deps.edn
• src/test/sheluchin/poker/core_test.cljs with these contents:
(ns sheluchin.poker.core-test
(:require
[cljs.test :refer-macros [deftest is testing run-tests]]))
(deftest test-numbers
(is (= 1 1)))
(run-tests)
It's unclear to me which option I should be using for running the tests: node.js, browser, or karma. Is it absolutely necessary to define a build target specifically for testing, or can I forego that for the time being? What command should I be using to run the tests? If I just eval the (run-tests) form, it doesn't seem to pick up on updates to that file, so if I change the test to (is (= 2 1)) , save the file, and re-eval the (run-tests) form, all the test still shows as passing.:browser-test target for tests:devtools {:preloads [your.foo.core-test]} in the regular build. that would make them hot-reload as well(require 'sheluchin.poker.core-test) after updating the file, it doesn't get picked up unless I shadow-cljs restart?(require 'sheluchin.poker.core-test :reload) otherwise it'll not load anything if its already loadedload-file is what I generally use (or rather my editor does):browser-test build target, what's the usual way to run the tests? I'm guessing it's like everything else and has CLI and REPL equivalents?:preloads thing I mentioned[1:1]~cljs.user=> (require 'sheluchin.poker.core-test :reload)
Testing sheluchin.poker.core-test
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
nil
[1:1]~cljs.user=> (load-file "sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
:cause "file not on classpath"
:data {:file-path "sheluchin/poker/core_test.cljs"}
:via
[{:type clojure.lang.ExceptionInfo
:message "file not on classpath"
:data {:file-path "sheluchin/poker/core_test.cljs"}
:at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
:trace
[[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
[shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
[shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
[shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
[shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
[clojure.lang.MultiFn invoke "MultiFn.java" 234]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
[shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 834]]}}]
[1:1]~cljs.user=>
+08:07 $ npx shadow-cljs classpath | tr ':' '\n'
shadow-cljs - config: /home/alex/repos/clojure-stuff/fulcrologic/poker/shadow-cljs.edn cli version: 2.8.64 node: v8.11.1
src/app
src/test
...
+08:08 $ tree src/test/
src/test/
└── sheluchin
└── poker
└── core_test.cljs
I can require the namespace and it works fine, but load-file complains that the file is not in the classpath, although it clearly is.load-file first?load-file takes an actual file path(load-file "src/test/sheluchin/poker/core_test.cljs")[2:1]~cljs.user=> (load-file "src/test/sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
:cause "file not on classpath"
:data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
:via
[{:type clojure.lang.ExceptionInfo
:message "file not on classpath"
:data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
:at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
:trace
[[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
[shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
[shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
[shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
[shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
[clojure.lang.MultiFn invoke "MultiFn.java" 234]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
[shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 834]]}}]
[2:1]~cljs.user=>
thheller/shadow-cljs {:mvn/version "2.8.52"}(load-file "/Users/whoever/projects/that-project/src/test/sheluchin/poker/core_test.cljs").52 so probably worth upgradingthheller/shadow-cljsjs- sorry for the noise.shadow-cljs using figwheel under the hood?shadow-cljs.edn;; for /browser-repl in case the page is reloaded
;; otherwise the browser seems to still have the websocket open
;; when doing the reload
(js/window.addEventListener "beforeunload"
(fn []
(when-let [s @socket-ref]
(.close s))))browser.cljs:406 Uncaught ReferenceError: window is not defined
at browser.cljs:406
at layout.js:2110
at Array.forEach (<anonymous>)
at Object.env.load (layout.js:2106)
at layout.js:2142figwheel work with shadow-cljs:devtools {:browser-inject :name-of-the-main-browser-module}.shadow-cljs/release-snapshot/the-build/latest/bundle-info.edn:worker-inject falserequire outside ns, right?ns(prefs/if-cljs-kernel (require '[pinkgorilla.kernel.shadowcljs :as cljs-kernel]) (require '[pinkgorilla.kernel.mock :as cljs-kernel]))
require conditional. CLJS stops parsing at the prefs/if-cljs-kernelrequirecannot be used anywhere other than in the ns form which is generally not true.:build-options {:ns-aliases {pinkgorilla.kernel.shadow-cljs pinkgorilla.kernel.mock}}mock ns whenever the shadow-cljs one was requiredrequire. my assumption always was that it also didn't run macros but I guess it does?if-cljs-kernel was a functionrequire outside ns was really meant for scripts that didn't have an ns (which shadow-cljs doesn't support either)if-cljs-kernel is a macro which acts depending custom :compiler-options[:app] Build failure:
IllegalArgumentException: Wrong number of args passed to keyword: :ns-aliases
clojure.lang.Keyword.throwArity (Keyword.java:98)
clojure.lang.Keyword.invoke (Keyword.java:149)
clojure.core/update (core.clj:6200)
clojure.core/update (core.clj:6188)
shadow.build/copy-ns-aliases (build.clj:251)2.8.80(shadow.cljs.devtools.api/repl-runtimes :todomvc-split) in the clojure REPL[{:runtime-info {:runtime-type :browser,
:lang :cljs,
:build-id :todomvc-split,
:user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
:remote-addr "0:0:0:0:0:0:0:1"},
:last-ping 1575462862870,
:last-pong 1575462862872,
:last-msg-received 1575462862872,
:last-pong-runtime 1575462862871,
:connected-since 1575462831938,
:runtime-id "69b97643-1982-4922-b7cf-375bfa7496a8"}
{:runtime-info {:runtime-type :worker,
:lang :cljs,
:build-id :todomvc-split,
:user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
:remote-addr "0:0:0:0:0:0:0:1"},
:last-ping 1575462863873,
:last-pong 1575462863874,
:last-msg-received 1575462863874,
:last-pong-runtime 1575462863874,
:connected-since 1575462832785,
:runtime-id "ebd1298e-0201-430b-889b-30bc97eb0103"}](shadow.cljs.devtools.api/repl :the-build {:runtime-id "that-runtime-id-from-above"})watch function, shadow-cljs shuts down once the targets are compiled. e.g.:
20:52 $ shadow-cljs watch dev test shadow-cljs - config: /Users/scott/code/xxxx/shadow-cljs.edn cli version: 2.8.52 node: v12.11.1 ... shadow-cljs - watching build :dev shadow-cljs - watching build :test [:dev] Configuring build. [:test] Configuring build. [:test] Compiling ... [:dev] Compiling ... [:dev] Build completed. (240 files, 1 compiled, 0 warnings, 3.65s) [:test] Build completed. (240 files, 1 compiled, 0 warnings, 3.67s) shutting down ... Worker shutdown. Worker shutdown.Works fine and continues to watch when only one target argument is supplied. Am I doing this wrong?
shadow-cljs - starting via "clojure" [2019-12-04T10:13:14,521][INFO ][o.xnio ] XNIO version 3.7.3.Final [2019-12-04T10:13:14,542][INFO ][o.x.nio ] XNIO NIO Implementation Version 3.7.3.Final [2019-12-04T10:13:14,581][INFO ][o.j.threads ] JBoss Threads version 2.3.2.Final shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.52 running at shadow-cljs - nREPL server started on port 8777
:jvm-opts in deps.edn then2.8.80 is latest:jvm-opts ["-Xmx1G"] in shadow-cljs.edn to constrain that2.8.80 worked. No memory constraints required. Thanks again 🙂:node-library's target would allow me to integrate with webpack and all other tools on the React side, but its not working (because it needs some of the Node code, like readFileSync and others). I could use :npm-module but then I loose the ClojureScript REPL. Is there any alternative?:npm-module as a target, going outside-in (i.e. from the leaves). We still use the REPLwindow.CLOSURE_BASE_PATH = '/javascripts' // Should match your assets location
require('cljs/shadow.cljs.devtools.client.browser') // REPL
require('cljs/shadow.remote.runtime.cljs.browser') // Shadow's Inspect[shadow.cljs.devtools.client.browser] on one of the required namespaces, it works too 🙂:node-library presumes node not webpack + browser.:npm-module able to run before/after load code?if (process.env.NODE_ENV === "development") { require("./path-to-output/shadow.cljs.devtools.client.browser") }React (which is not what you get by default). What are you guys using instead? Storybook?cljsjs.react before including devcardslein-garden looks like it only supports clojure though?cljsjs.react.dom. I don't know why devcards doesn't require them directly itself(:require ["react" :as react]) should work. I believe the newer cljsjs/react packages have that setup correctly to emulatecompilevia lein :aliases ẁorks ... until it does not when calling the alias from :prep-tasks. Seems this signature error is not uncommon. Any suspect about the possible culprit?
Note: Recompile with -Xlint:unchecked for details. Syntax error (NoSuchMethodError) compiling at (shadow/cljs/devtools/api.clj:1:1). com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
[thheller/shadow-cljs "2.8.80"] from :dev profile to default deps gets around it, but guess I don't want shadow-cljsending up in the (uber)jar.:backend and :frontend profiles in lein. that works reasonably well too1.10.597:advanced then yes that will never happenexample.html? which url did you load? there is no index.html?Active Builds window it sais client Watch starting ...:rewrite-polyfills like you suggested but am still encountering the same error.shadow-cljs and my output folder (not that it is needed) I get....Uncaught TypeError: $jscomp.initSymbol is not a function
at okta-sign-in.entry.js:14983...
cli version: 2.8.80 node: v12.3.1 and running on server cli version: 2.8.80 node: v12.3.1 just to confirmtools.deps for deps.yarnor npm?yarn!yarn scriptname and resolution to pin arbitrary packagesyarn get npm to do things properly and can we all get back to using the default thing.yarn.lock and package-lock.jsonresolutions is that it lets you control transitive dep versions, which is very useful when they inadvertently break@okta/okta-signin-widget just fine and it loads just find in dev and release builds. maybe you can try setting :compiler-options {:output-feature-set :es6} although it works without for me:modules try setting :compiler-options {:output-wrapper false}?shadow-cljs compile/`watch`give me a somewhat huge (12MB) module. That appears a bit odd for :none optimization. However, the cljs-runtime folder is 25MB and looks expected to me. Guess it all still somehow makes sense and there may be some desired redundancy. Could anyone please briefly explain how come the module may get that big?compile/ watchso I assume this is :none and hence, no DCE involved. The release build appears fine and just as expected. Will check build-report.:devtools {:loader-mode :script}:loader-mode :script indeed changes the size of the module as you pointed out. Again, thanks.:compiler-options {:output-wrapper false} seems to fix that?$jscomp variable:output-wrapper is necessary (setting to false causes some other error)var $jscomp = {};
...
var $APP = {};
(function() {
var $jscomp = $jscomp || {};var? I could have sworn this was supposed to work with var. let or const wouldn't.var $jscomp it works fine but no clue how to get the closure compiler to do that:output-wrapper default to true so if you didn't set that manually before you wouldn't run into this:compiler-options {:output-feature-set :es6} also works if you can live with thatwindow.$jscomp might be better$cljs$spec$alpha$$ object just gives backvar$cljs$spec$alpha$$. that should have zero references$cljs$spec$alpha$t_cljs$0spec$0alpha35496$$is just defined and never assigned a value 😕
reify callsreify callasync which would lead to race conditions? you can use defer?<script src="a.js" async> <script src="b.js" async>? this will load scripts in undefined order (based on whichever loads faster):js-options {:minimize-require false} if you want to know what those numbers stand forshadow$provide in the browser console0 entry thenshadow$provide. you have the code right there 😛shadow.js.filesshadow-cljs.edn I have a
following setup:
...
:nrepl {:port 3333}
:builds
{:app
{:target :react-native
:init-fn
:output-dir "react-native/app"
:js-options {:js-package-dirs ["react-native/node_modules"]}
:devtools {:repl-init-ns
...
Once I start the REPL I specify shadow as the REPL type and :app
as the build.
This starts the REPL and starts the build, which once complete goes in
the above specified ns .
When the REPL goes stale, where I can’t even eval something like '2,
I then do:
> :repl/quit user> (require '[shadow.cljs.devtools.api]) user> (shadow.cljs.devtools.api/repl-runtime-clear) user> (shadow.cljs.devtools.api/repl :app) cljs.user>At this point, I’ve recovered the REPL and can plough on as expected. Is this the recommended flow to clear the stale REPL session? If the answer is yes, what’s the way to create aliases that can be picked up, so that I don’t have to manually type up the full
(require '[shadow.cljs.devtools.api])? Say like in leiningen
projects where you can create dev/user.clj file where you can have
the desired requires.
And another, minor thing, once I’ve done the above, the ns I’m in, as
shown by the prompt is cljs.user. But as soon as I enter something
at the REPL, then the prompt changes to what I’ve set in my
:devtools {:repl-init-ns config.
Is there a config that I could set so that the REPL prompt can be
updated automagically?
Thanksrepl-runtime-clear wasn't necessary at all but I haven't found a good way to solve that problem yet. your workflow seems fine. you can create a user.clj if you want.user.clj what is the recommended convention:
• apart from having src under :source-paths , would you create something like dev/user.clj ?
• or would you just put user.clj under src directory?
• or is there some other way?
What is the “shadow” way of doing it?user.clj since that is always loaded unconditionally.:source-paths too) it really doesn't matterdev[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
:dependencies [[thheller/shadow-cljs "2.8.59"]]..
"devDependencies": {
"shadow-cljs": "^2.8.53", ...}
shadow-cljs command line then just project.clj is fine.project.clj 😉shadow-cljs pom and import the generated pom.xml in Cursive to create the projectshadow-cljs pom again to update later, Cursive will pick up the changes automaticallynode: v13.2.0 My project is at node 10.x , it won't clash, will it?target, node_modules folders ? I keep carrying some old libraries I am not using anymore..target yes, if you have a package-lock.json or yarn.lock (if you use yarn) then you can delete node_modules "safely"node_modules folderyarn again to rebuild themyarn.lock file the result of rebuilding them can be quite different1.5 or something and get 1.8 after a new installshadow-cljs watch app (where app is browser target) . I receive the following errors
The required namespace "cljsjs.material-ui" is not available, it was required by "cljs_react_material_ui/core.cljs" The required namespace "cljsjs.material-ui-svg-icons" is not available, it was required by "cljs_react_material_ui/icons.cljs"I create the following cljsjs stubs.
(ns cljsjs.material-ui (:require ["material-ui" :as material-ui]))and
(ns cljsjs.material-ui-svg-icons (:require ["material-ui-icons" :as material-ui-svg-icons]))The build now completes successfully. I open up the app and see the following errors in the developer console.
failed to load cljs_react_material_ui.reagent.js ReferenceError: MaterialUI is not defined failed to load cljs_react_material_ui.icons.js ReferenceError: MaterialUISvgIcons is not definedI add the following symbols
(js/goog.exportSymbol "MaterialUISvgIcons" material-ui-svg-icons) (js/goog.exportSymbol "MaterialUI" material-ui)to their respective stubs, The result is that the
MaterialUISvgIcons error disappears in the console but the MaterialUI error does not. Which I find confusing.material-ui/default.shadow-cljs compiler cache between CI builds and found that e.g.
1. rm -rf .shadow-cljs && lein shadow compile karma-test ~10-14s compile
2. lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 1.)
3. Tar up and extract the .shadow-cljs dir results in 10-14s compile again!
tar -cz -f cache.tgz -C .shadow-cljs . rm -rf .shadow-cljs mkdir .shadow-cljs cd .shadow-cljs tar zxf ../cache.tgz cd .. lein shadow compile karma-test4.
lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 3.)
What am I missing that is invalidating the cache ? The tar command used is what GitHub Actions cache action uses to cache files. This would speed up e.g. re-frame CI and all our internal builds by about 30%. @thheller.m2 maven downloads so that they don't change and also your JS deps in node_modules in case you use anyshadow-cljs but lacks repl? https://github.com/day8/re-frame/blob/master/docs/CodeWalkthrough.mdlein shadow supports any command shown by lein run -m shadow.cljs.devtools.cli --help e.g.
lein do clean, shadow cljs-repl clientlein shadow --help is not entirely helpful..shadow-cljs dir. just do .shadow-cljs/buildslein shadow does something? haven't checked what that doesios.js , but was hoping maybe we could use reader conditionals like we do for :clj and :cljsgoog.globalEval not available error when I open browser window.
opened up issue there, too: https://github.com/PEZ/rn-rf-shadow/issues/112.8.81src/main/foo where foo is a link to ~/dev/foo-project/src/foo{:paths ["src" "resources"]
:deps {com.fulcrologic/fulcro {#_#_:mvn/version "3.0.3"
.... :local/root "/Users/me/fulcro"}
lilactown/hx {:mvn/version "0.5.3"}}}
yarn link):watch-dir to "resources/public", which is the root that the web server serves from; still no changes are ever pushed (i see them when i reload the page). My css lives at resources/public/css/compiled, and is linked in the HTML as <link rel="stylesheet" href="/css/compiled/cue.css?cache-buster=<cache-buster>" />. What am I doing wrong?:watch-dir to "resources/public", which is the root that the web server serves from; still no changes are ever pushed (i see them when i reload the page). My css lives at resources/public/css/compiled, and is linked in the HTML as <link rel="stylesheet" href="/css/compiled/cue.css?cache-buster=<cache-buster>" />. What am I doing wrong?npx shadow-cljs watch app?cache-buster? your webserver just may be caching to aggressively too and only serving the "old" content when another request is made?{:lein {:profile "+dev"}
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "/js/compiled"
:compiler-options {:infer-externs :auto}
:dev {:compiler-options {:closure-defines
{"day8.re_frame.tracing.trace_enabled_QMARK_" true
"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:after-load user/after-load
:watch-dir "resources/public"}
:external-config {:devtools/config {:features-to-install :all}}
:pretty-print true
:print-input-delimiter true
:source-map true}
:release {:compiler-options {:closure-defines {goog.DEBUG false}
:optimizations :advanced}}
:main cue.core
:modules {:cue {:entries [cue.core]}}}}}:external-config needs to be in :compiler-options otherwise it has no effect:compiler-options:main cue.core does nothing(require '[orchestra.spec.test :as stest] '[shadow.cljs.devtools.api :as api] '[shadow.cljs.devtools.server :as server]) (server/start!) (api/watch :app) (api/repl :app) (stest/instrument)
:log {:level :debug} in shadow-cljs.edn top level"resources/public" as the value for my :watch-dir when my css lives at resources/public/css/compiled?/css/compiled/cue.cssresources/public + /css/compiled/cue.css{:type :asset-watch, :updates #{"/css/foo.css"}}:watch-dir was only needed for non-webserver setups, but your comment about the webserver not being involved makes me wonder whether i misunderstood?:watch-dir{:source-paths ["src/cljs"]
:dependencies
[[reagent/reagent "0.8.1"]]
:builds
{:app {:target :browser
:output-dir "resources/public/js/compiled/"
:asset-path "/js/compiled"
:compiler-options {:infer-externs :auto
:external-config {:devtools/config {:features-to-install :all}}}
:devtools {:after-load user/after-load
:watch-dir "resources/public"}
:modules {:css-reload {:entries [css-reload.core]}}}}}:entries or :init-fn) specified for one module was moved out:require setups somehow:modules
{:main {:init-fn some.app.main/-main}
:a {:entries [some.app.a} :depends-on #{:main}}
:b {:entries [some.app.a} :depends-on #{:main}}}
What would be an example of a something that would cause this error? Your implying something could be wrong with the requires? but i can't imagine what that could be. The app worked before the modules were added so in what scenario would it not work after modifying the shadow-cljs config to add modules.(ns some.app.main (:require [some.app.a :as a]) ?
You have to use the lazy load functionality?:depends-on correctlyimport * as React from "react";
I tried to use import React from "react" at first, but I get an error when I execute the code from a REPL that React is undefined. Using the glob syntax fixed this.
However, now a user has reported that trying to use it in React Native they receive this error:
--- helix/impl/class.js:1 Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import React from 'goog:shadow.js.shim.module$react';?
["react" :as react] is equiv of import * as react ...import React work would break the CLJS parts tooimport * as React should work in e.g. browsers right?import {createElement} from "react" or whatever to worknative.js versus web.jsimport * as react
so that you can do this
["react" :as react]
but react native isn't recognizing that syntax since it transpiles the JS itself (yet it has to be this way in es6 for the cljs import statement to work).native.js before .js.js fileComponent as the first arg in the functionshadow-cljs watch app from within my project directory and here's the shadow-cljs.edn (<https://gist.github.com/TomLisankie/ed0c3ab4e83c14aaf0bdf48b18594d47>).
I thought it was just taking a really long time to start or something, but then I tried the same command in a different shadow-cljs project and it was pretty quick. I'm guessing it's something wrong with my configuration, but I can't seem to figure out what.
Any help would be much appreciated.shadow-cljs cljs-repl app separately to get your REPL when needed. the watch is independent of thatshadow-cljs.edn ?deps.edn 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#deps-ednlein repl, just connecting to a single port and throwing clj/cljs forms from the editor against that single nrepl service. I may be missing something, but I am really having a hard time getting there (ugly :init-nsor even bypassing lein repland using lein run instead).
How would you guys be doing this?lein repl was that I found no way to get everything up without a manual step in between (launching shadow/watch). Hence, I stepped back from running lein repland started fiddling with lein run . However, I guess putting it all together may do the trick but still appears painful.(require '[shadow.cljs.devtools.api :as api] '[shadow.cljs.devtools.server :as server]) (server/start!) (api/watch :app) (api/repl :app)That kicks off the shadow compilation right there in the repl, and means i can restart shadow with a single click.
The result of a goog.define call must be assigned as an isolated statement. Only getting it at release buildclosure-library version on the classpath that is incompatible with the shadow-cljs version you are using[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
shadow-cljs.edn?lein deps :tree"user-namespace was evaluated" [:fb] Compiling ... Closure compilation failed with 18 errors --- goog/array/array.js:42 The result of a goog.define call must be assigned as an isolated statement. --- goog/array/array.js:50 The result of a goog.define call must be assigned as an isolated statement. --- goog/asserts/asserts.js:48 The result of a goog.define call must be assigned as an isolated statement. --- goog/base.js:213 The result of a goog.define call must be assigned as an isolated statement. --- goog/base.js:236 The result of a goog.define call must be assigned as an isolated statement. --- remaining errors ommitted ...
:builds {;; "firebase integration"
:fb {:target :browser
:compiler-options {:infer-externs :auto}
:output-dir "resources/public/fb/js"
:asset-path "/js"
:infer-externs :yes
:modules {:fb {:init-fn fb.core/init!
:entries [fb.core]}}
:build-hooks []
:release {:compiler-options {:optimizations :simple}}
:devtools {:http-port 8050
:http-root "resources/public/fb"
:watch-dir "resources/public/fb" :preloads [re-frisk.preload]}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}:dependencies that matter here:npm-module targets?
They appear to be almost correctly generated, both for development and release.
For development (`compile`), the source-maps aren't taking into account the shimming preamble. Deleting that and inspecting the maps with source-map-visualization[1] works as expected:
Here's an example of what I'm calling a preamble:
var $CLJS = require("./cljs_env");
var $jscomp = $CLJS.$jscomp;
require("./cljs.core.js");
var module$shadow_js_shim_module$$material_ui$styles$ThemeProvider=$CLJS.module$shadow_js_shim_module$$material_ui$styles$ThemeProvider || ($CLJS.module$shadow_js_shim_module$$material_ui$styles$ThemeProvider = {});
[...]
var shadow=$CLJS.shadow || ($CLJS.shadow = {});
[...]
var module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded=$CLJS.module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded || ($CLJS.module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded = {});
// empty line
$CLJS.SHADOW_ENV.setLoaded("cljs.namespace.js");
// empty line
Source maps for :browser-test worked out of the box!
(I couldn't check release builds - the tool complained about missing sources)
[1] - https://sokra.github.io/source-map-visualization/#custom:browser-test work flawlessly, but those for :npm-modules do not.
They're loaded and served correctly (via source-map-loader on webpack) but the mappings are slightly off, and removing the preamble from the JS seems to fix the mapping (but breaks the file, of course)
We never brought it up because we were using WP3 at the time, and attributed it to it!release build while running a watch build, won't they conflict (ie mess up the development process), if I don't have a specific :release {:output-to "... clause in my configuration? (`:target :browser`)shadow.resource for non-code resources. I think this is meant for single files only. What approach would I use to require a directory instead?(shadow/release <build-id> {:config-merge [{compiler-options {:optimizations :advanced}]})
I expect the build to use a configuration similar to as if i had a shadow-cljs.edn:
{:builds {<build-id> {:release {:compiler-options {:optimizations :advanced}}}
It would be nice to be able to easily verfiy i merged correctly.(shadow/release <build-id> {:config-merge [{compiler-options {:optimizations :advanced}]})`
given a shadow-cljs {:builds {<build-id> {:release {:compiler-options {:optimizations :simple}}}``
would be:
{:builds {<build-id> {:release {:compiler-options {:optimizations :advanced}}}
?:builds map that doesn't exist anymore{:build-id <build-id> :release {:compiler-options {:optimizations :simple}}}:build-id is added automatically (taken from the outer map){:build-id <build-id> :compiler-options {...}}##NOTE "..." just means information we can ignore.
{:modules
{:main {...}
:a {:entries [...] :depends-on #{:main}}
:b {:entries [...] :depends-on #{:main}}}
This results in
the main module including a namespace (will call it c_ns).
The issue is that this namespace is really only a requirement of the a and b namespace (corresponding to the modules we declare above).
Its my understanding that if i explicitly create a new module for c_ns then have the other two modules (:a and :b) depend on it. Then
the c_ns wont be fetched as part of loading the main module. This is possible because once the modules depend on the namespace explicitly,
the Google Closure compiler will know to not put it in the default module (main).
Specifically if we make the shadow-cljs file such that its like this:
{:modules
{:main {...}
:a {:entries [...] :depends-on #{:main :c}}
:b {:entries [...] :depends-on #{:main :c}
:c {:entries [...] :depends-on #{:main}}}
This process seems to work when applied to the first module we tried it on.
However, on the second one we tried. It doesn't.
In the working version what we see from our network traffic on the browser is. The app loads and
we make a GET request for the module we split out. The react components correctly load and
everything works as expected.
In the version that DOESNT work. The app loads and makes 3 GET requests for the module we split out (possible retries). The
react components don't correctly load. Specifically, a component that was loaded as part of react suspense
never loads. Its stuck at "suspended = true". This component would correspond to module :a or :b (from above). The components
that depend-no the module we are trying to split out.
Additionally, This behavior is only observed when we use the compiler optimizations set to Advanced.
Which in part is making it difficult for me to understand how to debug the issue, as i'm less sure how to get feedback.<script src="/js/main.js"> or whatever path you have?shadow.loader?<script src="/js/main.js">
For the module that isn't working were not using anything from shadow.loader. We were under the impression that just by declaring the modules in our shadow-cljs.edn file they would be re-organized as part of an optimization by the google closure compiler.shadow.loader.set_loaded();
So my interpretation of that is that somehow set_loaded is being called with no arguments? Possible resulting in the above error. Does that seem reasonable?.83 or .68?foreign-libs?st/instrument for some reason it starts to return an empty vector and stops instrumenting my fdefs.shadow-cljs, which has a builds dir that has the build cache.shadow-cljs made it work again.shadow-cljs and now have reintroduced it and everything is working fine :man-shrugging:impl.cljs <= defn’s
impl_specs.cljs <= fdefs
impl_test.cljs <= st/instrumentimpl.cljs or impl_specs.cljs or impl_test.cljs?st/instrumentable-syms it’s a set, other times it`s a vector, and when things weren’t working I remember running it and it was a vector with a ton of duplicates of the fdef’ed syms:cache-blockers configuration. It expects a set of namespace symbols. @colinkahn @lilactown :cache-blockers . I have: :cache-blockers #{cljs.spec.test.alpha clojure.spec.test.alpha}.shadow-cljs
Is there something I can find in those files that might give a clue to what is causing it to break? I've looked in the folder but can't say I really understand what those files are doing..shadow-cljs/builds/<the-build-id>/dev/ana/...deftest without async:
(deftest test-1
(st/unstrument)
(is (= (set (st/instrument)) #{`app.core/foo}))):cache-blockers and was able to get it no longer fail.:cache-blockers does(shadow.cljs.devtools.api/repl-runtimes-clear) to kick out "stale" sessions(shadow.cljs.devtools.api/repl-runtimes-clear)lodash. For example, if I have the following line on src/dependent.js:
import { size, isEqual } from 'lodash';
The following code on a .cljs file doesn't work:
(ns lod.main (:require ["/dependent" :as d]))
Closure compilation failed with 2 errors --- dependent.js:1 Requested module does not have an export "isEqual". --- dependent.js:1 Requested module does not have an export "size".
require and module.exports so CommonJS instead of ESM(react/createElement foo) , the CLJS file that uses it must require react)Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V at com.google.javascript.rhino.IR.name(IR.java:381)
Exception in thread "main" Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1). at clojure.lang.Compiler.load(Compiler.java:7647) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:463) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:1523) at shadow.cljs.devtools.cli$eval1826$loading__6706__auto____1827.invoke(cli.clj:1) at shadow.cljs.devtools.cli$eval1826.invokeStatic(cli.clj:1) at shadow.cljs.devtools.cli$eval1826.invoke(cli.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7165) at clojure.lang.Compiler.load(Compiler.java:7635) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:463) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:408) at user$eval1809$fn__1813.invoke(form-init1501309315939750065.clj:1) at user$eval1809.invokeStatic(form-init1501309315939750065.clj:1) at user$eval1809.invoke(form-init1501309315939750065.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7166) at clojure.lang.Compiler.load(Compiler.java:7635) at clojure.lang.Compiler.loadFile(Compiler.java:7573) at clojure.main$load_script.invokeStatic(main.clj:452) at clojure.main$init_opt.invokeStatic(main.clj:454) at clojure.main$init_opt.invoke(main.clj:454) at clojure.main$initialize.invokeStatic(main.clj:485) at clojure.main$null_opt.invokeStatic(main.clj:519) at clojure.main$null_opt.invoke(main.clj:516) at clojure.main$main.invokeStatic(main.clj:598) at clojure.main$main.doInvoke(main.clj:561) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:37) Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V at com.google.javascript.rhino.IR.name(IR.java:381) at com.google.javascript.jscomp.VarCheck.<clinit>(VarCheck.java:94) at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:243) at cljs.closure__init.load(Unknown Source) at cljs.closure__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at clojure.lang.RT.classForName(RT.java:2207) at clojure.lang.RT.classForName(RT.java:2216) at clojure.lang.RT.loadClassForName(RT.java:2235) at clojure.lang.RT.load(RT.java:453) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:2088) at cljs.repl$loading__5569__auto____6321.invoke(repl.cljc:9) at cljs.repl__init.load(Unknown Source) at cljs.repl__init.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at clojure.lang.RT.classForName(RT.java:2207) at clojure.lang.RT.classForName(RT.java:2216) at clojure.lang.RT.loadClassForName(RT.java:2235) at clojure.lang.RT.load(RT.java:453) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:3894) at shadow.cljs.devtools.api$eval2856$loading__6706__auto____2857.invoke(api.clj:1) at shadow.cljs.devtools.api$eval2856.invokeStatic(api.clj:1) at shadow.cljs.devtools.api$eval2856.invoke(api.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7165) at clojure.lang.Compiler.load(Compiler.java:7635) ... 68 more
:compile-finish hook but there is nothing built-in to do that:build-sources in the compile state. those are the resource-ids for all sources that were compiled. (get-in build-state [:output resource-id]) will get you the compile output :js is the generated JS for example(tap> build-state) and look at it in the Inspect UIbabel-preset-css-prop plugin: https://github.com/emotion-js/emotion/blob/master/packages/babel-preset-css-prop/src/index.js<div css={color: green`} />` and hooks into the JSX parser to transform the css prop:css prop in a map and do the transformation(def my-styles (emotion/css #js {:color "green"}))
(defn my-component []
[:div {:class my-styles} "Hello"])shadow.resource might work for you? https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745lein new luminus test +reagent +shadow-cljsthen use
lein shadow release appit output the errors
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
clojure.lang.Reflector.getInstanceField (Reflector.java:397)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
shadow.build.closure/js-error-xf/fn--23982 (closure.clj:536)
clojure.core/map/fn--5862/fn--5863 (core.clj:2742)
clojure.core.protocols/iter-reduce (protocols.clj:49)
clojure.core.protocols/fn--8140 (protocols.clj:75)
clojure.core.protocols/fn--8140 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
clojure.core/transduce (core.clj:6884)
clojure.core/into (core.clj:6899)
clojure.core/into (core.clj:6887)
shadow.build.closure/log-warnings (closure.clj:1081)
shadow.build.closure/log-warnings (closure.clj:1077)
shadow.build.closure/log-warnings (closure.clj:1079)
shadow.build.closure/log-warnings (closure.clj:1077)
shadow.build.closure/optimize/fn--24199 (closure.clj:1185)
shadow.build.closure/optimize (closure.clj:1170)
shadow.build.closure/optimize (closure.clj:1161)
shadow.build.api/optimize (api.clj:268)
shadow.build.api/optimize (api.clj:262)
shadow.build/optimize (build.clj:411)
shadow.build/optimize (build.clj:403)
shadow.cljs.devtools.api/release* (api.clj:350)
shadow.cljs.devtools.api/release* (api.clj:336)
shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
shadow.cljs.devtools.cli/main/body-fn--28515--auto----29104 (cli.clj:168)
shadow.cljs.devtools.cli/main (cli.clj:167)
shadow.cljs.devtools.cli/main (cli.clj:134)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:221)
shadow.cljs.devtools.cli/-main (cli.clj:219)
clojure.lang.Var.invoke (Var.java:388)
user/eval12549 (form-init10468658607384081452.clj:1)
user/eval12549 (form-init10468658607384081452.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7167)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.Compiler.loadFile (Compiler.java:7574)
clojure.main/load-script (main.clj:475)
clojure.main/init-opt (main.clj:477)
clojure.main/init-opt (main.clj:477)
clojure.main/initialize (main.clj:508)
clojure.main/null-opt (main.clj:542)
clojure.main/null-opt (main.clj:539)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
how to debug this error?shadow-cljs.edn only so you don't have to deal with this ...instance), looks like it doesn't distinguish which variable is used by which node, will it really fast?:depends-on @cfleming?{...
:output-dir "public/js"
:modules
{:shared
{:entries [my.app.common]}
:home
{:entries [my.app.home]
:depends-on #{:shared}}
:login
{:entries [my.app.login]
:depends-on #{:shared}}
:protected
{:entries [my.app.protected]
:depends-on #{:shared}}:modules:cljs-base module.:shared module that all others depend on. you can use :entries []shared.js and the-page-you-are-on.js via HTML:modules {:shared {:entries []}
:pay {:init-fn site.pay/init!
:depends-on #{:shared}}
:quote {:init-fn site.quote/init!
:depends-on #{:shared}}
:buy {:init-fn site.buy/init!
:depends-on #{:shared}}
:renew {:init-fn site.renew/init!
:depends-on #{:shared}}
However when I compile, I get the following:
[:site] Build failure:
Module Entry "site.buy" was moved out of module ":buy".
It was moved to ":shared" and used by #{:buy :quote}.site.buy ns was used somewhere in the :quote module. likely a direct (:require [site.quote ...])shared.js, buy.js and quote.js in quote.html? Or is the shared code all moved out to shared.js?:node-script build and I watch it, then hot code reloading should just work - is that correct? Is something logged somewhere when code is reloaded in that case?(defn ^:dev/after-load do-something-after-reload [] ...)?(defn ^:dev/after-load... vs (defn {:dev/after-load true}...^ comes before 😛some-fn it may help to pass #(some-fn %) instead:karma target for cli tests (which has a "browser" runner as well IIRC)https://<my-domain>/path, but in local dev I want them to call . Is there a tidy way to do this? I thought about using the hosts file but that doesn’t allow me to switch from https to http or specify the port to use.(goog-define LOCAL true) (def api-target (if LOCAL "<local-url>" "<prod-url>")Then only one of those values will be compiled into the code? Or am I better to have the URL itself as the value of the define?
^clj type hint?:test
{:target :node-test
:output-to "target/test/node-tests.js"
:autorun true
:ns-regexp "-test$"}shadow-cljs watch test doesn’t actually run the tests:
~/d/c/lambda (master)> shadow-cljs watch test shadow-cljs - config: /Users/colin/dev/cursive-site/lambda/shadow-cljs.edn cli version: 2.8.77 node: v12.1.0 shadow-cljs - connected to server shadow-cljs - watching build :test [:test] Configuring build. [:test] Compiling ... [:test] Build completed. (115 files, 13 compiled, 0 warnings, 7.68s)
watch two builds from the same project simultaneously in separate terminals?shadow-cljs pom and import the generated pom.xml in intellij for the project:advanced?shadow-cljs release app then shadow-cljs run shadow.cljs.build-report app report.html:optimizations :simple it will default to advanced.shadow-cljs/builds/the-build/dev/ana/...:advanced so you are doing something weird.js fileshadow-cljs release app --pseudo-names and try to figure it out from therenamespace "good.math.Long" already declared issue: https://github.com/thheller/shadow-cljs/issues/621
ideally i'd like to take advantage of nextjs web optimizations and ease of deployments
but wanted to ask, is it even recommended using them together? has anyone successfully gotten it working?cljs/analyzer.cljc (which I could figure out thanks to npx shadow-cljs run shadow.cljs.build-report app) in my bundle and I'd like to know why.Namespace: cljs.core.async via: cljs/core/async.cljs Entries that led to the inclusion of this namespace shadow.cljs.devtools.client.browser -> shadow.cljs.devtools.client.hud -> cljs.core.async shadow.test.browser -> shadow.dom -> cljs.core.async
(ns orgpad.client.views.widgets.md-button
(:require ["@material-ui/core/Button" :as button]))
(defn md-button []
[:> button/Button {:color :primary :variant :contained} "button"])
When calling md-button, the following error occurs:
react.development.js:168 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.How does the requiring work? Why does this occur?
(not (= [{:foo/id {1 {:foo/id 1}}} {:bar/id {1 {:bar/id 1, :bar/foo [:foo/id 1]}}}] [{:bar/id {1 {:bar/id 1, :bar/foo [:foo/id 1]}}} {:foo/id {1 {:foo/id 1}}}]))
is really hard to read in the browser.pom.xml fileanime.js with shadow-cljs?["animejs/lib/anime.es" :default anime]:Piggieback :module-name instead of the :CljEval , i am wondering what the difference is:Piggieback:
*fireplace-piggieback* *fireplace-clojurescript*
To use a ClojureScript, invoke |:CljEval| with the command you would normally use to start a ClojureScript REPL. For example:
>
:CljEval (cider.piggieback/cljs-repl (cljs.repl.nashorn/repl-env))
<
...
The :Piggieback command is softly deprecated wrapper for invoking Piggieback.
i figured :CljEval might be the more generic way to go about adding cljs support to an nrepl session. i might be wrong though. :man-shrugging::skin-tone-2:depend-on another module?
The docs say
> The names of other modules that must be loaded in order for this one to have everything it needs.
and the blog post says :
> As explained above we will start with the `:main` module (becoming the `main.js` output) calling `(https://demo.app/init)` on load, it is the only module that can be loaded directly without loading any other. Then we define one module for each component and they all depend on the `:main` module since that will provide the common code such as `reagent`, `react` and of course `cljs.core`. `:module-loader true` just tells `shadow-cljs` that it needs to do a couple extra steps to allow loading the code dynamically.
This seems straight foward, but to test my understanding. Say you have a react compoment A that contains another compoment B and both are made into modules. code looking like (not precise semantics of course)
(lazy-load A)
(defn A [] (.... (lazy-load B))
In this case it would seem wrong to say A depends on B because it doesn't necessarily contain what it needs to load.
Or maybe another test question would be. If in the blog post, you dont say "depends-on" then what happens? Would each module re-load all the code shared between main and the individual modules?depends-on another, it means that the depended on module MUST be loaded BEFORE the module which depends on it:main :A and :B:A no problem without :B. so you wouldn’t say it depends-on :B.
similarly, you can probably load :B without :A , since they’re both just React components and you might have other components which would lazy-load B somewhere else:main , which the compiler can move the code shared between modules :A and :B so it doesn’t get downloaded and loaded twicedepends-on is a way of specifying where shared code will be moved between a number of modules.
So if you have:
{:main {:entries [app.core]}
:A {:entries [app.A]
:depends-on #{:main}}
:B {:entries [app.B]
:depends-on #{:main}}}
this will make it so that any shared code (such as React, or other library or application code shared between the two) will be moved into the module created from :main. Then when you load :A, it will only have code specific to that module. :A will kick off a dynamic, lazy load of :B, which will also only contain code that is needed to render the B component.depends-on is a way of specifying static dependencies on modules. in this case, you are dynamically loading another module so there’s no necessary static dependencies between the two:appapp.js file and the client downloads it all upfront and it all gets run in the browser before your app starts:feature , and you say:
{:app {:entries [app.core]}
:feature {:entries [app.feature]
:depends-on #{:app}}}
now you can lazy-load app.feature.app.feature namespace, and all of the namespaces it requires.
if code or a namespace only appears in app.feature, then it will move that code into into the feature.js bundle.
if code or a namespace appears in app.feature, and something that is required by app.core, then it will be moved into the app.js bundle.
that way, when you load app.js it will have all of the code necessary for the app.core namespace with it. When you load feature.js, it will not contain any duplicate code that app.core and app.feature both needapp.feature was pretty hefty, maybe it included a couple NPM libs that were only used there, so the app.js bundle is now 1.1mb and the feature.js bundle is 0.9mb(lazy-load 'app.B) I don’t think it will infer that it needs to lazy-load C before it. you need to load C first, then B(def lazy-A (lazy-component app.A/A))
(def lazy-B (lazy-component app.B/B))
(case route
"A" (lazy-A)
"B" (lazy-B))
A ns
(:require [app.C]) (defn A [...] (C/lazy-C))B ns (same as A) C ns
(defn C [...] ...) (def lazy-C (lazy-component C))
(C/lazy-C) before the route in the main ns?lazy-C is redundant(defn C ...) supposed to be (defn main ...)?main, then that means you are explicitly requiring C in A and B somewherelazy-component to load C.app.A and app.B requires:depends-on means. You need to differentiate between "depends on" and "uses".requireing with lottie:
(ns animation (:require ["lottie-web" :refer [lottie]])) (defn load-animation [props] (.loadAnimation lottie props))I get back:
Duplicate let / const / class / function declaration in the same scope is not allowed.Googling around led me to https://github.com/google/closure-compiler/issues/3098, so I tried adding
{:output-wrapper true} to the build and it didn't change anything. I am guessing that i will just have to require the js directly in the HTML instead of via npm .function EffectsManager(){}
function EffectsManager(data,element){
var effects = data.ef || [];
this.effectElements = [];
var i,len = effects.length;
var effectItem;
for(i=0;i<len;i++) {
effectItem = new GroupEffect(effects[i],element);
this.effectElements.push(effectItem);
}
}:node-library target. I compile with release and everything works as expected, except that instead of using (set! ... I needed to use (aset ... to mutate a specific property in the context object that the handler received. How come this is necessary? I googled the difference between the two, but I still fail to understand why aset is needed in my case.
The specific property is "callbackWaitsForEmptyEventLoop". Printing out (.-callbackWaitsForEmptyEventLoop context) yields nil, whereas (aget context "callbackWaitsForEmptyEventLoop") yields true which is supposed to be the default value, which is what lead me on the right path..- style accessaget works is because the string "callbackWaitsForEmptyEventLoop" isn't renamed but .-callbackWaitsForEmptyEventLoop almost definetly is during an :advanced compile which is what release does.set! and aset act differently but my hope is that it is really just the way you are trying to access the result that is causing the issueaget and aset on object, see https://clojurescript.org/news/2017-07-14-checked-array-accesscljs.core/unchecked-set, which according to KLIPSE is compiled to foo["bar"] = 42.
@thheller had another solution, involving sticking to .- notation, adding additional externs checking, and type-hinting with ^js, when the compiler is clueless. This seems to be the better option.framer-motion with shadow-cljs?<motion.div animate={{ scale: 0.5 }} /> this work anyhow.. 😕 this is how I import it:
["framer-motion" :refer [motion]]this is how I’m using it
[:motion/div {:animate (clj->js {:scale 0.5})} "Hello"][motion/div {:animate (clj->js {:scale 0.5})} "Hello"] or even [motion/motion.div {:animate (clj->js {:scale 0.5})} "Hello"]motion in the browser console and see what attributes are on there to call into^js tags for things it warns about. see https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs[:> (. motion -div) ...]. the slash notation (eg. motion/div) only works for actual namespace aliases, so things using :as in :require (eg. (:require ["thing" :as alias])) not :refercom.fulcrologic.fulcro-native.alpha.components.src
main
app
...
com/fulcrologic/fulcro_native/alpha/components next to main or app?src/main then src/main/com/fulcro....yarn link in the CLJS worldgoog: prefix (i.e. import something from "goog:namespace")
When we use such a JS file from Shadow and the CLJS ns contains dashes, things break.
;;;;;;;;;;;
;; company/name_with_dashes.cljs
(ns company.name-with-dashes)
(def ^:export Thing '...)
;;;;;;;;;;;
;; company/folder-with-dashes/helper.js
import {Thing} from 'goog:company.name-with-dashes'
;;;;;;;;;;;
;; company/component.cljs
(ns company.component
(:require ["company/folder-with-dashes/helper.js" :as helper]))
While running tests involving company.component via :browser-test, shadow issues a warning:
shadow-cljs - failed to load module$node_modules$company$folder_with_dashes$helper
shadow.js.jsRequire @ js.js:71
failed to load company.component.js ReferenceError: with is not defined
at Object.shadow$provide.module$node_modules$company$folder_with_dashes$helper (helper.js:xx)
at Object.shadow.js.jsRequire (js.js:63)
at Object.shadow.js.require (js.js:97)
at eval (/js/cljs-runtime/company.component.js:xx)
at eval (<anonymous>)
at Object.goog.globalEval (test.js:827)
at Object.env.evalLoad (test.js:2174)
at test.js:2373
env.evalLoad @ test.js:2176
Digging into module$node_modules$company$folder_with_dashes$helper reveals:
...
var _immutable = require("module$node_modules$immutable$dist$immutable"),
_googCompany = global.company.name-with-dashes
;; ^ can't have dashes on JS symbol, right?
Other than renaming the involved files, would there be a workaround for this?_ instead of -? otherwise rename ...import {Thing} from 'goog:company.name_with_dashes') fails with
The required namespace "company.name_with_dashes" is not available, it was required by "..." 😕npx react-native run-android will be required to get the repl back? Here's the workflow that I'm using.
bash$ npx react-native run-android emacsλ (inf-clojure-connect "localhost" 5555) shadow.cljs => (shadow/repl :app) cljs.user => (+ 2 2) 4 ;; Make some code changes and reload the app in the emulator to render them. cljs.user => (+ 2 2) ;; Long delay Timeout while waiting for REPL result.Then the only way I've found to get the REPL working again is to re-launch the emulator with
npx react-native run-android. It's a painfully slow development loop, so I feel like I'm doing something wrong.(shadow/repl-runtime-clear) in the CLJ REPL(shadow/repl :app) again(shadow/repl-runtimes) should list all connected runtimes(defn exec [cmd]
(let [{:keys [exit out err]} (apply sh cmd)]
(if (zero? exit)
(when-not (str/blank? out)
(println out))
(println err))))
(defn nexe
{:shadow.build/stage :flush}
[state src dest]
(case (:shadow.build/mode state)
:release
(let [cmd ["nexe" "--output" dest src]]
(print (fmt "Executing: %s" cmd))
(exec cmd))
true)
state)shadow-cljs node-repl or shadow-cljs browser-repl:node-repl or :browser-repl build ids.shadow-cljs/socket.port (or something like that :))(defonce root-ref (atom nil))
(defonce root-component-ref (atom nil))
(defn render-root [root]
(let [first-call? (nil? @root-ref)]
(reset! root-ref root)
;; ...
And then re-natal has something similar.
(def cnt (r/atom 0)) (defn reloader [] @cnt [core/app-root]) ;; Do not delete, root-el is used by the figwheel-bridge.js (def root-el (r/as-element [reloader]))I didn't copy from an example and don't have anything like that in my code.
--verbose, same result. Is there a log or something where I might find more info?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0d6e616267787f68236e627f68297d7f64637961634d3c6f6838393b6f38"}, :content ("[email protected]")}. Not clear why that error would get swallowed though.clojure from my path and I'm trying to run shadow-cljs watch demo
https://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code
> @ start /home/souenzzo/src/demo > shadow-cljs watch demo shadow-cljs - config: /home/souenzzo/src/demo/shadow-cljs.edn cli version: 2.8.83 node: v13.4.0 shadow-cljs - starting via "clojure" Executable 'clojure' not found on system path. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ start: `shadow-cljs watch demo` npm ERR! Exit status 1Is clojure really needed?
deps.edn then you don't need clojure:test {:target :karma
:test-dir "resources/public/js/karma"}
Same thing happens with :browser-test and :node-test. Stack trace:
NullPointerException: shadow.build.targets.karma/configure (karma.clj:23) shadow.build.targets.karma/configure (karma.clj:18) shadow.build.targets.karma/process (karma.clj:115) shadow.build.targets.karma/process (karma.clj:111) clojure.lang.Var.invoke (Var.java:384) shadow.build/process-stage/fn--14115 (build.clj:148) shadow.build/process-stage (build.clj:145) shadow.build/process-stage (build.clj:137) shadow.build/configure (build.clj:358) shadow.build/configure (build.clj:261) shadow.cljs.devtools.api/compile* (api.clj:311) shadow.cljs.devtools.api/compile* (api.clj:308) shadow.cljs.devtools.cli/do-build-command (cli.clj:35) shadow.cljs.devtools.cli/do-build-command (cli.clj:26) shadow.cljs.devtools.cli/do-build-commands (cli.clj:51) shadow.cljs.devtools.cli/do-build-commands (cli.clj:40) shadow.cljs.devtools.cli/main/body-fn--16982--auto----17573 (cli.clj:168) shadow.cljs.devtools.cli/main (cli.clj:167) shadow.cljs.devtools.cli/main (cli.clj:134) clojure.core/apply (core.clj:669) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli/-main (cli.clj:221) shadow.cljs.devtools.cli/-main (cli.clj:219) clojure.lang.Var.invoke (Var.java:393) user/eval152 (form-init10054527494778132590.clj:1) user/eval152 (form-init10054527494778132590.clj:1) clojure.lang.Compiler.eval (Compiler.java:7177) clojure.lang.Compiler.eval (Compiler.java:7167) clojure.lang.Compiler.load (Compiler.java:7636) clojure.lang.Compiler.loadFile (Compiler.java:7574) clojure.main/load-script (main.clj:475) clojure.main/init-opt (main.clj:477) clojure.main/init-opt (main.clj:477) clojure.main/initialize (main.clj:508) clojure.main/null-opt (main.clj:542) clojure.main/null-opt (main.clj:539) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)Googling didn't help much. Is this a known issue or should I file a bug report?
karma.conf.js, etc):output-to is not optional for :karma builds, and the NPE indeed points to that being the case (https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L23)output-to argument.(def ^js aws (js/require "aws-sdk")) (defn my-handler ... (let [ses (aws.SES.)] ...which on runtime errors out with
"TypeError: wn.ld is not a constructor".
Using shadow-cljs' simple externs, I can get it to work by simply adding the string "`SES`" to externs/my-build.txt, but I'd really like to get it working using typehinting.
So far, I've tried:
(let [ses ^js (aws.SES.) ...and
(let [ses (new ^js aws.SES)but to no avail
;; ~/.clojure/deps.edn
{:deps {nrepl/nrepl {:mvn/version "0.7.0-alpha3"}
cider/cider-nrepl {:mvn/version "0.23.0-SNAPSHOT"}
refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"}}}
;; ~/.nrepl
{:middleware [refactor-nrepl.middleware/wrap-refactor]}(:require ["aws-sdk" :as aws]) in your ns and then (aws/SES.) that should take care of it[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (style.css, line 0) [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.js, line 0) [Error] Refused to execute as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type. [Error] ReferenceError: Can't find variable: goog Global Code (0.0.0.0:14)
{:dependencies
[[org.clojure/core.async "0.4.490"]
[com.stuartsierra/component "0.4.0"]
[environ "1.1.0"]
[ch.qos.logback/logback-classic "1.2.3"]
[org.clojure/tools.logging "0.4.1"]
[ring/ring-core "1.7.1"]
[ring/ring-defaults "0.3.2"]
[compojure "1.6.1"]
[http-kit "2.4.0-alpha2"]
[com.taoensso/sente "1.13.1"]
#_[com.cognitect/transit-clj "0.8.313"]
#_[com.cognitect/transit-cljs "0.8.256"]
[org.clojure/tools.namespace "0.3.0-alpha4"]
[reagent "0.8.1"]
[org.webjars/bootstrap "4.2.1"]]
:source-paths
["src" "dev" "resources/public"]
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/public/js"
:modules {:main {:entries []}}}}}:asset-path looks incorrect. the server is likely using resources/public as a root? or probably should be?"resources", I get rid of the 404 errors. But now shadow-cljs shows a “Stale client” error.nil for any ( …) calls.shadow-cljs run?watch.:dev-http? or a http config in :devtools?user.clj that starts it?(run) as part of the jack-in. This is how the template is wired. I had forgotten about that part…create-cljs-app?$ npx create-cljs-project acme-app is pretty much all I have used since making it:browser.
(defn foo [i]
(throw (ex-info "hello" {:a 1})))
I can't get a meaningful stacktrace for this code, but I can get one for this
(defn foo [i] (throw (js/Error. "hello")))
ex-info.main.js:2218 failed to load fullstack_explore.app.js Error
at Object.fullstack_explore$app$foo [as foo] (app.cljs:6)
at eval (app.cljs:8)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2216)
at main.js:2396
And this is the error for ex-info
failed to load fullstack_explore.app.js #error {:message "", :data {}}
env.evalLoad @ main.js:2218
(anonymous) @ main.js:2396(defn foo [] (throw ...)) (foo)The code looks like this, nothing more.
(defn foo [] (throw ...)) (defn ^:dev/after-load test-me [] (foo))
ex-info becomes much longerjs/Error.(defn foo [] (throw (ex-info "foo" {:x 1})))
(js/setTimeout foo 1000):devtools {:loader-mode :script}speced.def use ex-info for it's error.:loader-mode?:loader-mode :script it works correctly.:stack.:loader-mode :script is basically what other CLJS does:loader-mode :eval (the default) loads things differently and thus may change the stacktraceex-info, error reporting will become drastically worse, if the error happened on load.
Needless to say there are many cljs libs that can throw a ex-info at any point. i.e. this is not specific to my library.
@ thheller - are you 100% sure this is not something shadow-cljs can handle?
Otherwise, it'd seem worth it to create an issue in the cljs compiler, or such.:devtools {:loader-mode :script} in your build configCmd + R if my program was so broken that it threw an exception on init.
Maybe worth considering - document :script and :eval? Would be nice if programmers were aware of these tradeoffs upfront.
At the same time, the root of the problem seems to lie in the js/Error <-> ex-info difference. By intution, there shouldn't be one. Would be interesting to determine what component is at fault (shadow, the compiler, etc)js/Error until it had a change to load the source maps and stuff(defn init [] (js/setTimeout foo 0))(foo) directly. or whatever you are doing:init-fn call which is the LAST thing during load time(defn init [] (js/setTimeout foo 0)) is interesting, however I can't/shouldn't control how consumers of my library structure their applications
Documenting this intricacy seems far leaner/cleaner than suggesting workarounds or doing a best-effort approach to replacing ex-info -> js/Error everywhere. Don't you agree?js/setTimeout.js/Error.eval then:script loader-mode.:script doesn't eval .. so makes senseTextField from Material-UI. I am requiring using following code
(:require ["@material-ui/core/TextField" :default TextField])However the symbol
TextField is undefined and it shows following error:
TypeError: Cannot read property 'default' of undefined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:55)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
Please could you help me to figure this out.shadow-cljs browser-repl and (require '["@material-ui/core/TextField" :as x]) then x or (js/console.dir x) or so:default:default should work thoughx it outputs this:
== JS EXCEPTION ============================== ENCODING FAILED, check host console ==============================================
(remove [:a :b] #{:a})(js/console.dir x) or (js/console.log x)(js/console.dir x) it returns nil .nil in the developer tools js console?:default works for meObject
default: [Exception: TypeError: Cannot read property 'default' of undefined at Object.get [as default] (node_modules/@material-ui/core/TextField/index.js:1:336) at Object.invokeGetter (<anonymous>:1:142)]
__esModule: true
get default: ƒ ()
length: 0
name: "get"
arguments: null
caller: null
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: index.js:11
[[Scopes]]: Scopes[2]
__proto__: Object
default property(require '["@material-ui/core/TextField" :default TextField]) and TextField should be working fine(require '["@material-ui/core/TextField" :default TextField]) .(ns project.text-field (:require ["@material-ui/core/TextField" :default TextField])) (defn text-field [] (js/console.log TextField) [:div]And the following stacktrace:
isRequired is supposed to be but it might be caused by a dependency conflict. thats not so easy to debug unfortunately. for me it works in an empty test project so that makes dependency conflict more likelyshadow-cljs.edn ?
{:lein true
:source-paths ["src"]
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:app {:entries [psw.core]}}
:devtools {:after-load psw.core/mount-root}}}
:dev-http {3000 {:root "resources/public"
:handler psw.handler/app}}}
I ran npx shadow-cljs release app
please excuse my noobness :)init! fn called? assuming from your HTML somewhere? :modules {:app {:entries [ydfg.core/init!]}}, ? because it causes that:
[markdown-to-hiccup "0.6.2"]
Invalid configuration
-- Spec failed --------------------
{:target ...,
:output-dir ...,
:asset-path ...,
:modules {:app {:entries [ydfg.core/init!]}},
^^^^^^^^^^^^^^^
:devtools ...,
:build-id ...}
should satisfy
unquoted-simple-symbol?
or
string?
{:type :dtd, :data ["html" nil nil]}init! fn in psw.corepsw.handler/app emits that html?init! if it works in dev mode?:modules {:app {:init-fn psw.core/init!}} in your configInvalid configuration
-- Spec failed --------------------
{:target ...,
:output-dir ...,
:asset-path ...,
:modules {:app {:entries [ydfg.core/init!]}},
^^^^^^^^^^^^^^^
:devtools ...,
:build-id ...}
should satisfy
unquoted-simple-symbol?
or
string?TextField a Material-UI component to use in my project called Orgpad. I have this minimal project here:
https://github.com/vitkalisz/shadow-cljs-materialui.git
where everything works just fine. However when doing the same in Orgpad, I get some ?dependency problem? screenshotted below, which persists even after I reduce the project to a minimal version similar to that in the example. (I am just rendering a TextField , I have commented out every other namespace - leaving just the one rendering the TextField, I have reduced shadow-cljs.edn to this:
{:source-paths ["src"]
:dependencies [[reagent "0.9.0-rc4"]]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:init-fn orgpad.client.core/init}}
:compiler-options {:infer-externs :auto}
:devtools {:after-load orgpad.client.core/mount-root
:watch-dir "resources/public"}}}}
dependencies in package.json to this:
"dependencies": {
"@material-ui/core": "^4.8.0",
"create-react-class": "^15.6.3",
"react": "^16.12.0",
"react-dom": "^16.12.0"
}
I ran npm install, npm clean-install and restarted shadow-cljs) Would somebody please help me figure out why there is this problem?[foo] where foo is nilclojure [:app] Compiling ... IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError clojure.lang.Reflector.getInstanceField (Reflector.java:397) clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440) shadow.build.closure/js-error-xf/fn--11573 (closure.clj:536) clojure.core/map/fn--5862/fn--5863 (core.clj:2742) clojure.core.protocols/iter-reduce (protocols.clj:49) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/transduce (core.clj:6884) clojure.core/into (core.clj:6899) clojure.core/into (core.clj:6887) shadow.build.closure/log-warnings (closure.clj:1081) shadow.build.closure/log-warnings (closure.clj:1077) shadow.build.closure/log-warnings (closure.clj:1079) shadow.build.closure/log-warnings (closure.clj:1077) shadow.build.closure/optimize/fn--11790 (closure.clj:1185) shadow.build.closure/optimize (closure.clj:1170) shadow.build.closure/optimize (closure.clj:1161) shadow.build.api/optimize (api.clj:268) shadow.build.api/optimize (api.clj:262) shadow.build/optimize (build.clj:411) shadow.build/optimize (build.clj:403) shadow.cljs.devtools.api/release* (api.clj:350) shadow.cljs.devtools.api/release* (api.clj:336) shadow.cljs.devtools.cli/do-build-command (cli.clj:29) shadow.cljs.devtools.cli/do-build-command (cli.clj:26) shadow.cljs.devtools.cli/do-build-commands (cli.clj:51) shadow.cljs.devtools.cli/do-build-commands (cli.clj:40) shadow.cljs.devtools.cli/main/body-fn--16106--auto----16696 (cli.clj:168) shadow.cljs.devtools.cli/main (cli.clj:167) shadow.cljs.devtools.cli/main (cli.clj:134) clojure.core/apply (core.clj:669) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli/-main (cli.clj:221) shadow.cljs.devtools.cli/-main (cli.clj:219) clojure.lang.Var.invoke (Var.java:388) user/eval140 (form-init5608872905668697635.clj:1) user/eval140 (form-init5608872905668697635.clj:1) clojure.lang.Compiler.eval (Compiler.java:7177) clojure.lang.Compiler.eval (Compiler.java:7167) clojure.lang.Compiler.load (Compiler.java:7636) clojure.lang.Compiler.loadFile (Compiler.java:7574) clojure.main/load-script (main.clj:475) clojure.main/init-opt (main.clj:477) clojure.main/init-opt (main.clj:477) clojure.main/initialize (main.clj:508) clojure.main/null-opt (main.clj:542) clojure.main/null-opt (main.clj:539) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)```
[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
:dependencies listlein deps :tree and resolve the conflicts:exclusions or adding the proper versions of the dependencies I pasted abovecljs.core/*target* returns “react-native”Unable to resolve module xmlhttprequest from …require is a compile time construct in react-nativejs/XMLHttpRequest at all(js/require "xmlhttprequest") since its done at compile time and it doesn't recognize the conditionalextraNodeModules in metro.config.js seems to have done the trick.The required namespace "goog.date.relative.getPastDateString" is not available, it was required by xxx
(:import [goog.date.relative getPastDateString])
(:require [goog.date.relative :as rel]) (rel/getPastDateString ...)?import Constants from 'expo-constants';
const { version } = Constants.manifest;
On the CLJS side, I wrote my namespace declaration like this:
(:require ["expo-constants" :as expo-constants])But when I try to access
(.-Constants expo-constants), it just returns nil.
I can run (type expo-constants) and it comes up as #object[Object] so it's something, but struggling to figure out how to access it further. Anyone have tips or troubleshooting ideas?:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.83"}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
When I try to execute the alias:
clj -A:shadow-cljs watch appI get the following error:
Error building classpath. Coordinate type not loaded for library :main-opts in coordinate ["-m" "shadow.cljs.devtools.cli"]
Has anyone ran into similar issues?(:require ["expo-constants" :default expo-contants])(.-manifest expo-constants) became immediately accessible after using :defaultclj? you can just run with shadow-cljs watch app if you configure :deps {:aliases [:shadow-cljs]}clj, not shadow-cljs. looks ok to me .. maybe ask in #tools-deps:main-opts is listed as part of the :extra-deps map. its a misplaced }.No such var: ana/unwrap-quote im gonna continue this evening.shadow-cljs watch but now shadow-cljs release is giving me issues. I have two modules with :web-worker true, but I was getting this error:
[:main] Build failure:
Module Entry "shadow.cljs.devtools.client.worker" was moved out of module ":fetch-worker".
It was moved to ":shared" and used by #{:filter-worker :fetch-worker}.
I tried to move :web-worker into :worker-shared, and that builds, but I get "SHADOW_ENV is not defined" when it runs.:modules {:shared {:entries []}
:web-shared {:entries []
:depends-on #{:shared}}
:worker-shared {:entries []
:depends-on #{:shared}
:web-worker true}
:app {:entries [main.gsv.client]
:depends-on #{:web-shared :shared}}
:fetch-worker {:entries [main.gsv.fetch-worker]
:depends-on #{:worker-shared :shared}
}
:filter-worker {:entries [main.gsv.filter-worker]
:depends-on #{:worker-shared :shared}
}}:devtools {:worker-inject false}:worker-inject :worker-shared that might work too:modules or so?:web-worker true on the workers. I think your entire setup isn't actually supported right now:devtools {:browser-inject web-shared} probably:web-worker true on the shared worker stuff:devtools {:worker-inject false} and :web-worker true for both the workers but not the sharedOOO? whats that 😛mkdir app npm init -y npm i react create-react-class react-dom shadow-cljs
npx create-cljs-project app will take care of creating generic boilerplate and some configcreate-cljs-app but it gets a bit heavy with the headless browser it brings alongnpm init but less "full" then create-cljs-app<a href=""> thats invalid, missing https://inspect_client.cljc:279 Uncaught ReferenceError: document is not defined
at $fulcrologic$fulcro$inspect$inspect_client$install
Removed the inspect preload and now getting
browser.cljs:430 Uncaught ReferenceError: window is not defined
at browser.cljs:430(.setAppElement Modal "#app") should not be run at the top level, as it will re-execute on every hot-reload. stuff like that goes into the init fn .. which you confusingly called main 😉:devtools {:browser-inject :web-shared :worker-inject false}shared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined env.evalLoad @ shared.js:3199 (anonymous) @ app.js:1482 shared.js:3199 failed to load goog.crypt.base64.js TypeError: Cannot read property 'SAFARI' of undefined etc..
[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
shadow-cljs.edn ensures that but can't for the othersshared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined
at Object.goog.inherits (shared.js:1931)
at eval (throttle.js:76)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:1817)
at Object.env.evalLoad (shared.js:3197)
at app.js:936
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:936
shared.js:3199 failed to load fulcro.client.network.js TypeError: Cannot read property 'ErrorCode' of undefined
at eval (network.cljc:24)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:1817)
at Object.env.evalLoad (shared.js:3197)
at app.js:960
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:960
shared.js:3199 failed to load fulcro.client.primitives.js TypeError: goog.async.Throttle.base is not a function
etc..console.warning but sound like serious errors.shared.js:2 Uncaught ReferenceError: $jscomp is not defined
at shared.js:2
at shared.js:1
Which I think is warned about with:
File: /Users/baruchberger/work/gsv/src/main/gsv/api/createIterable.js:89:8
--------------------------------------------------------------------------------
86 | if (prop === 'length') {
87 | return length;
88 | }
89 | if (prop === Symbol.iterator) {
--------------^-----------------------------------------------------------------
variable $jscomp is undeclared
--------------------------------------------------------------------------------
90 | return iterator;
91 | }
92 | return source[prop];
93 | }
--------------------------------------------------------------------------------:compiler-options {:output-feature-set :es6}:web-shared {... :prepend-js "window.$jscomp = {};"} .. there is an option issue about this I think. still need to dig into the closure compiler to figure out why this happensjs/window seems to be undefined. So many errors compared to earlier, did the closure compiler suddenly get a lot more strict or something?:compiler-options {:output-wrapper false}shadow-cljs compile for now.(ns my-ns
(:require
["some-npm-module" :as module]))
And my-ns and "some-npm-module" are never required by any other ns, "some-npm-module" will not be included in the output?forceUpdate on the wrapper. Can anyone shed light on that? See the following code for reference. Thanks.
https://github.com/eihli/cljs-react-native-starter/blob/1e7721b9d82b0a2163fb83f03534c341e5a59a77/src/example/core.cljs
(defn make-reloader [comp]
(let [comp-ref (atom comp)
;; ...
(rn/AppRegistry.registerComponent "ExampleApp" (fn [] wrapper))
(fn [comp]
(when-let [wrapper @wrapper-ref]
;; Why do we need to reset the component here?
;; Why doesn't calling forceUpdate on the parent-most component
;; cause everything to re-render?
;; Is there a downside to doing it this way? Is there an alternative?
(reset! comp-ref comp)
(.forceUpdate @wrapper-ref)))))reagent function that requires a real dom?
(defn ^:dev/after-load start []
;; dummy prop that always changes
(reagent/render [ui {:x (js/Date.now)}] dom-root))clojure -Sdeps '{:mvn/local-repo ".m2"}'
I can't seem to find it.npx shadow-cljs compile ci-tests
I don't want to permanently change it.clojure -Sdeps '{:mvn/local-repo ".m2"} -m shadow.cljs.devtools.cli compile ci-tests~/clojure/deps.edn on the CI systemrender-root there and the following? Through my surface-level testing and current understanding, they appear to function the same.
(defn make-reloader [comp]
(let [comp-ref (reagent/atom comp)
wrapper (reagent/create-class
{:render
(fn []
(let [comp @comp-ref]
(if (fn? comp) (comp) comp)))})]
(rn/AppRegistry.registerComponent "ExampleApp" (fn [] wrapper))
(fn [comp]
(reset! comp-ref comp))))shadow-cljs run (or something else similar) of running clj-kondo like the lein/tools.deps example in https://github.com/borkdude/clj-kondo/blob/master/doc/jvm.md?shadow-cljs server (or shadow-cljs watch) is running the startup will be much faster["highcharts/highcharts" :as highcharts]. I'm then importing the histogram module like this ["highcharts/modules/histogram-bellcurve" :as histogram]. There is some issue with how I'm using the histogram module that I'd like to debug. When clicking an item in a stacktrace in the browser that points to some code in the histogram module, I get minified code. Is there a way to use the non-minified code for development and switch to the minified in production?["highcharts/modules/histogram-bellcurve.src" :as histogram] got me the source.(ns example
(:require
["highcharts/highcharts" :as highcharts]
["highcharts/modules/histogram-bellcurve" :as histogram]))
(histogram highcharts)
However, if I do that, I will get an exception saying e is not a function. It's pretty useless because the file is minified. So I switch the histogram require to point to the source JS file: ["highcharts/modules/histogram-bellcurve.src" :as histogram] . After running the code, I get an exception giving me more info: "correctFloat is not a function". This "correctFloat" function is provided by some Utilities module.
I end up changing the highcharts require to ["highcharts/highcharts.src" :as highcharts] in hopes I get some more information. After changing the require, everything works! Using the highcharts/highcharts results in a function missing. Any idea why this would happen and whether this is a shadow issue or a highcharts issue?_registerModule(_modules, 'modules/bellcurve.src.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js'], _modules['mixins/derived-series.js']], function (H, U, derivedSeriesMixin) {
var correctFloat = U.correctFloat,
I don't entirely know what this means but it appears that it is trying to lookup the correctFloat function at the path ["_modules"]["parts/Utilities.js"]["correctFloat"]. If I try to lookup that path in the browser console,
compute.ui.components.highcharts.h._modules["parts/Utilities.js"].correctFloat => undefinedI can, however, find other functions at that path
compute.ui.components.highcharts.h._modules["parts/Utilities.js"].arrayMax => fn
correctFloat is entirely missing from the place the histogram-bellcurve module is looking for it. Could this be because it was DCE'ed? I thought shadow doesn't do that with npm modules. Or perhaps it's a highcharts issue?correctFloat being assigned to r: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L584. Line 116 has the definition for r: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L116. This function definitely exists in the code base then.
Line 51 you can see it is defined within the parts/Utilities.js module: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L51correctFloat function is removed.<script src="https://code.highcharts.com/highcharts.js"></script>to my index.html and set
:js-options {:resolve {"highcharts/highcharts" {:target :global
:global "Highcharts"}}}
in shadow-cljs.edn. After doing so, things work as expected. It would seem like shadow is removing that function for some reason. Is there a way to fix this?highcharts/highcharts.src work in development and results in a minified version in production. I guess I'll go with that for now. This was quite confusing.["highcharts/highcharts" :as highcharts]? the docs would suggest that ["highcharts" :as highcharts] would be the correct on to use?devtools.core. if you need it you add it to your build config :devtools {:preloads [devtools.preload]}["@material-ui/core/TextField" :default TextField]We get the following error in the console:
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$SelectInput
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$Select @ Select.js:21
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$Select
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$TextField
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$index
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:75 Uncaught TypeError: Cannot read property 'isRequired' of undefined
at Object.shadow$provide.module$node_modules$$material_ui$core$Select$SelectInput (SelectInput.js:453)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$Select$Select (Select.js:21)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$Select$index (index.js:16)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$TextField (TextField.js:37)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$index (index.js:16)
at Object.shadow.js.jsRequire (js.js:66)
It was suggested that the problem is with a conflict of dependencies. Any ideas how to do debugging?"dependencies": {
"@material-ui/core": "^4.8.0",
"bezier-js": "^2.4.4",
"create-react-class": "^15.6.3",
"deps": "^0.1.2",
"process": "^0.11.10",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-motion": "^0.5.2",
"webfontloader": "^1.6.28"
},prop-types is the problematic packageisRequired is supposed to be coming fromdefault.isRequired and default is undefinednode_modules/@material-ui/core/node_modulesnpm list or something shows all installed packages["rete/build/rete.min.js" :as rete]
watch would work with a :node-script target? I have the following config:
{:target :node-script
:main lambda.serve/main
:output-to "target/local/lambda.js"
:devtools {:before-load-async lambda.serve/stop
:after-load lambda.serve/start}}}}
and in my lambda.serve ns I have:
(defn main [& args] (println "Hello") (js/console.log "Hello") ...etc etc...) (defn start "Hook to start. Also used as a hook for hot code reload." [] (js/console.warn "start called") (main)) (defn stop "Hot code reload hook to shut down resources so hot code reload can work" [done] (js/console.warn "stop called"))
shadow-cljs watch local I’m not seeing any signs in the log that either main, start or stop are being called.(done) so that would break hot-reload too since it'll wait for stop to complete{:source-paths ["src/shared" "src/deploy" "test" "src/local"]
:dependencies [[com.andrewmcveigh/cljs-time "0.4.0"]
[funcool/promesa "4.0.2"]
[appliedscience/js-interop "0.1.21"]
[cljs-bean "1.5.0"]]
:builds {:production
{:target :node-library
:compiler-options {:optimizations :simple}
:output-to "target/production/lambda.js"
:exports {:webhook lambda.webhook/webhook
:buy lambda.buy/pre-auth
:renew lambda.renew/pre-auth
:quote lambda.quote/quote}}
:test
{:target :node-test
:output-to "target/test/node-tests.js"
:autorun true
:ns-regexp "-test$"}
:local
{:target :node-script
:main lambda.serve/main
:output-to "target/local/lambda.js"
:devtools {:before-load-async lambda.serve/stop
:after-load lambda.serve/start}}}}node target/local/lambda.js or something aws or whatever cloud you use?watch it would run the output automatically, so that shadow could reload - is that not the case? Do I have to run it locally using node?deps.edn.
The best way to do this would be via --config-merge, right?(:refer-clojure :rename {get core-get})
In a cljc file and a function named get. The initial compilation is fine but then whenever I reload I get the warning:
get already refers to: cljs.core/get being replaced by: mylib.core/getIs there something else I have to do to prevent this? Is this just a cljs thing unrelated to shadow?
:refer-clojure :exclude [get] instead? you can then refer to it via fully qualified symbol cljs.core/getThe required namespace "goog.dom.query" is not available.(:require ["google-closure-library"]) doesn't fix it(defn text-input [] [:> Text "Some title"]) (defn test-view [title] [:> View [text-input]])But when I move
text-input out into another namespace and edit the text there, I don't see the changes in the app until I manually reload, even though on save a build is triggered and the dev console reports that the ^dev/after-load function is being called.
(defn test-view [title] [:> View [:> Text "Title"] [other-ns/text-input]])I've stopped and restarted
shadow-cljs server, shadow-cljs watch :app , and npx react-native start --reset-cache.
Any ideas on what this might be or how to troubleshoot it?^dev/after-load function doing?(defn ^:dev/after-load start [] (rf/clear-subscription-cache!) (reload views/app-container))
dev/after-load function gets called but the view doesn't refresh. Then, I add a meaningless extra newline at the end of some other file (just so emacs sees a change and allows me to save it) and save it. Then the view that I was trying to hot-reload/hot-refresh actually refreshes.test-view. it didn't change so reagent or react (don't exactly know who is reponsible) stops there.this and then using reagents (force-update @wrapper-this true) to nuke and re-render everything, but that resulted in the same behavior, no update.force-update does. So still have a lot of exploring to do.app-container in it as dev/always(ns ^:dev/always my-app.views ...) (defn app-container ...)
:dev/always, figure out the correct way to fix it instead. always makes everything slower.:locals)
[1] https://github.com/binaryage/dirac/commit/a08d565a2f85072f8157ceafa6f4abd670058476#diff-7acb24e7dee86ee2bb972e97d74a6c92R24failed to load workshop.core.js ReferenceError: $jscomp is not defined
at Object.createComponent (classes.js:8)class you should probably set :compiler-options {:output-feature-set :es6}class?$jscomp is weird though. dunno what that is about:modules?helix.impl = helix.impl || {};
helix.impl.classes = helix.impl.classes || {};goog.provide doeslein new shadow-cljs +re-frame:eval (default) and :script (old one):script technically has 2 modes<script> tags, depending on whether you use <script async src="the-module.js"> or not:eval. never tested.SHADOW_ENV.evalLoad is really running “anonymous” code which is not associated with any source file, so (logically) that source file is not created/tracked in the DevTools - devtools only creates “virtual” cljs files from sourcemap information (orange stuff in devtools resource tree)//# sourceURL= or something instead of just /js/cljs-runtime/foo.bar.js:as and a symbols to the respective ns.
However, I am just not sure how to refer to a a NPM package "firebase-admin" from within my cljs macro.
Two questions:
1. Is there a better way of referring to cljs ns from my macro? Some seem to work and some don't, quick summary on why that is?
2. How do I refer to node packages from a clojure macro? In my case I am attempting to use ["firebase-admin" :as admin], but that does not work within my clj macro namespace.(deftest-function create-example-with-macro-test
sut/create-example-cloudfx
[doc1 "messages/message-1" {"foo" "bar"}
doc2 "messages/message-2" {"foo" "baz"}]
(t/is (not= (.get doc1 "foo") (.get doc1 "foo")))
(t/is (not= "bar" (.get doc1 "foo")))
(t/is (not= "baz" (.get doc2 "foo")))
;; And presumably also testing some side effect of the sut/create-example-cloudfx running
)resolve-var. the common thing I recommend is doing something like (ns foo.bar (:require ["thing" :as x])) (def thing-you-need-in-macro x/foo)foo.bar/thing-you-need-in-macro in the actual macro:default into vanilla cljs analyze it gives me “Only :as, :refer and :rename options supported in :require / :require-macros…”ns parser with one that I wrote. https://github.com/thheller/shadow-cljs/blob/5ee9efcb7cae4ec558227bd04aa9d083c8aefc7c/src/main/shadow/build/compiler.clj#L169yarn link to test some third party library feature that's not pushed to npm yet. Am I right to conclude shadow-cljs doesn't deal with links?~/.config/yarn/...node_modules but still getting
Search in: /Users/baruchberger/work/gsv/node_modules You probably need to run: npm install See:
/Users/baruchberger/work/gsv/node_modules/deck.gl/package.json exist or not?lerna for sub modules.deps.cljs in your source root, and there you can declare NPM deps, example: https://github.com/wilkerlucio/pathom-viz/blob/master/src/core/deps.cljs["/resources/shaders/Backface" :as BackfaceMaterial], shadow-cljs then complains
`
[1] https://github.com/react-spring/react-three-fiber/blob/master/examples/src/resources/shaders/Backface.js.d.ts files are irrelevant. they aren't used in any way.import Three from "three"Three.BackSide in the codeThree.something , because it generates Three.default.something instead of Three.something in jsrequire instead of importconst Three = require("three"); results in similar issue,import * as three from "three" worksmodule.exports = 'foo'; or soimport * as three from "three" works!three object in some global js var in cljs code and access it in the js fileimport *?clojure.lang.KeywordLookupSite$1.
Example 1:
------ WARNING #1 - :invalid-arithmetic ----------------------------------------
File: /home/p-himik/dev/git/ensemble/src/hgs/strayhorn/named_expressions/views.cljs:26:5
--------------------------------------------------------------------------------
23 | (cst/split model ",")
24 | [])))
25 | roman-on-change #(on-change (cst/join "," %))]
26 | (fn [_ & {:keys [error]}]
-----------^--------------------------------------------------------------------
cljs.core/unsafe-bit-and, all arguments must be numbers, got [#object[clojure.lang.KeywordLookupSite$1 0xae194d44 "
Example 2:
------ ERROR ------------------------------------------------------------------- File: jar:file:/home/p-himik/.m2/repository/com/cognitect/transit-cljs/0.8.256/transit-cljs-0.8.256.jar!/cognitect/transit.cljs:295:6 -------------------------------------------------------------------------------- 292 | ([tag-fn rep-fn str-rep-fn] 293 | (write-handler tag-fn rep-fn str-rep-fn nil)) 294 | ([tag-fn rep-fn str-rep-fn verbose-handler-fn] 295 | (reify ------------^------------------------------------------------------------------- Syntax error macroexpanding cljs.core/deftype. ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.IFn clojure.spec.alpha/spec-impl/reify--2059 (alpha.clj:923)Example 3:
------ ERROR -------------------------------------------------------------------
File: /home/p-himik/dev/git/ensemble/src/hgs/ella/score_details/sequences/views.cljs:297:3
--------------------------------------------------------------------------------
294 | :children (mapv (fn [w] [rc/label :label w]) issues)]])
295 |
296 | (defn question-panel [_game-id changeset-id q args]
297 | (let [{:keys [events subs]} args
---------^----------------------------------------------------------------------
Syntax error macroexpanding cljs.core/nil?.
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.IFnunsafe-bit-and.
But the warning about ClassCastException is also mentioned here: https://github.com/thheller/shadow-cljs/issues/443 As well as OpenJ9 (aka AdoptOpenJDK I believe).
I do embed shadow-cljs, but I definitely don't interact with the REPL in any way when these issues occur.(defmacro slurp [file] (clojure.core/slurp (io/file (io/resource file))))
(ns ezmonic.e-data (:require [cljs.reader :as reader]) (:require-macros [ezmonic.util :refer [slurp]])) (defonce data (reader/read-string (slurp "number-to-word-tree.edn")))I'm using that to read a
:require-macros is so ugly 😛(foo.bar.baz)
cljs docs says its supported (https://cljs.github.io/api/syntax/dot), but not sure why i'm receiving use of unresolved var[lib.core :refer [comp]]
and i'm trying to use it like this
(comp.view (comp.text "Hello World"))shadow-cljs classpath and get the classpath but it unfortunately prints out some info that is unnecessary like config, node version, etc. Is there a way to get just the classpath info without any of this extra information?--quiet and for yarn it's --silent.npx shadow-cljs classpath will put the stderr onto std out?npx --help says:
--quiet, -q Suppress output from npx itself. Subcommands will not
be affected. [boolean]shadow-cljs release app[metosin/malli {:git/url ""
:sha "1a1038d2473c6de784252b6ad42a6cc1e764ebcc"}]
How do I do this?[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
deps.edn. shadow-cljs.edn does not currently support them directly.FileWatcher. If a new directory is created with a bunch of files and then removed shortly thereafter, there can be a java.nio.file.NoSuchFileException:
Exception in thread "async-thread-macro-1" java.nio.file.NoSuchFileException: /%python-subdir-within-project%/__pycache__/flow_control.cpython-37.pyc.140019814933808 at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55) at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149) at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99) at java.base/java.nio.file.Files.readAttributes(Files.java:1763) at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225) at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276) at java.base/java.nio.file.FileTreeWalker.next(FileTreeWalker.java:373) at java.base/java.nio.file.Files.walkFileTree(Files.java:2760) at shadow.util.FileWatcher.registerAll(FileWatcher.java:41) at shadow.util.FileWatcher.pollForChanges(FileWatcher.java:114) at shadow.util.FileWatcher.pollForChanges(FileWatcher.java:76) at jdk.internal.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167) at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:438) at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invokeStatic(fs_watch_jvm.clj:17) at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invoke(fs_watch_jvm.clj:16) at clojure.core$map$fn__5866.invoke(core.clj:2753) at clojure.lang.LazySeq.sval(LazySeq.java:42) at clojure.lang.LazySeq.seq(LazySeq.java:51) at clojure.lang.RT.seq(RT.java:535) at clojure.core$seq__5402.invokeStatic(core.clj:137) at clojure.core$apply.invokeStatic(core.clj:660) at clojure.core$mapcat.invokeStatic(core.clj:2783) at clojure.core$mapcat.doInvoke(core.clj:2783) at clojure.lang.RestFn.invoke(RestFn.java:423) at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invokeStatic(fs_watch_jvm.clj:46) at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invoke(fs_watch_jvm.clj:33) at shadow.cljs.devtools.server.fs_watch_jvm$start$fn__73779.invoke(fs_watch_jvm.clj:77) at clojure.core.async$thread_call$fn__34862.invoke(async.clj:484) at clojure.lang.AFn.run(AFn.java:22) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)
shell/sh.Files.walkFileTree is doing its job, there's a chance the whole walk will fail because of it.
I guess somewhat of a fix would be to keep calling Files.walkFileTree until there's no NoSuchFileException.__pycache__?__pycache__ right next to the sources.
I could of course move Python sources out of the classpath altogether. But having them there gives a nice ability to not have to deal with arbitrary paths when some files are shared between CLJ and Python code.src on the classpath. Somewhere in there are both CLJ and Python sources. __pycache__ will be created there as well - not at the top level.Files.walkFileTree. Not sure.shadow.build.classpath/get-classpath-entries? It would leave src in there. And then a FileWatcher would be created for src. And FileWatcher doesn't exclude anything.js/snabbdom without any require for it you can create it by exporting that global variable in a namespace that included before that libjs/snabbdom(ns foo (:require ["test.json" as test-json]))
compiles to SHADOW_IMPORT("module$src$test_json.js");, if I'm reading this correctly. Obviously that can't be found. I was expected this to work according to https://medium.com/technoetics/reading-data-from-json-files-in-react-native-3622744b75e3 saying import sample from '../dbstore/sample1.json'; would work.["./test.json" :as test-json]:resolve {"test.json" {:target :file
:file "src/test.json"}}js/require(def data (js/require "../path-to/file.json")):output-dir:resolve is typically only used in cases where you can't change the code that does the require (eg. in libraries):resolve doesn't give require any new options otherwisemain! and updated my build's :main key to that function I now have a build without errors and running node out/main.js runs the app without error but there's no live reloading I can see shadow is recompiling though^:dev/after-load in shadow-cljsupdate! I was assuming I could change the numbers on the calculator and immediately see that I don't think the update-proxy! thing is updating the react components properlydelete require.cache[require.resolve('./b.js')]:pseudo-names true :pretty-print true on the compiler options)main.js:158 Error: 1
at main.js:3498
at $goog$module$ModuleLoadCallback$$.execute (main.js:17943)
at $JSCompiler_StaticMethods_callCallbacks_$$ (main.js:3444)
at $goog$module$ModuleInfo$$.$APP.$JSCompiler_prototypeAlias$$.onError (main.js:17977)
at $JSCompiler_StaticMethods_dispatchModuleLoadFailed_$$ (main.js:3613)
at $JSCompiler_StaticMethods_requeueBatchOrDispatchFailure_$$ (main.js:3579)
at $goog$module$ModuleManager$$.$APP.$JSCompiler_prototypeAlias$$.$handleLoadError_$ (main.js:18099)
at $JSCompiler_StaticMethods_evaluateCode_$$ (main.js:4227)
at $goog$module$ModuleLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (main.js:18605)
at $JSCompiler_StaticMethods_fireListeners$$ (main.js:3882)shadow-cljs release app --pseudo-names to set those options. don't need to actually put them into the config$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha62946$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$256$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
return $APP.$cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $APP.$cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $APP.$cljs$spec$alpha$op_describe$$(this.$re$));
});TypeError: Cannot read property 'prototype' of ...
1.10.597:compiler-options {:output-wrapper false} in case you are using multiple :modules$APP comes from$cljs$spec$alpha$t_cljs$0spec$0alpha28640$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$322$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
return $cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $cljs$spec$alpha$op_describe$$(this.$re$));
});lein new re-frame foobar so the process to integrade shadow-cljs comes next?cd foobar and npm install npx shadow-cljs watch applein dev but you are going to need npm for react/react-dom anyways so ... 😛lein dev does the trick also.convert-sources-simple* to not remove names from “anonymous” functions, e,g, when passing function myName(…) {} as a callback parameter, google closure rewrites it into function (...) {}, I understand that the name is not needed, but I have a special case where I need it, react devtools use that name for display in component tree:simple mode to transform all stuff required via npm - that is also reason why it is minified (speaking about dev mode):js-options :resolve in this special case and point to raw sources I see in the npm package, but I’m not sure how to specify path in :resolve:js-options takes all the regular :compiler-options. don't know why it removes names, are you sure they aren't already gone when using the npm package? maybe that has minified sources?:resolve only affects where the source comes from, it does not change how it is processed:js-options {:variable-renaming :off}, defaults to :local in :simple:variable-renaming :off didn’t help, it was a good try
btw. I’m always deleting both .shadow-cljs and out directory, just to be sure no caches confuse my results:js-options {:anon-fn-naming-policy :unmapped} helpful, it gives all anonymous functions names of variables/keys which appear immediately before such anon function, in my case it gives them the exact names I want
but I’d like to have option to keep original names and maybe generate a new one only when there is no name in the first place:anon-fn-naming-policy :mapped or :unmapped should prevent the renaming?:optimizations :whitespace?:simple is kind of required but if you don't care about loading extra deps in dev it should be fine:none is not a thing in the closure compiler worldweb.cjs.js fileexamples/node_modules/react-three-fiber/web.js and examples/node_modules/react-three-fiber/web.cjs.js"main": "web.cjs.js", "module": "web.js"
mainreact-three-fiber/web (or any lib):anon-fn-naming-policy :unmapped assings names to anon functions only if there is no previous name(into ["-command" "clojure"] (map powershell-escape) clojure-args)(into ["-command" "clojure"] (map powershell-escape clojure-args))clojure -m shadow.cljs.devtools.cli watch app is identical to shadow-cljs watch appclojure -m shadow.cljs.devtools.cli server onceshadow-cljs as normaldeps.exe and don't have time to look into that right now.js file in my project and have the build process send that file to the output-dir so another tool can pull it in with js/require?
It looks like https://clojurescript.org/reference/dependencies#bundling-javascript-code would be an alternative. If I could do the following, then I wouldn't have to js/require, I could just (:require [my-lib])?
(cljs.build.api/build "src"
{:output-to "out/main.js"
:externs ["yayquery-externs.js"]
:foreign-libs [{:file "yayquery.js"
:provides ["yq"]}]
:optimizations :advanced})
But shadow doesn't work like that? https://shadow-cljs.github.io/docs/UsersGuide.html#publish-deps-cljscljs and do things proper.:foreign-libs is not supported by shadow-cljs and also doesn't do what you asked forrequire and not CLJS directly?gradlew clean before a gradlew buildRelease. And the react-native cli has a react-native run-android --reset-cache . Is it ever necessary to rm -r ouput-dir/ ?
That's kind of the reason I don't generate it straight to the output dir. I clean that directory occasionally and copy the file back over rather than re-generate it into the output dir.required JS dependency "async/series" is not available, it was required by "node_modules/winston/dist/winston/transports/file.js". and the recomendation to run: npm install async/serie When I try to run install it errors out and can’t find the repositories /usr/local/bin/git ls-remote -h -t @github.com/async/series.git it just seems to me that since this is occurring in 3 apparently unrelated instances - except for all using async/series and that it is fine in npm and only shows up in shadow I was thinking it must be trying to do something shadow doesn’t supportnpm install winston and (require '["winston" :as w]) works absolutely fine for measync/series message is a bit wrong. it is the async package which should have been installed when installing winston since it is once of its dependenciesjs/foo.bar_baz get munged with optimizations?foofoojs/cljs.core.assoc or js/goog.string.startsWithfoo.bar_baz and I need to get foo.bar_baz in some CLJS codegobj/get for now until I can refactor this(shadow/nrepl-select :app) selecting app directly from repl:output-wrapper false when updating shadow-cljs from 2.8.67 to 2.8.68 (this release included a commit saying "make `:output-wrapper` for multi-module builds as well")defineProperty on exportemoji-mart(:require [reagent.core :as r] ["emoji-mart/data/all.json" :as emoji-data] ["emoji-mart" :as emoji-mart])
:output-wrapper causing problems is known. dunno about the exports thing, never seen that beforetrue ... but it is also known to fix other problems since making the default true. Can't win with this JS mess 😛➜ new-app npx shadow-cljs node-repl
npx: installed 90 in 2.668s
shadow-cljs - config: /Users/kamuela/Code/new-app/shadow-cljs.edn cli version: 2.8.83 node: v12.14.1
shadow-cljs - connected to server
cljs.user=> no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
SHADOW import error /Users/kamuela/Code/new-app/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
throw e;
^
Error: Cannot find module 'ws'
Require stack:
- /Users/kamuela/Code/new-app/[stdin]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /Users/kamuela/Code/new-app/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
at global.SHADOW_IMPORT ([stdin]:63:44)
at [stdin]:2258:1
at [stdin]:2266:3
at Script.runInThisContext (vm.js:116:20)
at Object.runInThisContext (vm.js:306:38) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/kamuela/Code/new-app/[stdin]' ]
}:shadow-cljs map out of project.clj and into a proper shadow-cljs.edn file and rip out that plugin. The downsides are that you'll have two config files. The upside is that all workflows and documentation will again apply to you. Seems like a steep price to pay to have a single file.lein shadow compile app and it should make a package.json file and a shadow-cljs.edn file. it copies all the deps over it seems instead of just the ones you need so probably prune that down. at that point excise all that junk and just embrace the two systemsTypeError: s.replace is not a function
at Object.clojure$string$replace_all [as replace_all] (karma-test.js:49567:10)
at Object.clojure$string$replace [as replace] (karma-test.js:49626:23)
at Object.shadow$test$karma$indent [as indent] (karma-test.js:82522:23)
at shadow$test$karma$format_log (karma-test.js:82613:214)
at karma-test.js:29716:89
at karma-test.js:29717:3
at Object.sval (karma-test.js:23585:110)
at Object.cljs$core$ISeqable$_seq$arity$1 (karma-test.js:23736:10)
at Object.cljs$core$seq [as seq] (karma-test.js:16711:13)
at karma-test.js:29690:36
The code I added is the following.
(defn summarize-results' [spec-check] (map (fn [x] (pprint/write (stest/abbrev-result x) :stream nil)) spec-check)) (defn check' [spec-check] (is (nil? (-> spec-check first :failure)) (summarize-results' spec-check)))Does anybody have a solution? I already tried to add a "-test" postfix to the namespace the code is in.
message to be a string but isn'tmessage you mean the second argument to is? That makes sense. I copied the code from somewhere but summarize-results' returns a seq not a string. Thank you for your help.is takes a second arg at all 😛shadow-cljs.edn file and then remove lein-shadow entirelyshadow-cljs.edn file nor package.json file. Then i run lein shadow compile app and the plugin generates those files from the project.clj file. At this point you have a normal shadow-cljs.edn file. At this point, remove that plugin and delete the shadow-cljs entry in the project.clj file and pretend like that stuff never happenedcider-jack-in-cljs from the shadow-cljs.edn file and the repl starts up.;; Startup: /home/dan/projects/node/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0 server ;; ;; ClojureScript REPL type: shadow ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
cider-jack-in-clj and then separately cider-jack-in-cljscider-jack-in-cljs seems to work… I selected shadow, then the build, and it’s offering to open a page in the browser that shows active http servers.cider-jack-in-clj├── README.md ├── assets │ └── index.html ├── package.json ├── shadow-cljs.edn ├── src │ └── app │ ├── lib.cljs │ └── main.cljs └── yarn.lockAnd doesn't really explain how you would have gotten there in the first place, do you generally start a new shadow-based CLJS project with an npm-init and install, then include
shadow-cljs.edn and plugin shadow at that point?npx create-cljs-project foobar https://github.com/thheller/shadow-cljs#quick-startcreate-cljs-appcreate-cljs-project path to followfailed to load re_frame.events.js Error: No protocol method IMapEntry.-key defined for type object: [object Object]. The websocket connects and then immediately says that it cannot parse the message. It seems almost that cljs isn't well definedIMapEntry.-key is a common error for libs that used to call key on vectors which used to work but no longer;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[reagent "0.9.1"]
:dev-http {8080 "public"}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn }}}}}
And I get
shadow-cljs - config: /Users/kamuela/Code/acme-app/shadow-cljs.edn cli version: 2.8.83 node: v12.14.1 ===== ERROR ================= reagent is not ISeqable =============================when I try to run
shadow-cljs watch frontend
Top of app.cljs:
(ns :require [reagent.core :as r])
(ns (:require [reagent.core :as r]))
(ns (:require [reagent.core :as r]))
===== ERROR ======= bit comes from the shadow-cljs command line. so not even the compiler:dependencies [[reagent "0.9.1"]]
window.Waypoint = Waypoint. There seems to be no export or anything so when i try to add a require to "waypoints" shadow is recommending me to npm install waypoints which i've already done. Is there a way to "import" this and then use it like js/Waypoint. ?(:require ["waypoints/foo/bar/something.js"]) and then access via js/Waypointwaypoints/lib/noframework.waypoints.min.js
js/Waypoint comes from and doesn't care eitherjs/Waypointshadow-cljs.edn and deps.edn files up one level and that would "magically" fix a lotpackage.json is(defn ^:dev/after-load mount-root []
(re-frame/clear-subscription-cache!)
(reagent/render [views/main-panel]
(.getElementById js/document "app"))):devtools {:after-load } in the build configpackage.json in your project. I assume you want to configure where it looks for actual npm packages and that you can configure per build via :js-options {:js-package-dirs ["addBankAccount/node_modules" ...]}<project>/src/main and then just have it output separate files to <project>/lambdas/foo/... so each lambda can have its own config and stuff in its own folder or .core or whatever namespace that handles all the initialization logic[views/main-panel] so your UI is already separate;; shadow-cljs configuration
{:source-paths
["src"
"test"]
...
:builds
{:dev
{:target :browser
:output-dir "resources/dev/public/js/compiled"
:asset-path "/js/compiled"
:js-options {:variable-renaming :local}
:modules {:app {:init-fn app.core/main}}
:devtools {:http-root "resources/dev/public"
:http-port 3449}}}}
✦ ❯ netstat -tulpn | rg LISTEN 09:35:16(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 1313/puma 3.12.1 (t tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN - tcp6 0 0 127.0.0.1:36585 :::* LISTEN 472/java tcp6 0 0 127.0.0.1:35625 :::* LISTEN 472/java tcp6 0 0 :::5355 :::* LISTEN - tcp6 0 0 :::44179 :::* LISTEN 472/java tcp6 0 0 ::1:3000 :::* LISTEN 1313/puma 3.12.1 (t tcp6 0 0 :::3449 :::* LISTEN 472/java tcp6 0 0 :::3451 :::* LISTEN 472/java tcp6 0 0 :::9630 :::* LISTEN 472/java
tcp6 0 0 :::3449 :::* LISTEN 472/java?*. (for info on https://readme.localtest.me/). And when I try to connect to shadow-cljs on Windows from it can't find it. I'm trying to debug this and see if it's because it's not listening specifically on 0.0.0.0. The thought that led me down that path is because a rails webserver listening on port 3000 and bound to 0.0.0.0 is able to be reached by on Windows.:: and 0.0.0.0 behaves the same on WSL. IE They're both accessible from . However, in WSL2 (which is what I run) only 0.0.0.0 is accessible from . So it looks like WSL2 is not correctly handling :: .
Thanks again, talking to someone else running WSL really helped narrow this down.localhost:8080 but not cljs.analyzer/warning:karma target wouldn't actually include any tests?ns-regexp is unset, and I have tests in the test directory (which is on source-paths) with -test$test was in the source-paths in shadow-cljs.edn but not in deps.edn:deps true in your shadow-cljs.edn then the source-paths and dependencies will be completely ignored in that filereact-native-web to react-nativelinkify npm module via cljsjs in a figwheel project.
I’m trying to convert it over to shadow-cljs and for the life of me, I can’t figure out how to get the syntax of the require correct.
In the GitHub repo, the instructions are: https://github.com/SoapBox/linkifyjs/
var linkify = require('linkifyjs');
require('linkifyjs/plugins/hashtag')(linkify); // optional
var linkifyHtml = require('linkifyjs/html');
So, following the instructions, I tried this:
(:require
["linkifyjs" :as l]
["linkifyjs/hmtl" :s lh])
But I keep getting errors like:
The required JS dependency "linkifyjs/hmtl" is not available, it was required by "trello_workflow/io.cljs". Search in: /Users/genekim/src.local/trello-workflow/node_modules You probably need to run: npm install linkifyjs/hmtl See:How does one get access to the
linkifyHtml function?
Many thanks in advance! And keep up all the great work, @thheller!!!goog.string.linkify library in Google Closure, but wow, their SafeHtml classes are way too effective — I couldn’t replicate all my dangerous hacks I was using! 🙂lh => #object[Function] (lh "") => "<a href=\"\" class=\"linkified\" target=\"_blank\"></a>"Thank you so much!!! 🎉 🎉 🎉 🎉
expo and react-native for the web target?expo can use react-native-web to target the web but in shadow-cljs the build target react-native . I try to use a target web for react-native-web without expo but not work for the moment because of ui-kitten.shadow-cljs<latest> placeholder with "LATEST". It seems that in Maven 3, both "RELEASE" and "LATEST" are missing: https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution
The maven-resolver-api that's used by tools.deps still seems to support "RELEASE" though, but I cannot find any specific information about it.npm install thing actually got rightshadow-cljs find-versions reagent or something like that some dayshadow-cljs add-dep reagent or something like that. :)
But that asks for a different project. Or maybe a PR for depot.:deps map. Although it may require hooking into the EDN parser or even writing your own to know exactly where that } is (never tried or even read about rewrite-clj, no idea here).
I'd argue that it would be enough for the vast majority of cases. And for the rest, the user can always fix the file manually, especially when using any VCS. The heavy lifting of getting the version and putting the coordinates into the file has already been done.
But even just printing out the coordinates is much better than nothing, that's for sure.34 files changed, 185 insertions(+), 1965 deletions(-)[:app] Build failure:
------ ERROR -------------------------------------------------------------------
File: /Users/jeeq/Documents/rnproj/src/js/rnproj/home.js:6:5
--------------------------------------------------------------------------------
3 |
4 | function Home(props) {
5 | return (
6 | <Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
-----------^--------------------------------------------------------------------
primary expression expected
--------------------------------------------------------------------------------
7 | <G clipPath="url(#prefix__clip0)">
8 | <Path
9 | d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
10 | fill="#546BFB"
--------------------------------------------------------------------------------
It seems to be able to find the js file but not parsing it correctly. I have a line in my :require, [“./home” :as svghome :refer (Home)]
home.js is svg converted to “appropriate” format by tool linked by react-native-svg (https://svgr.now.sh/)
import React from "react";
import Svg, { G, Path, Defs, ClipPath } from "react-native-svg";
function Home(props) {
return (
<Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
<G clipPath="url(#prefix__clip0)">
<Path
d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
fill="#546BFB"
/>
</G>
<Defs>
<ClipPath id="prefix__clip0">
<Path fill="#fff" d="M0 0h16v16H0z" />
</ClipPath>
</Defs>
</Svg>
);
}
export default Home;
ns is going to be reloaded in start fn call in runner-ns?
Currently start would run whole test suite, but i’d like to run tests from recompiled ns only. I tried using build-hooks for that which is getting build-state object. Idea was to store recompiled ns somewhere in global var and then use it in runner-ns start fn.------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/robert/.m2/repository/org/clojure/clojurescript/1.10.597/clojurescript-1.10.597.jar!/cljs/core.cljs:999:14 -------------------------------------------------------------------------------- 996 | (if (js/isFinite o) 997 | (js-mod (Math/floor o) 2147483647) 998 | (case o 999 | ##Inf --------------------^----------------------------------------------------------- No reader function for tag Inf -------------------------------------------------------------------------------- 1000 | 2146435072 1001 | ##-Inf 1002 | -1048576 1003 | 2146959360)) --------------------------------------------------------------------------------
org.clojure/tools.reader 1.1.0` at least, but i've checked, i have org.clojure/tools.reader 1.3.2 on the classpath (according to clj -Stree )-Stree with all the aliases active you'd have active for cljs?org.clojure/clojurescript 1.10.597 and org.clojure/tools.reader 1.3.2clj (with the aliases) and then ( "clojure/tools/reader.clj") (require first)user=> ( "clojure/tools/reader.clj") #object[.URL 0x1c7fd41f "jar:file:/Users/robert/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar!/clojure/tools/reader.clj"]
{:app {:devtools {:preloads [shadow.remote.runtime.cljs.browser
When i run shadow-cljs watch app it tells me the shadow.remote.runtime.cljs.browser ns isn't available. I'm not sure what else to try.( "clojure/tools/reader__init.class")#object[.URL 0x49872d67 "jar:file:/Users/robert/.m2/repository/com/datomic/datomic-pro/0.9.6021/datomic-pro-0.9.6021.jar!/clojure/tools/reader__init.class"]:override-deps {datomic false} or so?The required namespace "clojure.datafy" is not available, it was required by "shadow/remote/runtime/shared.cljc". "clojure/datafy.clj" was found on the classpath. Should this be a .cljs file?Sorry. Ill just come back to this later. Im probably missing something obvious
1.10.597;;; fn invoke
{:standardDeviation 0.023446214753117665, :bindings "[val (rand)]", :maximum 1, :total 11, :expr "(simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00055}
{:standardDeviation 0.027376540573065246, :bindings "[val (rand)]", :maximum 1, :total 15, :expr "(simple-fn-indirect simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00075}
{:standardDeviation 0.029143094653764887, :bindings "[val (rand)]", :maximum 1, :total 17, :expr "(simple-fn-indirect-hinted simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00085}import React from "react";
function myComponent() {
return <h1>JSX!</h1>;
}
export { myComponent };
when I conver this jsx to js with babel as in the docs I get error message about shadow.js.shim… not being provided:
Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault
construct
[native code]:0
_construct
construct.js:30:26
Wrapper
wrapNativeSuper.js:26:23
SyntheticError
index.bundle?platform=ios&dev=true&minify=false&hot=false:31652:111
handleException
ExceptionsManager.js:111:31
handleError
setUpErrorHandling.js:23:40
ErrorUtils.setGlobalHandler$argument_0
ErrorRecovery.fx.js:8:32
tryCatch
runtime.js:45:44
invoke
runtime.js:271:30
tryCatch
runtime.js:45:44
invoke
runtime.js:135:28
Promise.resolve.then$argument_0
runtime.js:145:19
tryCallOne
core.js:37:14
setImmediate$argument_0
core.js:123:25
_callTimer
JSTimers.js:146:14
_callImmediatesPass
JSTimers.js:194:17
callImmediates
JSTimers.js:458:30
callImmediates
[native code]:0
flushedQueue
[native code]:0
invokeCallbackAndReturnFlushedQueue
[native code]:0
Without the import line and if I just set to return a simple number (i.e. return 2;) I’m able to use the exported module. It just seems to be confused when trying to import any modules.
Any pointers?babel --plugins @babel/plugin-transform-react-jsx src/js --out-dir src/gen
ns and instead do (def thing (js/require "../path/to/home.js"))var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", { value: true });
exports.myComponent = myComponent;
var _react = _interopRequireDefault(require("react"));
function myComponent() {
return 8;
}
This is the output from babeldeps.edn and putting the files in a git repo or local folderdeps.edn:source-paths or use lein install and add the dependency/code/project-a/src and /code/the-library/srcproject-a/shadow.cljs.edn you put :source-paths ["src", "../the-library/src"]deps.ednReferenceError: SHA-1 for file …/assets/logo.png (…/assets/logo.png) is not computed:output-dir used in the build configlein-shadow, What’s the recommended process to build the CLJS part of the uberjar?shadow-cljs release appshadow-cljs release app && lein uberjar. Two steps you need to do: compile your js and build a jar. how you get there is straight forward. if lein can just shell out you can do that. otherwise, ensure the build is present and then uberjar as normal. check the jar that your stuff is there and then never worry about this again.
├── clj
├── cljs
│ ├── client
│ │ └── exercises
│ └── test
│ └── client
├── gen
│ └── client
└── ts
└── client
I need to require something from gen/client in the client.exercises.two namespace. I tried every variant of "./file", "./file.js", "/client/file", "client/file" and so on I can think of.
My shadow-cljs.edn's :source-paths is ["src/cljs" "src/clj" "src/gen"]. I'm probably making an obvious mistake, but can somebody point it out for me?client.exercises.two namespace you are in the /client/exercises/two.cljs file so ../file.js or /client/file.js should work. (extension is required. not optional)The required JS dependency "../boxes.js" is not available, it was required by "client/exercises/two.cljs".or
The required JS dependency "/client/boxes.js" is not available, it was required by "client/exercises/two.cljs".There is definitely a file named boxes.js in the right location.
gen
└── client
└── boxes.js
Is there anything else I could have gotten wrong?project-A depend on the source files of another shadow-cljs project-B?
I am facing the need to create a custom build of a ReactJS component,
to pack it into a stand-alone project would add up to granularity, seemed like a good idea..
However, 'project B' has node dependencies and when
project-A/deps.edn
{:deps {project-B {:local/root <path-to-project-B>}}}
project-A$ yarn => Installed dependencies of Project-A project-A$ shadow-cljs watch dev => The required JS dependency <a-dependency-of-Project-B> is not available => Searched in:/<path-to-projects>/project-A/node_modules
deps.cljs in your source path that includes {:npm-deps {"the-npm-dep" "version"}}function hello() {
console.log("Hello World from TypeScript!");
}
Should I report a bug?:lein true then :source-paths in shadow-cljs.edn has no effect whatsoever and you need to configure it in project.clj insteadimport React from "react";
var MyComponent = function MyComponent(_ref) {
var key = _ref.key;
console.log('child props', key);
return React.createElement(
"li",
{ key: key },
"Hello JSX!"
);
};
var MyDefaultComponent = function MyDefaultComponent(_ref2) {
var children = _ref2.children;
return React.createElement(
"div",
null,
React.createElement(
"h1",
null,
"Hello JSX!"
),
React.createElement(
"ul",
null,
children
)
);
};
export { MyComponent };
export default MyDefaultComponent;
import * as React from "react";shadow-cljs release app with version 2.8.69, in an app that works fine in dev mode with hot-reloading, but I’m getting this error:IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
const logo = require('../../media/logo.svg'); and then use logo as html (e.g. in React's dangerouslySetInnerHTML={{ __html: logo }). What to people do in Cljs / shadow? I guess it is not supported to require a non-cljs resource. Thank you!shadow.resource/inline not mentioned there or have failed to search well?
Perhaps "Table 1. ES6 Import to CLJS Require " could be extended to point to a description of this as people use in JS import/require for non-code resources?
Or add a section between 12.2 and 12.3 (12.25 :)) called "Embedding resources from files"?require('../../media/logo.svg') pattern is something from webpack and not supported by shadow-cljs in any wayinline stuff can be used to inline svg but that only works for svgsshadow-cljs release app && lein uberjar would be my recommendation. I really don't see the point lein doing everything but some people prefer that.~/d/b/bank1 ❯❯❯ shadow-cljs release app ⏎ master ✱ shadow-cljs - config: /Users/jmckitrick/devel/bank/bank1/shadow-cljs.edn cli version: 2.8.69 node: v13.7.0 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app NPM version conflict for "react" in deps.cljs (will use A) A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs NPM version conflict for "react-dom" in deps.cljs (will use A) A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs [:app] Compiling ... IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
lein. so YOU must ensure that the shadow-cljs version in project.clj gets the matching closure-compiler version it expects.69.lein there…:lein is configured in shadow-cljs.edn it will use lein to run thingslein trueshadow-cljs watch app everything works just fine, but when i run shadow-cljs release app and try to open index.html or push the code to my github page, I get this js error : Error: No matching clause: . At first I thought that the app.js generated by the release command was faulty, but it seems to work just fine when i run it with a http server (lite-server). In all case the code is loaded just fine. It's just really confusing. What am I missing?shadow-cljs release app --pseudo-names or shadow-cljs release app --debug (to get source maps). should be easier to tell where it fails then:target :browser live in :build-defaults?The resource from "" was blocked due to MIME type ("text/html") mismatch (X-Content-Type-Options: nosniff).shadow.user=> (shadow/repl :app) null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:536). Assert failed: (symbol? read-ns)
{:prepl {:app 5555}} in shadow-cljs. I can connect to the prepl-server and it works fine. however, if I have a prepl-server running, and then connect to the socket-server, then I get the error I posted (`null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:536).`):socket-repl {:port 1234}?react/createElement. I cannot do that in my macro because compiler complains (I guess due to that “react” is not normal namespace, it is coming from npm, with normal namespaces this normally works). When I create some alias (def my-create-element react/createElement) and emit my-ns/my-create-element instead. All works, but release build suffers from generating dynamic arity dispatch. Even if I specify explicit fixed arity (defn my-create-element [x] (react/createElement x)) it does not get inlined in advanced mode (verified with --pseudo-names).
Any ideas, how could I reference react/createElement in my macro directly? js/React.createElement does not work. “React” is not avail at runtime due to way how shadow isolates npm modules (?)window.reactCreateElement=$APP.vl.createElement I need a way how to reference that $APP.vl (react npm import in my macro)(def ^function my-create-element react/createElement) is possible and the compiler will always emit a direct function call in instead of the usual my_create_element.ifn1 ? ...^function as well?[:app] Compiling ...------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared --------------------------------------------------------------------------------
[com.cognitect/transit-clj "0.8.319"] I get a warning that it was ignored, and still see the above error.The required namespace "carcalc.core" is not available. I think I must have some stupid mistake somewhere but can't find it.. Does anyone see what's wrong with this repo? https://github.com/dakra/carcalc:source-path should be :souce-paths(shadow/repl :app) and then type in cljs commands, but is it possible to evaluate a single cljs form through Shadow’s API without interacting with the cljs REPL? Thanks!(shadow/eval-cljs :my-build-id '(js/console.log "Hello world")) would be awesome(shadow/eval-cljs :my-build-id '(foo/bar "Hello world"))foo (if its an alias)(shadow/eval-cljs :my-build-id '(foo ::bar)) would also turn ::bar into :user/bar (or whatever CLJ ns you are currently in)(shadow/eval-cljs :my-build-id "(js/console.log \"Hello world\")")Retrieving reagent/reagent/0.9.1/reagent-0.9.1.pom from Retrieving cljsjs/react/16.9.0-1/react-16.9.0-1.pom from Retrieving cljsjs/react-dom/16.9.0-1/react-dom-16.9.0-1.pom from Retrieving cljsjs/react-dom-server/16.9.0-1/react-dom-server-16.9.0-1.pom from Retrieving re-frame/re-frame/0.11.0/re-frame-0.11.0.pom from Retrieving reagent/reagent/0.9.1/reagent-0.9.1.jar from Retrieving cljsjs/react-dom-server/16.9.0-1/react-dom-server-16.9.0-1.jar from Retrieving cljsjs/react-dom/16.9.0-1/react-dom-16.9.0-1.jar from Retrieving cljsjs/react/16.9.0-1/react-16.9.0-1.jar from Retrieving re-frame/re-frame/0.11.0/re-frame-0.11.0.jar from
shadow-cljs classpath?"" =
{
host = repositories.maven;
path =
"args4j/args4j/2.33/args4j-2.33";
type = "jar";
pom = {
sha1 = "168b592340292d4410a1d000bb7fa7144967fc12";
sha256 = "046pab6gz1bh6w1jfbabgxvkrnvncrj93lnmaya5qs6a1z7mccn2";
};
jar = {
sha1 = "bd87a75374a6d6523de82fef51fc3cfe9baf9fc9";
sha256 = "1mlyqrqyhijwkjx4sv2zfn2ciqfwpc08qq8w55rcxb941fxfmpci";
};
};:lein set in shadow-cljs.edn)?lein with-profile prod cljsbuild once
_lein_cmd='yarn app:compile:android'
_repo_path=$(mktemp -d)
function filter() {
sed -E "s;Retrieving ([^ ]+)\.(pom|jar) from $1.*;$2\1;"
}
echo "Computing maven dependencies with \`$_lein_cmd\`..." > /dev/stderr
trap "rm -rf ${_repo_path}; [ -f ${_project_file_name}.bak ] && mv -f ${_project_file_name}.bak ${_project_file_name}" HUP ERR EXIT INT
cd $GIT_ROOT
# Add a :local-repo entry to project.clj so that we always start with a clean repo
sed -i'.bak' -E "s|(:license \{)|:local-repo \"$_repo_path\" \1|" ${_project_file_name}
rm -rf ./${_repo_path}
$_lein_cmd 2>&1 \
| grep Retrieving \
| filter clojars \
| filter central # NOTE: We could use `lein pom` to figure out the repository names and URLs so they're not hardcoded.shadow-cljs/classpath.edn:maven {:local-repo "local-m2"} and keep the <project>/local-m2 files in git[:dev] Build failure: ------ ERROR ------------------------------------------------------------------- File: /Users/lilactown/Code/helix/src/helix/hooks.cljc:115:41 -------------------------------------------------------------------------------- 112 | (cond 113 | ;; warn on typical errors 114 | (and (= (count body) 1) (symbol? (first body))) 115 | (do (hana/warn ::hana/simple-body env) -----------------------------------------------^-------------------------------- helix/hooks.cljc [line 115, col 41] Invalid keyword: ::hana/simple-body. -------------------------------------------------------------------------------- 116 | nil) 117 | 118 | ;; deps are passed in as a vector 119 | (vector? deps) (deps->hook-body `(cljs.core/arraythis is in a
:clj reader-conditional, and the hana namespace alias does exist in clojure (but not cljs).cljc files I’m assuming?(comment ::foo/bar) Syntax error reading source at (REPL:1:19). Invalid token: ::foo/bar
hana . I can evaluate ::hana/foo using a REPL.cljc file where I have not required/aliased that namespace in the CLJS portion, which is why it can’t be read$ clj test.cljc
Exception in thread "main" Syntax error reading source at (/mnt/c/Users/thheller/code/tmp/test.cljc:3:31).
at clojure.lang.Compiler.load(Compiler.java:7642)
at clojure.lang.Compiler.loadFile(Compiler.java:7573)
at clojure.main$load_script.invokeStatic(main.clj:452)
at clojure.main$script_opt.invokeStatic(main.clj:512)
at clojure.main$script_opt.invoke(main.clj:507)
at clojure.main$main.invokeStatic(main.clj:598)
at clojure.main$main.doInvoke(main.clj:561)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Invalid token: ::str/foo$ cat test.cljc #?(:clj ::foo :cljs ::str/foo)
.jsonp has a breaking change — it no longer takes a uri, but now it takes a TrustedResourceUrl.
This breaks the cljs-http / jsonp library call. I’ve created a new patched version of jsonp that creates a TrustedResourceUrl, but…
But it just hit me — seems like there should be a code path for the older versions of Google Closure http://goog.net, and one for the newer versions — how does one determine what version of the Closure compiler is being used? 🤔
Or to broaden the question, how do we tell which data structure to pass the jsonp function — a Uri or TrustedResourceUrl?
Thank you!.versionconstant or something…
I’ll keep exploring #3. Maybe ask in another channel, too…prototype! I’ll run with that idea, and see if I can make it work.
PS: I was really “excited” to discover that Closure compiler generates compile time errors in “release mode” when attempting to do unsafe things. I actually really like static typing, although at times like this, I sure do love the escape hatches!! 😂
I appreciate the potential irony and logical inconsistency. 🙂i18n library that can integrate with hx ?npx shadow-cljs server and then start two separate npx shadow-cljs watch :app1 and npx shadow-cljs watch :app2 with different class paths?:devtools {:ignore-warnings true} which seems to match the user guide, but it still won’t hot reload[:builds :app :devtools]I18nPlugin (replace translation on compile time) with shadow-cljs?:js-options :resolve currently isn’t supported when building for react-native target - is there a reason it’s not supported?cljsjs/react dependency. During the build, shadow compiler fails with “react dependency is missing” so i’d like to resolve it with :js-options {:resolve {"react" {:target :global :global "React"}} as i’m adding react.js to the page via another script(:require [react ...]) so not (:require ["react" ...]):react-native build won't actually use it .. but it will make the error go awaybrowser target. We have multiple targets in out config. For react-native target, we still want shadow to pull js dependency code from external file, similar to what cljs compiler option :foreign-libs does https://cljs.github.io/api/compiler-options/foreign-libs
Also, library doing (:require [react]) is reagent as it depends on cljsjs/react (not react from node_modules).(:require [react]) works fine in shadow-cljs IF node_modules/react exists:js-resolve to pick react from a global, coming from somewhere else(:require [react]) it'll first check if thats a regular CLJS namespacenode_modules/react:js-package-dirs:js-package-dirs option, it looks like that what i want. I basically want to point to the dir where to get “react” dependency from when building for react-native:target did you use?:browser:browser build via https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report:js-provider :require in which case it is all electron providing the dependencies):js-provider :requireprocess.env.NODE_ENV but I'm not sure how you'd set itshadow-cljs that declares a global variable at the top? I required it (using an absolute path), but that does not cause this variable to be available via js/Var — is this expected? Is there a better way?@octocat/rest work from NPM? it seems to depend on a Node-only package, but somehow authors also produce a release for Web without this dependency)var Octokit = ...; — no AMD, not a ES6 package, so I'm at loss how to use it except <script> in HTML and use the global.npm install @octokit/rest and (:require ["@octokit/rest" :as x]) what does that give you?The required JS dependency "os" is not available, it was required by "node_modules/os-name/index.js""os-name" is a transitive dependency of @octokit/rest:browsernpm install shadow-cljs in the project should fix itos is one of those packages that needs a polyfill for the browsershadow-cljs globally, and only reluctantly says "yes, you can install it local and use npx":node-test target combined with watch that makes me wonder if i’ve missed something basic. i have
:test
{:target :node-test
:output-to "out/node-tests.js"
:autorun true}
and i run npx shadow-cljs watch script test. but when i change a file, it seems like only a subset of my tests are automatically run. if i explcitly do node out/node-tests.js then they all run.
what am i doing wrong?(:require ["@aws-amplify/api" :refer [graphqlOperation] :default API]
["@aws-amplify/pubsub" :default PubSub]
["/graphql/mutations" :refer [createTodo]]
["/graphql/queries" :refer [listTodos]]
["/graphql/subscriptions" :refer [onCreateTodo]]
["/aws-exports" :default awsconfig] ;; Important Diff, no period
[applied-science.js-interop :as j])
Local directory has src/graphql generated and corresponding js files (queries, mutations). The following require throws an error:
The required JS dependency "/graphql/mutations" is not available, it was required by "app.cljs".
What am I missing?src in :source-paths?(shadow/reload-deps!) but it returns :shadow.cljs.devtools.api/standalone-only and is doing nothingnpx shadow-cljs node-repl from the terminal and received this message. It appears to indicate I need to install the ws module. This is all that's in my package.json
{
"name": "spec1-select",
"dependencies": {},
"devDependencies": {
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cljs-test": "0.1.0",
"shadow-cljs": "2.8.83"
}
}cljs.user=> Failed to read: clojure.lang.ExceptionInfo: Input/output error {:type :reader-exception, :line 1, :column 1, :file "repl-input.cljs"}
That will only stop when I ctrl+c again.{:target :chrome-extension}) and trying to set up some functions in a user.cljc file to help me switch between the REPLs hosted by the background and content scripts. I have the logic figured out (using (shadow/repl-runtime-select ...)) , but the UX still isn't clean for a few reasons:
1. The base Clojure REPL loads shadow.user instead of my user ns
2. Shadow doesn't seem to load my user ns on initial compile into either the CLJ or CLJS REPLs (perhaps because nothing depends on it?)
Is there a way to configure Shadow to load my user ns automatically in all of the REPLs (the default Clojure behavior)?
Can I query the CLJS runtime from within? (similarly to the way shadow.cljs.devtools.api works from the base Clojure REPL):devtools {:repl-init-ns some.ns} per builduser ns, I get this error
(enter-content-script-repl)
no source by provide: user
{:provide user}
ExceptionInfo: no source by provide: user
shadow.build.data/get-source-id-by-provide (data.clj:184)
shadow.build.data/get-source-id-by-provide (data.clj:181)
shadow.build.data/get-source-by-provide (data.clj:187)
shadow.build.data/get-source-by-provide (data.clj:186)
shadow.cljs.repl/repl-compile/fn--14867/fn--14868 (repl.clj:453)
shadow.cljs.repl/repl-compile/fn--14867 (repl.clj:429)
shadow.cljs.repl/repl-compile (repl.clj:427)
shadow.cljs.repl/repl-compile (repl.clj:424)
shadow.cljs.repl/process-read-result (repl.clj:515)
shadow.cljs.repl/process-read-result (repl.clj:491)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:844)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:798)
shadow.cljs.devtools.server.worker.impl/eval15787/fn--15788 (impl.clj:879)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325/fn--15333 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--15324 (util.clj:257)
java.lang.Thread.run (Thread.java:830)enter-content-script-repl is a CLJC fn and has a CLJS portion that works fine once I manually load the ns.:init-ns isn't part of the actual build:devtools {:preloads [the-repl-init-ns] :init-ns the-repl-init-ns}2.8.83:preloads trick worked. Everything's nice and clean now. Would you like me to file an issue that :repl-init-ns should imply that the ns gets loaded?:repl {:init-ns user} at the top leveluberjar task, the payload built by shadow in target/cljsbuild is being deleted. I’ve disabled :clean-targets in my project file, but it’s still happening.:output-dir "resources/public/js so something like that in the shadow-cljs build configresources into the uberjar (or configured via :resources-paths)/js/main.js or whatever your files are namedrm -rf resources/public/js && shadow-cljs release app && lein uberjar(:require ["/graphql/mutations"]) why does shadow throw a The required JS dependency "/graphql/mutations" is not available ..." when the source path is set to src and it contains src/graphql/mutations.js?source-path is set to src and deps in deps.edn, in shadow-cljs. In deps.edn the paths var is set to src.println the same thing after page refresh it did when I loaded the extension in chrome. What could be wrong?^:dev/after-load is indeed reloaded, but not in the init function.(defn ^:dev/after-load reloaded [] (println "The content script was reloaded!")) (defn init [] (reloaded))After changing the string in the
reloaded function, the new string is printed in the console of the page. But when I reload the page after that, the old string gets printed.:module-hash-names true to the shadow-cljs config helped with that.reloaded fn and inspect the callstack:chrome-extension I pretty much have the background page working (modulo some issue with the test-storage function).
But the biggest problem is I can't figure out how to configure shadow-cljs to properly hook in the extension popup. I was just guessing it was related to the :browser-action but my guess is clearly not working. I am still pretty unwashed when it comes to cljs / shadow-cljs and chrome extensions.
My attempt at this is at https://github.com/omnyway-labs/chromex-sample-shadow. The README details the issues.
If anyone has any helpful hints, I would be greatly appreciated. It seems pretty close and once this is made to work, it could be a good template for building chrome extensions with shadow-cljs.{:type :client/stale} . Even when I ssh into the container and curl it directly:
$ curl 'localhost:9630/ws/worker/dev/ac9d0f31-11a6-4c6b-9c75-a6f6a5ed1756/8dcdadc5-c951-4188-9c08-c5881f658fe7/browser' -H 'Accept: */*' --compressed -H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Extensions: permessage-deflate' -H 'Sec-WebSocket-Key: kC/iKKLLhR2/TcOVtWVO7Q==' -H 'Connection: keep-alive, Upgrade' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade: websocket'
{:type :client/stale}
Not sure what to poke next to troubleshoot. Thanks!shadow-cljs watch dev directly on my machine. So something about the container environment is keeping it from seeing and/or reporting fresh compilations.:client/state means that the js files you loaded in your HTML were not produced by the watch you started. so I'm guessing you are serving old files or have some cache enabled that serves them(not= proc-id (:proc-id worker-proc))
(send-ws-error :client/stale):output-dir and make sure that is the actual files you are serving--pseudo-names:
https://gist.github.com/darwin/a2ce8ee9079f78842f62e9e89dfc6615#file-popup-js-L96
$chromex$ext$runtime$connect_STAR_$$ is missing:chrome-extension :target:
https://github.com/binaryage/chromex/tree/master/examples/shadow
https://github.com/binaryage/chromex/blob/master/examples/shadow/shadow-cljs.edn#L23shared.js in the output-dirchrome-extension://…/something.map URLs`net::ERR_UNKNOWN_URL_SCHEME looks like coming from C++(js/chrome.runtime.reload)?code should be possible solutionjs/chrome.runtime.reload and it is not a good solution
it blows extension state, including background page and othersdo-js-reload and on content script init replay all reloads since last extension reload(defn refresh-source []
(let [this-file
{:resource-id [:shadow.build.classpath/resource "ext/content.cljs"]
:module :content-script :ns 'ext.content
:output-name "ext.content.js"
:resource-name "ext/content.cljs"
:type :cljs
:provides #{'ext.content}
:warnings []
:from-jar nil}]
(shadow.browser/handle-build-complete
{:info {:sources [this-file] :compiled #{(:resource-id this-file)}}
:reload-info {:never-load #{} :always-load #{}
:after-load
[{:fn-sym 'ext.content/loaded
:fn-str "ext.content.loaded"}]}})))content.cljs is the name of the content script file, loaded is the function that you want to run when the content script loads (not necessary to add any tags to it).:js with fresh source codeError: Namespace "..." already declared.:chrome-ext build was commented outcontent.cljs, reload the page, "▶️❤️◀️" will still be printed instead of a new string.FROM circleci/clojure:openjdk-11-tools-deps-1.10.0.414-nodeseems to be an ok start..
Uncaught ReferenceError: window is not defined and I guess it is because it tries to load /shadow/cljs/devtools/client/browser.cljs instead of /shadow/cljs/devtools/client/worker.cljs.{:base {:entries [cljs.core]}
:mod {:entries [my.ns]
:depends-on #{:base}}
:worker {:entries [my.ns.worker]
:depends-on #{:base}
:web-worker true}}:devtools {:browser-inject :mod}npm install <folder>: Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If <folder> sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.
🠶?goog-define some constant in some namespace ns.a and use it in another ns.b? This doesn't seem to work if I require the ns.a from ns.bantd package. Antizer pulls the antd package
in through cljsjs, which causes bloat in my local development environment due to the size of the antd package.
My thought was to change antizer to use shadow-cljs so we can target specific elements of the package, rather than importing the whole thing. We don’t know what the user would like to import, so I’m stuck on how to conditionally require parts of antd from antizer.
One way I can think to handle this is to create a different file for each Antizer import that maps directly to an antd import. Ex:
antizier.Button => antd/Button and then requiring the relevent element from antizier.
Another way (that I think would work?) would potentially be to keep track of each distinct element that is called in antizier and calling (require) for each.
Does anyone know of a better way to handle this?(require) is a macro that only works in development:source-map-prefix could be helpful for some future ad-hoc workarounds in similar cases when I want source maps to be server independentlyjs/fetch to get the files from dev-server running on localhost, and it workedchrome.runtime.getURL("out/content-script.js")chrome.runtime.getURL?Unknown at the top (from NativeRunnable.java, not very helpful)npm install, but I can't say for certain. The build still works after updates on my boxreact-native init AwesomeProject and update the PR after I'm up tomorrowrun shadow.cljs.build-report app target/build-report.html
Illegal character ((CTRL-CHAR, code 0)): only regular white space (\r, \n, \t) is allowed between tokens
file: .shadow-cljs/builds/app-release-snapshot/release/shadow-js/module$node_modules$object_assign$index.jsnode_modules/object_assign/index.js with hex editor, does it contain any zero bytes?re-frisk-remote working for a react-native app that I build using a shadow-cljs with deps managed in a deps.edn file. Since there is no leiningen involved I’m not sure how to start the the web (i.e. lein re-frisk). So I guess I make my own ‘plugin’ for tools.deps to get an equivalent server running? Probably the wrong channel to ask, though.re-frame-10x would work for you?re-frame based applications. re-frame is based around a single central app-db and re-frisk/re-frisk-remote can be used to trace and inspect the content of this db. The leinigen plugin spins up a web-server on the dev machine to provide the UI for traceing/inspecting the remote db. https://github.com/flexsurfer/re-frisktap> re-frame’s app database. I will try to find some time to make the server component of re-frisk-remote standalone so I can use it with shadow-cljs and tools.deps.goog-define some constant in some namespace ns.a and use it in another ns.b? This doesn't seem to work if I require the ns.a from ns.b(goog-define THING "foo") is the same as (def THING "foo"). so you'd refer to it like any other def using a/DEBUG (assuming (:require [ns.a :as a])).native or .web extensions
or do you have to create completely different namespaces for each platform?feature.web.js feature.ios.js and a single import statement into the app import feature from 'feature':build-options {:ns-aliases {some.app.feature some.app.feature-web}}some.app.feature it would end up using some.app.feature-web instead(:require [some.app.feature :as x]) would actually be (:require [some.app.feature-web :as x]):build-defaults {:build-options ...} would apply it to all configured builds yesextensions: ['.web.js,' '.js'](ns some.app.feature-web)analyticsanalytics and then a file called segment so analytics.segmentanalytics object but the two are basically in a race to get to the window spot first correct?:devtools {:loader-mode :script} in the build configCompiling ... Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:582). com.google.common.collect.Streamsupon
shadow-cljs compile appwatch, but then it magically got fixed by calling compile once.clj -Stree (remember to enable all aliases you might have)npm install --save firebase:backend and :web with almost all deps defined within the alias (`:extra-deps`) and the source directories in :extra-paths. You can put common deps or shared sources in the top level :paths and :deps.
In shadow-cljs.edn :
:deps {:aliases [:web]}
works for me and plays along nicely with Cursive IDE in IntelliJ IDEA. (hint: in cursive you need to enable your aliases in the deps panel).:deps and then a :cljs alias on top that inherits all the CLJ deps?:extra-deps for CLJS:deps []:extra-deps in the aliases.project.clj file before that just included ALL dependencies but wasn't actually used for anythingrum then?:dependencies [[rum "whatever-version"]] in shadow-cljs.ednrum show up in clj deps too? e.g. "for server-side rendering". or should I dep it both in shadow and in deps.edn? as rum is cljc libshadow-cljs.edn to declare CLJS dependencies and then deps.edn or project.clj for CLJ. yes there may be some overlap and things declared in both but that is not an issuedeps.edn with a :cljs alias and a :clj alias with a common :shared oneclj -Stree once and see which guava version you get and from whatimport Highcharts from 'highcharts/highstock'I can confirm that it's working at https://stackblitz.com/edit/react-4ded5d?file=index.js (at least, in Firefox). The table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages says that anything that looks like
import defaultExport from "module-name"; should be written as (:require ["module-name" :default defaultExport]).
I required this:
["highcharts/highstock" :as Highcharts-as] ["highcharts/highstock" :default Highcharts-default]In runtime,
Highcharts-as is the desired object, and Highcharts-default is undefined.
Any idea why is there a discrepancy for this particular module?* to that table? Otherwise, it's not that clear that there are exceptions if you don't read further since the table appears like the ultimate authority.:default works even for CommonJS packages* or some other indication that a user should read further about :default in particular. :) Seems like I'm not the only one that doesn't read/remember everything, given the question about Highcharts in #clojurescript["@elastic/eui" :as eui]?reagent-playground with a bunch of sources:
;; a.cljs
(ns reagent-playground.a
(:require [reagent-playground.b :refer [f] :rename {f b-f}]))
(defn f [])
(js/console.log "A F" f)
;; b.cljs
(ns reagent-playground.b)
(defn f [])
;; core.cljs
(ns reagent-playground.core
(:require [reagent-playground.a :as a]))
(js/console.log "A F2" a/f)
The JS console output is:
a.cljs:6 A F fnreagent-playground$a$f[] core.cljs:5 A F2 undefined
a/f works inside a, but outside suddenly becomes undefined. It can be fixed by not requiring that b namespace along with :rename.watch a release build? debugging advanced-comp issues:optimizations `:advanced` on the dev buildfind src | entr shadow-cljs ...http://entrproject.org
node_modules to test some stuff I’m stuck with some shadow-cljs - failed to load errors. package.json and package-lock.json are the same so I’m a little confused what could be causing this.node_modules files while a watch is running. it may not fully recover from that an may require a resatrtmodule$node_modules$$firebase$firestore$dist$index_cjs
components.home.js TypeError: client.util.adapt_class is not a function
client.util.js TypeError: firebase.INTERNAL.registerComponent is not a function
:optimizations does not apply to watch builds as it always forces :none. for debugging I suggest running shadow-cljs server and then shadow-cljs release app --pseudo-names or --debug whenever you make a changegit ls-files | entr shadow-cljs release app --psuedo-namesserver anyway 😂:compiler-options {:source-map true}. Meanwhile, they are used with watch.
Did I not add some flag?(shadow.cljs.devtools.api/repl :app) manually, any better way to do it?(alter-var-root! shadow.build.warnings/*color* (constantly false)).cider-connect-clj&cljs to connect to shadow's nrepl serviceshadow-cljs watch and trigger an exception in the browser, the stacktrace shows correct CLJS files, and I can open them in the browser.
If I use shadow-cljs release, the stacktrace shows minified files. Of course, I cannot use shadow-cljs built-in debug server for this (I think), so I use python -m http.server in the directory with index.html..map file is created and that the .js file has a //# sourceMappingUrl ... at the bottom.map is there. And the sourceMappingUrl is there as well. In fact, the Python server shows that the source map is downloaded by the browser. But it's not used for some reason.Uncaught Error: Button clicked
at main.js:593
at Object.da (react-dom.production.min.js:17)
at Oa (react-dom.production.min.js:18)
at ub (react-dom.production.min.js:18)
at wa (react-dom.production.min.js:18)
at vb (react-dom.production.min.js:20)
at O (react-dom.production.min.js:20)
at P (react-dom.production.min.js:20)
at Mi (react-dom.production.min.js:82)
at ig (react-dom.production.min.js:289)
With the debug build, it results in the correct core.cljs file being mentioned with the correct line.start function - same deal.main.js in the exception printout.:init-fninit no longer exists and just directly throws at the top level<script>reagent_playground.core.init();</script>
init-fn call NEVER has source mapsinit-fn.script tag above works. Meaning, the ^:export works. Meaning, the core/init function is not inlined anywhere.(start) with just the exception.
This is what I have in CLJS:
(defn ^:export init [] (throw (js/Error. "Hi there")))And this is what it ends up as in the compiled JS:
function Xf() {
throw Error("Hi there");
}
init ...setTimeout.cljs.core. But that's definitely not the case.(defn do-bad-stuff [stuff] (throw (js/Error. stuff))) (defn ^:export init [] (.setTimeout js/window #(do-bad-stuff "From setTimeout 0") 0) (.setTimeout js/window #(do-bad-stuff "From setTimeout 100") 100))
(defn do-bad-stuff [delay] (.setTimeout js/window #(do-bad-stuff (+ delay 1000)) delay) (throw (js/Error. delay))) (defn ^:export init [] (do-bad-stuff 0))compiled as this
var ca = function ca(a) {
window.setTimeout(function () {
var c = a + 1E3;
return ca.a ? ca.a(c) : ca.call(null, c)
}, a);
throw Error(a);
};
function ia() {
return ca(0)
}
and outputting this
Uncaught Error: 0
at ca (main.js:4821)
at Object.ia [as init] (main.js:4825)
at (index):14
So it somehow became worse.(defn do-bad-stuff [delay]
(.setTimeout js/window
(fn []
(do-bad-stuff (+ delay 1000))
(throw (js/Error. delay)))
delay))
(defn ^:export init []
(do-bad-stuff 0))
var ca = function ca(a) {
return window.setTimeout(function () {
var c = a + 1E3;
ca.a ? ca.a(c) : ca.call(null, c);
throw Error(a);
}, a)
};
function ia() {
return ca(0)
}
Uncaught Error: 0
at core.cljs:10374init
- Still wrong location["highcharts/highstock" :as Highcharts] ["highcharts-react-official" :default HighchartsReact]and it works fine, but without the no data label, how should I include this file?
["highcharts/module/no-data-to-display"]I get > Compilation failed! > The required JS dependency “highcharts/module/no-data-to-display” is not available, it was required by “fund_performance/stockchart.cljs”. > > Search in: > /Users/wvelezva/dev/workspace/fund-performance/node_modules > You probably need to run: > npm install highcharts/module/no-data-to-display > > See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install
{:credits {:enabled false}
:title ""
:rangeSelector {:buttonPosition {:x -200}} ;;to hide the zoom buttons but letting the input dates visible
:legend {:enabled true}
:lang {:noData "There are no data to display or there are any Fund Selected"}
:noData {:style {:fontWeight "bold"
:fontSize "15px"
:color "#303030"}}
:plotOptions {:series {:showInLegend true
:events {:click #(.log js/console (str "p= " (.. % -point -x) " sn=" (.. % -point -series -name)))}}}
:tooltip {:pointFormat "{series.name}: <b>{point.y:.1f}%</b>"}
:series [{:type "line"
:name "Random data"
:data []}]}:lang {:noData "There are no data to display or there are any Fund Selected"}
clj->js), then it looks fine to me.
Does your data work in a pure JS environment?require or import. The also call the imported function on the Highcharts object.["highcharts/modules/no-data-to-display" :as no-data-module]
And call (no-data-module Highcharts) somewhere at the top level or in init.require('highcharts/modules/exporting')(Highcharts)
:content-scripts [{:css ["re-frame-modal.css"]}]
and
:content-scripts {:css ["re-frame-modal.css"]}
neither produced manifest.json that was accepted by chrome extension loading. I could manually set the manifest.json and that would work.
Could you show me what you put in the manifest.edn to get the css file to be accepted? Thanks:web-accessible-resources ["assets/content-style.css"]
:content-scripts [{:css ["assets/content-style.css"] :matches ["<all_urls>"]}]require the necessary packages
["react-dnd" :refer [DragDropContext DropTarget DragSource DragLayer]]with the following build failure
[:app] Build failure: The required JS dependency "domain" is not available, it was required by "node_modules/@react-dnd/asap/dist/cjs/node/raw.js". Search in: /Users/josh/src/rodeorockstar/genpoetry/node_modules You probably need to run: npm install domaini've also manually added domain
yarn add domain and tried to require it directly with the same error message as aboveFailed reading cache for theta.log: failed to require macro-ns "theta.log", it was required by "theta.log"The file is like:
(ns theta.log #?(:cljs (:require-macros [theta.log]))This just started. Is this a cache problem?
:web-worker configuration work for node_modules? (I have a package that expected me to configure a worker loader w webpack so wondering if that's possible with shadow-cljs)(deftest failing-async-test
(t/async done
(let [e (ex-info "foo" {})
p1 (p/promise e)]
(p/catch p1 (fn [x]
(t/is (= :a x))
(throw (ex-info "test" {}))
(done))))))Exception in thread "async-dispatch-4" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583) at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575) at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980) at shadow.undertow$fn$reify__15877$fn__15997.invoke(undertow.clj:322) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29) at clojure.lang.AFn.run(AFn.java:22) at java.lang.Thread.run(Thread.java:748) [:app] Compiling ... [:app] Build completed. (1064 files, 1 compiled, 0 warnings, 6.11s) ^CRunning shutdown hook. shutting down ...
Exception in thread "async-dispatch-2" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583) at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575) at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980) at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2931.invoke(ioc_macros.clj:991) at clojure.core.async.impl.channels.ManyToManyChannel$fn__680.invoke(channels.clj:265) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29) at clojure.lang.AFn.run(AFn.java:22) at java.lang.Thread.run(Thread.java:748) Exception in thread "async-dispatch-5" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583) at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575) at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984) at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980) at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2931.invoke(ioc_macros.clj:991) at clojure.core.async.impl.channels.ManyToManyChannel$fn__680.invoke(channels.clj:265) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29) at clojure.lang.AFn.run(AFn.java:22) at java.lang.Thread.run(Thread.java:748)
require :reload or something while the watch was running?:aot false in the shadow-cljs.edn?:web-worker is intended for standalone use only (no further processing)shadow-cljs watch app unit-tests I get these warnings in the JS console:
DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: ... DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: DevTools failed to parse SourceMap:The same problem was there before I made the unit-tests build, so I’m wondering why this even shows up. There is otherwise no mention of devtools in my setup. shadow-cljs.edn:
{:deps {:aliases [:shadow-cljs :testing]}
:dev-http {8000 "classpath:public"}
:nrepl {:port 9000
:init-ns dev}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "js"
:modules {:main {:init-fn user/start-dev}}}
:unit-tests {:target :browser-test
:test-dir "resources/public/js/test"
:devtools {:http-port 8001
:http-root "resources/public/js/test"}}}}
deps.edn
{:paths ["src" "resources"]
:deps {org.clojure/clojurescript {:mvn/version "1.10.597"}
reagent {:mvn/version "0.9.1"}
hickory {:mvn/version "0.7.1"}}
:aliases {:testing {:extra-paths ["test"]}
:shadow-cljs {:extra-paths ["dev/src"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.83"}}}}}shadow-cljs.edn or simply only running the app build, just breaks the unit-tests build and doesn’t mute the warnings anyway.:output-dir "resources/public/js/compiled" and classpath:public meaning that the files are accessed via /js/compiled/... but you have :asset-path "js" which likely should be /js/compiled if you have any kind of client side routing:asset-path "/js/compiled"did the trick
Error in phase :compilation.:deps true in shaodow, are there any issues with using local dependencies using :local/root ? It seems to not be recognizing macro namepsaces in the local dependenciesError in phase :compilation error, without a stacktrace."proj/ns.clj" was found on the classpath. Should this be a .cljs file?shadow-cljs - connected to server [:test] Compiling ... ------ ERROR ------------------------------------------------------------------- File: /path/to/frontend_test.cljs Error in phase :compilation -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Anyways, it took me until today to find find an excuse to dig into this during work hours. But I found out that Java uses ipv6 by default and converts ipv4 addresses to their ipv6 equivalents. Ex 0.0.0.0 -> ::1
So if you're like me and need to force shadow-cljs to use an ipv4 binding you can set it as an option in env vars export _JAVA_OPTIONS="-.preferIPv4Stack=true"
https://superuser.com/questions/453298/how-to-force-java-to-use-ipv4-instead-ipv6:jvm-opts ["-.preferIPv4Stack=true"] in shadow-cljs.edn (or deps.edn/project.clj)(ns editor.main
(:require [reagent.core :as r]
[clojure.string :as str]
["codemirror" :as codemirror]
["codemirror/mode/clojure/clojure"]
["codemirror/addon/edit/matchbrackets"]
["codemirror/addon/hint/show-hint"]
[shadow.resource :as rc]
[cljs.reader :as edn]))@material-ui/icons ?
I have a weird error when I import:
["@material-ui/icons/Menu" :default menu-icon] => Module not provided: module$node_modules$$material_ui$icons$MenuThe module exists on path
node_modules/@material-ui/icons/Menu.js@material-ui/icons - you have to import it separately@material-ui/icons is imported separately. Works with @material-ui/icons/esm/Menu$ shadow-cljs watch app
shadow-cljs - config: /home/.../shadow-cljs.edn cli version: 2.8.83 node: v12.3.1
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch appshadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:69:5).
at clojure.lang.Compiler.analyzeSeq(Compiler.java:7115)
at clojure.lang.Compiler.analyze(Compiler.java:6789)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:7095)
at clojure.lang.Compiler.analyze(Compiler.java:6789)
at clojure.lang.Compiler.analyze(Compiler.java:6745)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3888)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:7109)
...
...
Caused by: java.lang.NoSuchFieldException: getRegisteredGroups
at java.base/java.lang.Class.getField(Class.java:1999)
at clojure.lang.Compiler$StaticFieldExpr.<init>(Compiler.java:1284)
at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:1006)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:7107)
... 188 moreshadow-cljs.edn for dependencies .. then you don't have to worry about such things[org.clojure/clojurescript "1.10.597"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]lein deps :tree will likely tell younpx shadow-cljs start, I get this in my error log:
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:69:5).Followed by a massive stacktrace that - at least to me - doesn't contain anything useful in determining what the error is. How might I go about figuring out what the issue is? I'm not terribly familiar with build tools and it might very well be a simple error in my config files, but I don't know how to determine that.
(defproject prj "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url ""}
:dependencies [[org.clojure/clojure "1.10.0"]
[com.fulcrologic/fulcro "3.0.1"]]
:main ^:skip-aot sheluchin.client
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
:dev {:source-paths ["src/prj/"]
:dependencies [[org.clojure/clojurescript "1.10.520"]
[thheller/shadow-cljs "2.8.83"]
[binaryage/devtools "0.9.10"]]}})
; [cider/piggieback "0.4.1"]]}})
; [fulcrologic/fulcro-spec "3.1.4"]
; [com.fulcrologic/guardrails "0.0.9"]]}})[org.clojure/clojurescript "1.10.597"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]:after-load/:before-load per module?The required JS dependency "web3" is not available, it was required by "cljsjs/web3.cljs".
Search in:
/Users/jfleury/Documents/Git/multis-interview/node_modules
You probably need to run:
npm install web3
I'm stuck on this, as when I run "npm install web3", it works, but package.json keeps being rewritten by the command lein-shadow - running shadow-cljs... somehow... I don't understand how to add a js package to project.clj... Can anyone help me on that ?lein-shadow parts since I don't recommend using it(:require ["web3" :as web3]) or whatever the actual package name is(defproject xxx "lein-git-inject/version"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.597"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[thheller/shadow-cljs "2.8.83"]
[reagent "0.9.1"]
[binaryage/devtools "0.9.10"]
[clj-commons/secretary "1.2.4"]
[re-frame "0.11.0"]
[day8.re-frame/tracing "0.5.3"]
[day8.re-frame/test "0.1.5"]
[day8.re-frame/re-frame-10x "0.5.2"]
[cljs-web3 "0.19.0-0-11"]
[district0x.re-frame/web3-fx "1.0.5"]]
:plugins [[day8/lein-git-inject "0.0.11"]
[lein-shadow "0.1.7"]
[lein-shell "0.5.0"]]
:middleware [leiningen.git-inject/middleware]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
;"package.json"
;"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn xxx.core/main
:preloads [day8.re-frame-10x.preload]}}
:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame-10x.debug? true
day8.re-frame.tracing.trace-enabled? true}}
:devtools {:http-root "resources/public"
:http-port 8280}}
:karma-test {:target :karma
:ns-regexp "-test$"
:output-to "target/karma-test.js"
:compiler-options {:pretty-print true
:closure-defines {re-frame.trace.trace-enabled? true}}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]
"test-once" ["do"
["clean"]
["shadow" "compile" "karma-test"]
["shell" "karma" "start" "--single-run" "--reporters" "junit,dots"]]
"test-auto" ["do"
["clean"]
["shadow" "watch" "karma-test"]]
"karma-watch" ["shell" "karma" "start" "--reporters" "junit,dots"]})shadow-cljs.edn and package.json for CLJS and not using lein-shadowshadow-cljs.ednnpm install shadow-cljs in the projectnpx shadow-cljs watch clientshadow-cljs.edn from the :clean-targets. otherwise lein will delete it:shadow-cljs stuff as well. basically what the plugin does is copy that to shadow-cljs.edn{:source-paths
["src/cljc/"
"src/cljs/"
"test/cljs/"]
:dependencies
[[reagent "0.9.0-rc1"]
[cider/cider-nrepl "0.22.0-beta8"]]
:nrepl
{:port 8202}
:builds {:dev {:target :browser
:modules {:main
{:entries [my-app.frontend]
:depends-on #{:cljs-base}}
:tracker
{:entries [my-app.tracker]
:depends-on #{:cljs-base}}
:cljs-base
{:entries []}}
:output-dir "resources/public/assets/js"
:asset-path "/assets/js"}
:test {:target :browser-test
:test-dir "test/resources/public"
:devtools {:http-port 8021
:http-root "test/resources/public"}}}}:test build configuration is clobbering the :dev build entirely; with my shadow-cljs.edn like that, if i do a dev build, i get a test build:dev files?shadow-cljs watch dev, which i guess runs a process that serves the files?:dev build, which is why I ask:test build configuration entirely, emacs will take me to localhost:9630:dev build is not running. when you open the page on your separate web server, do you not see your application running and changes not hot loading?:dev or :test are building?java.lang.RuntimeException Unable to resolve symbol: + in this context error... hmm.$ yarn cljs:watch yarn run v1.21.1 $ shadow-cljs watch app shadow-cljs - config: .../shadow-cljs.edn cli version: 2.8.83 node: v10.15.2 shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: tap> in this context, compiling:(shadow/debug.clj:36:3) at clojure.lang.Compiler.analyze(Compiler.java:6792)
yarn babel ... , all works fine, so I'm sure I need an upgraded version of babel - so probably I need an upgraded version of shadow-cljs).
However, not sure why shadow-cljs seems to have issues with watch apppackage.json, I have a script "cljs:watch": "shadow-cljs watch app"tap> missing means you are not using clojure 1.10.1[2020-02-23 08:51:46.509 - WARNING] provide conflict for #{sheluchin.client} provided by app/sheluchin/client.cljs and {"/sheluchin/client.cljs" #{sheluchin.client}}
{:lein {:profile "+dev"}
:nrepl {:port 9000}
:dev-http {8000 "resources/public"}
; Ignored since :lein is set
; :source-paths ["src/app"]
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:dependencies [[cider/piggieback "0.4.1"]
[fipp "0.6.21"]]
:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}
:modules {:main {:init-fn sheluchin.client/init}}
:devtools {:after-load sheluchin.client/init
:preloads [com.fulcrologic.fulcro.inspect.preload]
; sheluchin.app.core-test]
:repl-pprint true}
:compiler-options {:external-config {:guardrails {}}
:closure-defines {'goog.DEBUG true}}}}}
(defproject app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url ""}
:dependencies [[org.clojure/clojure "1.10.0"]
[com.fulcrologic/fulcro "3.0.1"]]
:main ^:skip-aot sheluchin.client
:target-path "target/%s"
:source-paths ["src/app"]
:profiles {:uberjar {:aot :all}
:dev {:source-paths ["src/app"]
:dependencies [[org.clojure/clojurescript "1.10.597"
:exclusions [com.google.javascript/closure-compiler-unshaded]
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]
[thheller/shadow-cljs "2.8.83"]
[binaryage/devtools "0.9.10"]]}})Invalid Filename, got app/sheluchin/client.cljs but expected sheluchin/client.cljs (or .cljc) 1 | (ns sheluchin.client 2 | (:require 3 | [com.fulcrologic.fulcro.application :as app] 4 | [com.fulcrologic.fulcro.components :as comp :refer [defsc]] 5 | [com.fulcrologic.fulcro.dom :as dom :refer [div h1 h2 h3 button ul li]]
:source-paths ["src/app"] set, so ns sheluchin.client should correspond to src/app/sheluchin/client.cljs, no?react-native-web (300kb 😬) is being included even though I'm only using a portion of it.
reading docs it says advanced optimizations are only done if :js-provider is set to closure . which I imagine is the issue here. but if some of my other packages aren't compatible with closure compiler, is there way way to exclude them from advanced optimization, or to specifically include the packages I want optimized?react-native-web (300kb 😬) is being included even though I'm only using a portion of it.
reading docs it says advanced optimizations are only done if :js-provider is set to closure . which I imagine is the issue here. but if some of my other packages aren't compatible with closure compiler, is there way way to exclude them from advanced optimization, or to specifically include the packages I want optimized?pprint and spec are bundled).. though not sure if that's bc other cljs deps are depending on itnpx create-cljs-project ? go to definition for the libs does not seem to work (:require [reagent.core :as r]) i.e. can’t jump to reagent codelein bin to get the recent bin, since the one that is provided is not up to date, works now, thanks!npm run build"scripts":{"build":"shadow-cljs release your-app"} or so:browser-target, and running shadow-cljs release app, what is the HTML-file supposed to call in order to call the init -function?:init-fn in the build config insteadmy-ns isn't available as a global variable^:export to the init fn so its name is preserved^:export there{:deps true
;; set an nrepl port for connection to a REPL.
:nrepl {:port 8777}
:builds {
:test {:target :node-test
:modules {:base {:init-fn token-streamer.main/init}}
:output-to "out/node-tests.js"
:ns-regexp ".*-test"
:autorun true}
}}shadow-cljs compile :true[:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (46 files, 1 compiled, 0 warnings, 1.52s)
:modules does not apply to the :node-test target so if you expect that to do something it won't:paths ["src" "test"] in your deps.edn?["src"]my.app.foo-test, no point in your main build doing anything for that:modules {:main {:entries [] :preloads [my.app-tests]}}main.js and call the respectice "init" fn you want<script>my.app.init()</script> while the other calls the testsshadow-cljs watch app but
when I make a release shadow-cljs release app it doesn't show my chart
and some things doesn't seem to work without any error output.
I'm new to clojurescript, any tips to debug this or some common gotchas
I've to look out for that makes the release different from the dev version?shadow-cljs release app --pseudo-names or shadow-cljs release app --debug will make things a little more understandable--pseudo-names or --debug. I don't get 404 anywhere. it works almost as expected just recharts is not displayed and some css looks slightly wrong which is correct when I do the dev build.:compiler-options {:infer-externs :auto}(fn [{:keys [classes] :as props}] to (fn [{:keys [^js classes] :as props}]main.js:52 Uncaught Error: No protocol method IProfile.perf-start! defined for type object: [object Object]
clj -A:shadow-cljs watch app, but I couldn't find a way to get that working with cider-jack-in-cljscider-jack-in-cljs + shadow-cljs , but my automation uses the clj -A:shadow-cljs release app alias to release the app as it avoids needing a docker image that has shadow-cljs installedC-u C-c M-J and then just type in clj -A:shadow-cljs watch appuser.cljs, or put it in a preloadcljs/user.cljs is loaded but applies to all builds and REPLs so I wouldn't use itlein new re-frame todo +10x +cider +test and at localhost:9630 the Builds tab and the Inspect tab work fine, but the REPL tab just says Loading... forever. Any ideas to try?.m2 directory? I’m playing with Netlify and I see that my builds always have to re-fetch all dependencies during the shadow-cljs - updating dependencies phase.import { Ocean } from './jsm/misc/Ocean.js'; in js?import {
Vector2
} from "three";
instead, I had to write it like this:
import * as three from 'three';
const { Vector2 } = three;import { Vector2 } from "three". either way, nice that you fixed it 🙂:http {:host "localhost"} in shadow-cljs.edn{:closure-defines {shadow.cljs.devtools.client.env.ssl true}}
and then was able to send folks to https://test-app.example.com and have them see my changes from wherever they were in real-time and debug their issues from the REPL (or the browser view, or even tap> from the clients and Inspect the results).
It has made for a really interesting and capable development experience -- if the 'trusted/unsafe' operations could be IP whitelisted as you suggest, I would recommend this to most folks and see if I could bottle up the pattern and write something about it. :)localhost only? https://github.com/thheller/shadow-cljs/issues/660:chrome-extension target actually doesn't do anything chrome specific so it might work(shadow.cljs.devtools.server/start!) and this is almost there. The problem is that this doesn't use the nrepl middleware so i just need to figure out how to get that up and going. Does anyone know of a good way to support this?start! and the middleware. see https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server__dirname from a cljs repl attached to a node-script (compiled with shadow)?js/__dirnamejs/__dirname. literally no difference in the emitted code__dirname is inherently tied to the current file ... REPL has no file so you probably shouldn't use it from the REPL 😛js/__dirname and it doesn't work.
Edit: better link
https://github.com/anmonteiro/lumo/commit/658732fb2b934569507db9cc9a845aea07918f0c:node-script you can of course access it?__dirname?__dirname for their base-path. Is there a better option?__dirname to enable working with a .wasm file.file:///[some-path]/foo.htmlCompiling ClojureScript using shadow-cljs: release [:web] Compiling ... The required namespace "shadow.js" is not available, it was required by "braintree-2.26.0.min.js".
shadow.js in any wayshadow-cljs, but I need to use Boot for now because of existing infrastructureshadow/js.js should be on the classpath. boot does a lot of dynamic classpath magic so its easy to miss stuffshadow.js since that is the glue putting it all together)(set-env! :dependencies ...) in build.boot:
[degree9/boot-shadow "2.8.14-0" :scope "test" :exclusions [thheller/shadow-cljs]]
[thheller/shadow-cljs "2.8.83"]tap>)shadow.js existed in .14 too:infer-externs :auto and you probably won't need any:compiler-options {:infer-externs :auto
:externs ["datascript/externs.js"]}Modal component in my reagent/shadow-cljs project…
I’ve added react-modal to package.json and re run yarn and added the line (:require ["react-modal" :as react-modal]) to my ns form(js/goog.exportSymbol "Modal" react-modal) too?js/Modal global (which you shouldn't)react-modal?FlipMove here https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md#creating-reagent-components-from-react-componentsreact-modal/Modal? gives me a reference error[:> react-modal ...]react-modal only has one export which is the actual modal then just use that directly(:require ["react-modal" :as Modal]) then [:> Modal ...] if that makes it clearer?(:require ["react-modal" :default Modal]):as Modal.
Thanks a million for your help!worker.js:126 WebSocket connection to '' failed: Error during WebSocket handshake: Unexpected response code: 403
npx shadow-cljs watch app on my dev machine and opening up a web browser to port 9000 (we override the port for the shadow-cljs dashboard http server)0:0:0:0:0:0:0:1 not trusted. Add :trusted-hosts #{"0:0:0:0:0:0:0:1"} in shadow-cljs.edn to trust.
{:dev-http
{9010
{:root "..."
:short-name "..."}
9020
{:root "..."
:short-name "..."}
...}:display-name:name is fine too I guesspr-str maybe I don't quite know how to display themshadow-cljs just for REPL at this moment - so I had no builds defined (I do not target browser yet). But I was unable to run shadow-cljs in Calva in VSCode due to something something nil error (builds list was empty).lein deps :tree and fix the conflicts^:dev/after-load set on the exported fn that binds my app component to the DOM with r/render* Components view in chrome dev tools, shows the parent component is registered twice into the hierarchy; as a sibling next to itself… but only one of them has child components:devtools {:reload-strategy :full} in your build config (only works if you have the latest shadow-cljs version)r/atom?defonce ’d r/atom s~/.m2/repository directory, and creating a hash from .shadow-cljs/classpath.edn to invalidate. (This is for a CI environment BTW).classpath.edn since it won't exist between CI runs?shadow-cljs.edn should be fine:shadow.build.npm/js-invalid-requires on this code:
return _interopRequireWildcard(require("".concat(
/* webpackChunkName: "icon.[request]" */
// It's important that we don't use a template string here, it
// stops webpack from building a dynamic require context.
// eslint-disable-next-line prefer-template
'./assets/' + typeToPathMap[iconType] + '.js')))ring.middleware.proxy-headers.wrap-forwarded-remote-addr (i.e. X-Forwarded-For) but for some baffling reason, it sets :remote-addr to the /last/ address in X-Forwarded-For which is a proxy and usually user-controllable, respecting what was user-sent (the /first/ address is the original client IP) :man-facepalming::remote-ip to always appear to be 192.168.xx.xx rather than 127.0.0.1 🙂npx shadow-cljs watch :main and then connect to the NRepl started by shadow, I have to execute (shadow/repl :main) in the repl to actually get into the cljs repl. Is there some way to automate this so that shadow/repl would start automatically instead of me typing it every time?The required namespace "cljs.user" is not available. when saving files via a connected repl a known issue?cljs.user and they were gone.cljs/quit configurable ? I want to back to shadow.user instead of user.shadow-cljs.edn:
:builds
{:app
{:target :browser
:modules {:main {:init-fn app/init}}
:devtools {:after-load app/init}}}}
Is this expected? I can’t help but feel I did something wrong in order for that line to become necessary.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0766697363473329372937"}, :content ("[email protected]")} and finding that pulling in their Timeline component is pulling in their entire @ant-design/icons and @ant-design/icons-svg libraries.
They've explicitly refactored in 4.0.0 to ensure that the icons can be tree shaken.(:require ["antd/es/timeline" :default ATimeline]) (def AItem (.-Item ATimeline))I'm following their instructions for pulling it in modularly: https://ant.design/docs/react/introduce#Use-modularized-antd And the upstream library's import of icons (inside the distributed version of
Timeline.js) looks like this:
import { LoadingOutlined } from '@ant-design/icons';(:require ["antd/es/timeline" :default ATimeline]) (def AItem (.-Item ATimeline))I'm following their instructions for pulling it in modularly: https://ant.design/docs/react/introduce#Use-modularized-antd And the upstream library's import of icons (inside the distributed version of
Timeline.js) looks like this:
import { LoadingOutlined } from '@ant-design/icons';@ant-design/icons/LoadingOutlined.js is a file, which imports ../lib/icons/LoadingOutlined.js which imports @ant-design/icons-svg/lib/asn/LoadingOutlined.js
Is the entire NPM library simply pulled in, even if only a subset of it is used (explicitly, through JS imports)?import { LoadingOutlined } from @ant-design/icons is only able to find the inner icon through @ant-design/icons/index.js and shadow keeps all of the files that are re-exported through there, rather than just the component that was required?@ant-design/icons this is relevant yes@ant-design/icons with an override file which re-exports only the used icons. I also filed an issue upstream to ask them to change their imports:
https://github.com/ant-design/ant-design/issues/21744
I'll also spend some more time trying to understand:
• Whether it's possible to use tsickle to generate externs for TypeScript NPM modules.
• Whether there's an easier way to pre-process upstream modules for only the required imports and their dependencies.ATimeline and AItem with stubs) that if I remove the require above, that the build report loses all of the ant-design files, so it's definitely those requires that are pulling in the entire library.:builds
{:app
{:js-options
:js-options
{:resolve {"@ant-design/icons" {:target :file :file "overrides/ant-design-icons.js"}}}
... }}
shadow-cljs in response to a question on the #clojurescript channel, and am already delighted at how it is helping me, but I am sure I will have a bunch of questions along the way. The first one is, I can’t seem to get a cljs REPL working in CIDER. And I fear the answer may simply be “that’s because your project doesn’t support that kind of operation.” But I want to be sure.;; Startup: /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.23.0-SNAPSHOT server ;; ;; ClojureScript REPL type: node ;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env))) ;; Execution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:29). Assert failed: (keyword? repl-env) WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user>
.cljs buffer that needs a REPL, CIDER still complains about there being no CLJS REPL available.bytefield package offered by instead using a Clojure-based DSL inside Asciidoc documents. Woo hoo!ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
npx shadow-cljs node-repl in the terminal before I try to connect CIDER, it works! This will make me much happier as I continue to evolve this project. And the ease with which shadow-cljs allowed me to build a Node module is just delightful.shadow-cljs.edn I've got :main target of type :browser which produces UI. I also have .clj foo.core/init function for backend and API. What's the proper way of starting backend together with frontend? shadow-cljs watch main obviously only keeps .js file up to date.shadow-cljs also provides clj-repl... Was I wrong expecting shadow-cljs to cover both backend and frontend tasks?shadow-cljs(ns snabbdom (:require ["snabbdom" :as snabbdom])) (js/goog.exportSymbol "snabbdom" snabbdom)But this line is triggering an error: https://github.com/cjohansen/dumdom/blob/dd7cbae5e1b03892a068410e246cd44dcaeb8cbf/src/dumdom/core.cljs#L20
Failed to load dumdom/core.cljs TypeError: Cannot read property 'create' of null
at Object.exports.init (snabbdom.js:39)
at eval (core.cljs:23)
(All the properties of js/snabbdom used on that line are coming up nil)cljsjs.snabbdom and then manually ensure it is loaded before dumdomimport to import things from notebookscurl the notebook and include it in your build if you really wantdevcards in shadow-cljs?
This does not seem to work
;; shadow-cljs configuration
{:source-paths
["src"
"test"
"tailwind.config.js"]
:dependencies
[[reagent "0.9.1"]
[metosin/reitit "0.4.2"]
[binaryage/devtools "1.0.0"]
[devcards "0.2.6"]]
:builds
{
:devcards {:target :browser
:output-dir "devcards"
:asset-path "/"
:compiler-options {:devcards true
:source-map-timestamp true}
:modules {:devcards {:entries [limeray.web.app-test]}}
:devtools {:http-port 9003
:http-root "devcards"}}}}
;; limeray.web.app-test
(ns limeray.web.app-test
(:require
[cljs.test :refer [testing is use-fixtures]]
[devcards.core :as dc]
[reagent.core :as r]
[limeray.web.components :as ui]
["@testing-library/react" :as rtl])
(:require-macros
[devcards.core :refer [defcard deftest]]))
(enable-console-print!)
(defcard my-first-card
(r/as-element [ui/date-picker]))
(defn ^:export init []
(dc/start-devcard-ui!)){:type :dtd, :data ["html" nil nil]}
BUt having this error
//cljs-runtime/devcards.core.js:101 Uncaught TypeError: devcards.system.start_ui is not a function
:asset-path is incorrect for one//:asset-path "/"asset-path and http-root under devtools
:devcards {:target :browser
:output-dir "devcards"
:asset-path "/"
:compiler-options {:devcards true
:source-map-timestamp true}
:modules {:devcards {:entries [limeray.web.app-test]}}
:devtools {:http-port 9003
:http-root "/"
:preloads [devcards.core]}}}}preloads:http-root was correct. / is definitely incorrectcljsjs.react and maybe cljsjs.react.dom since devcards doesn't declare its dependency on react for some reason:preloads isn't useful in the first placelein-shadow. I hate that its the default but I absolutely advise against using it.lein-shadow can write it to disk so shadow-cljs can pick it up? (really stop using lein-shadow)project.cljnrepl-select and starting it on a specific namespace, but I don't find any documentation for the opts parameter of the nrepl-select to use it. I tried to use init-ns but didn't work.shadow-cljs.edn correct?
In trying to use the init-ns to get a repl directly in the dev namespace where I have a lot of utility functions that I use. But this is specific for me, I wouldn't like to pollute the shadow-cljs.edn with my specific dev environment.shadow-cljs.edn in the build config via :devtools {:repl-init-ns some.foo}lein ancient?deps.edn, you can use olical/depot. Here's my global deps.edn alias:
:outdated
{:extra-deps {olical/depot {:mvn/version "1.8.4"}}
:main-opts ["-m" "depot.outdated.main"]}shadow-cljs.edn, I am unclear as to what adding a deps.edn would do, wouldn’t that be two different places to specify the dependencies which could get out of sync?deps.edn to speficy dependencies: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn
This functionality is in place just to avoid the duplication you're (rightly) reluctant to create. The advantage being that you can plug into the rest of the ecosystem for deps.edn / tools-deps 🙂deps.edn…Send to repl does not work properly(+ 1 1) Syntax error compiling at (REPL:1:1). Unable to resolve symbol: + in this context
(in-ns 'foo.bar) without having (require 'foo.bar) first, ie. switching before actually loadingshadow-cljs watch app in a separate terminal and trying to connect to it with Cursive remote repl(shadow.cljs.devtools.api/repl :app):cljs/quit to switch back to CLJ:init-nsCannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)import { OceanShaders } from "../shaders/OceanShaders.js";
but that results in undefined. any other form results in "Cannot import Closure files by path..."(:require ["/jsm/misc/Ocean" :as ocean]that Ocean.js tries to import OceanShaders.js with:
import { OceanShaders } from "../shaders/OceanShaders.js";
OceanShaders there passes compilation but comes up as undefined. Elsewhere, I rewrote a similar syntax to:
import * as three from 'three';
const {...} = three;
to make it work. If I try to rewrite similarly:
import * as OceanShadersLib from "../shaders/OceanShaders.js";
const {OceanShaders} = OceanShadersLib;
it'll fail with:
Closure compilation failed with 1 errors
jsm/misc/Ocean.js:64
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)threeexport * from './SQLite';
^^^^^^
SyntaxError: Unexpected token 'export'
at Module._compile (internal/modules/cjs/loader.js:896:18).js and only includes export statements so pretty sure it’s just that the node_module needs to be compiled?SyntaxError: Unexpected token 'export'
at Module._compile (internal/modules/cjs/loader.js:896:18)expo-sqlite in an electron app:desktop-main
{:target :node-script
:output-to "apps/desktop/dist/index.js"
:main rf.app-desktop.main/start}
require. so shadow-cljs processes no npm deps whatsoeverCannot run program "java" (in directory "M:\libs\myproject"): CreateProcess error=206, The file name or extension is too longwhich basically means that leiningen computes too many classpaths. I was googling little bit around and one suggested solution is to add plugin
[lein-classpath-jar "0.1.0"]Which solves that problem but creates a new problem while compiling shadow-cljs release build. I am doing this in lein by
["run" "-m" "orgpad.build/release"]whose code is the following
(ns orgpad.build
(:require [shadow.cljs.devtools.api :as shadow]))
(defn release []
(let [version (System/getenv "HEROKU_SLUG_COMMIT")]
(shadow/release :client {:config-merge [{:release-version version}]})))
But it fails with the error:
Warning: implicit hook found: lein-classpath-jar.plugin/hooks Hooks are deprecated and will be removed in a future version. SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See for further details. [:client] Compiling ... The required namespace "orgpad.client.core" is not available.Compiling directly using shadow-cljs release client works fine. Any ideas what is wrong?
shadow-cljs server instance running and trigger shadow-cljs release app --pseudo-names manually when needed (or via a REPL keybind)require('some-polyfill.js')
require('public/js/main.js'):devtools {:reload-strategy :full} in your build config:done? Its really meant as an api method for the REPL so it caches and pretty-prints exceptionsrelease! fn that just throws and doesn't catch the error:js-options {:babel-present-config {:targets {:ie 8}}} to my shadow-cljs.edn, but I still get "Promise not defined" in iexplorer... any suggestions? 😄js/Promise:babel-preset-config? Is there any doc for it?(defn start-animation [] ,,,) (start-animation)then
load-file at the repl, preferably using a hotkey 😄eval-defun, i.e. only eval the function you're modifying:dev {:devtools {:autoload true
:reload-strategy :full
:after-load app.core/reload}}:devtools {:reload-strategy :full} Before enabling :deps true , live reloading would include updates to files under node_modules. Now after enabling, I have to use reload-strategy to get that functionality. I'm just curious why the deps modes are different in this way?:dev-http {8080 "classpath:foo"}:reload-strategy is not affected by using :deps true or not.:js-provider. so should CLJS ever get "different" support its just another method you can selectnpm link to symlink the dependencies inside our node_modules and that has been working great! If we make a change to the Javascript library shadow-cljs would pick-up the changes via the symlink and recompile and everything was awesome! However, we recently switched to using tools.deps for our maven dependencies so we could the use :local provider and get the same setup for our Clojurescript libraries.
It seems like enabling :deps true has in some way prevented shadow-cljs from picking up changes to our Javascript files and recompiling now. These seems strange to me and probably is something else but I'm not sure where else to look.node_modules code is not hot-reloadable or only in a very limited way but I don't see how deps.edn affects it in any waynpm link behavior would likely changepackage.json for modification (timestamp is enough) so "touch package.json" should be enough to trigger a shadow-cljs compile?package.json file but that's pretty much the equivalent of just re-running compile every time we make a change:react-native target and the app will crash when running as a production build: shadow-cljs release app there is some information related to this library and shadow-cljs: https://github.com/henryw374/tick-on-shadow-cljs-demo that does not help with production builds. However, using shadow-cljs compile app before ./gradlew assembleRelease to skip optimisations will result in a working app. Any hints? I read the excellent documentation to shadow-cljs but seem to have missed something. Thanks in advance!:compiler-options: :optimizations :simple and :infer-externs :auto:compiler-options {:infer-externs :auto} but there is no hint to what I could change to make thinks work. As a workaround :optimizations :simple probably works but having :advanced compilation working is preferred.tick depends on js-joda-time which is normally pulled in with cljsjs based deps… so my guess is, that js-joda.time* gets yanked by the compiler because they are not considered as used. Just an idea…--------- beginning of crash
2020-03-05 16:39:19.966 1894-1923/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: , PID: 1894
com.facebook.react.common.JavascriptException: TypeError: this.wh is not a function. (In 'this.wh()', 'this.wh' is undefined), stack:
:infer-externs :auto only warns about your sourcesshadow-cljs release app --pseudo-names and looking at the logexterns/app.txt and add someThing (one line)shadow-cljs release app --pseudo-names and only got one warning:
------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- nilbut nothing like “`this.$someThing$` is undefined”
shadow-cljs check app gives me tons of warnings (> 500) many related to the tick library:
------ WARNING #547 - --------------------------------------------------------- File: ~/.m2/repository/tick/tick/0.4.23-alpha/tick-0.4.23-alpha.jar!/tick/core.cljc:1055:61 -------------------------------------------------------------------------------- 1052 | LocalDateTime 1053 | (in [ldt z] (.atZone ldt z)) 1054 | (offset-by [ldt offset] #?(:clj (.atOffset ldt (zone-offset offset)) 1055 | :cljs (.atZone ldt (zone-offset offset)))) -------------------------------------------------------------------^------------ Property atZone never defined on ldt__$1 --------------------------------------------------------------------------------
--------- beginning of crash
2020-03-05 16:39:19.966 1894-1923/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: , PID: 1894
com.facebook.react.common.JavascriptException: TypeError: this.wh is not a function. (In 'this.wh()', 'this.wh' is undefined), stack:
check unfortunately produces a lot of noiseE/ReactNativeJS: TypeError: this.$toLocalDate$ is not a function. (In 'this.$toLocalDate$()', 'this.$toLocalDate$' is undefined)… put it in
externs/app.txt, rebuild the apk and now it no longer crashes. Thank you very much Sir!:compiler-options {:externs ["cljsjs/js-joda/common/js-joda.ext.js"]} in your build configtick 🙈thheller/shadow-cljsjs as a dependency would have fixed the problem as well?require A from "a";
require B from "b";
module.exports {
a: A,
b: B
}
since there's an object that contains a and b, If I require this file in cljs, both a and b will be bundled no matter I use them or not.import { faCoffee } from '@fortawesome/free-solid-svg-icons' only include the faCoffee, even though '@fortawesome/free-solid-svg-icons' represent a index.js that require all files.["@fortawesome/free-solid-svg-icons/faCoffee" :as faCoffee] (maybe :default not :as) to get the same effect?:js-options {:js-provider :closure} in your build config:advanced compilation{
test: /\.fs(x|proj)?$/,
use: {
loader: "fable-loader",
options: {
babel: babelConf
}
}
}<script> in runtime?rc/inline pulls the file into the build:source-paths I gave you". I was interested in this because the namespace of my tests was not detect, because the regex a supply didn't match it (silly thing). But I finally fix it ^^undefined when checking with (goog/typeOf) or object (which seems empty) when trying with ["react-data-grid" :as ReactDataGrid]))["react-data-grid" :default ReactDataGrid]["react-data-grid" :refer (ReactDataGrid)]:loader-mode :script?"shadow-cljs": "^2.8.52":devtools {:loader-mode :eval} in your build config or upgrade (which sets that as a default){:deps {:aliases [:dev]}
:nrepl {:port 9000
:init-ns user}
:dev-http {8000 "resources/public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn spreadnotes.client/init}}
:devtools {:after-load spreadnotes.client/init
:preloads [com.fulcrologic.fulcro.inspect.preload]}}}}:loader-mode?deps.edn?cli version: 2.8.91 node: v8.17.0deps.ednlet , def , +) raises a warning :undeclared-var , and it seems to think that the function should be found in the current ns.(js/goog.require "cljs.core") (cljs.core/+ 1 1)I get the expected output of 2. 🙂
:bootstrap target. pretty sure thats a full replacement to replumb though. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for an example:bootstrap target will pre-compile sources and the host build will just load them (instead of compiling itself)cljs.core was treated as special and extra deps were hard:target :node-library so that they have the async keyword
AWS lambda needs it and it looks like it's not working when just returning a promise in the cljs function that we export
For async handlers, you can use return and throw to send a response or error, respectively. Functions must use the async keyword to use these methods to return a response or error.
Here what the aws lambda doc is asking for:
const https = require('https')
let url = ""
exports.handler = async function(event) {
const promise = new Promise(function(resolve, reject) {
https.get(url, (res) => {
resolve(res.statusCode)
}).on('error', (e) => {
reject(Error(e))
})
})
return promise
}asyncload-config macro combined with :closure-defines goog/ENV like this code sketch
(defmacro load-config []
`(if (= js/goog.ENV "prod")
;; prod config
(load-from-file "prod-config.edn")
;; dev config
(load-from-file "dev-config.edn")))
-A:alias cli option override {:deps {:aliases [:alias]}} in shadow-cljs.edn?:node-test target working, which is great, but the console output is a bit plain and I'm looking for editor integration to spot any failure more easily and focus on failing tests directly in an editor. I tried VSCode Calva, but the tests commands dont work with shadow-cljs yet. Is it better with Cursive or Cider ?release with it, it complains about not having access to goog -namespace.
It seems to be loading the bootstrap stuff from the output folder I have assigned but the evaluation itself fails. I'm using re-plumb for now, is it something to do with that? Should I just stop using it and switch to the built-in one mentioned in the blog post instead?base.js:5319 Uncaught ReferenceError: goog is not defined
at eval (/js/bootstrap/js/75b50edc.cells.lib.js:1)
at eval (<anonymous>)
at Object.goog.globalEval (base.js:251)
at Object.shadow.cljs.bootstrap.browser.script_eval (base.js:5513)
at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (base.js:5516)
at base.js:5526
at goog.async.run.processWorkQueue (base.js:5326):compiler-options {:optimizations :simple} for your "host" build. :advanced (the default) is not supported.:compiler-options {:output-wrapper false} toooutput-wrapper: false solved the issue for me. Thanks again for your fast response. So, I'm guessing the output-wrapper is a function that basically hides the goog from being globally available and removing that fixes it.cljs would be the next and so on:npm-module and sticking with webpack for a while#!/usr/bin/env node at the beginning of a node-script target, besides removing it afterward with sed? (in order to compile in the nodejs deps with webpack):hashbang false in the build config I think:node-library though[:api] Compiling ... Done in 37.24s.and then from time to time a task fails saying the file doesn't exist, which I can confirm by running a
ls after shadow, the file isn't thereDone isn't from shadow-cljs it is from the CI:jvm-opts ["-Xmx1G"]. see https://shadow-cljs.github.io/docs/UsersGuide.html#jvm-optstwo modules without deps, please specify which one is the default:depends-on properlynubank.workspaces.shadow-cljs.target which of course doesn’t know about my shared moduleshadow-cljs watch app from the command line. Using Emacs + CIDER with cider-jack-in-cljs, I get
[:app] Configuring build. [:app] Compiling ... WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.0 (package:Everything else mostly works. I was expecting CIDER to inject that dep. Reading messages tells me:
[nREPL] Starting server via /home/lvh/.nvm/versions/node/v11.2.0/bin/npx shadow-cljs -d nrepl:0.7.0-beta1 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.0-SNAPSHOT server... this suggests that refactor-nrepl isn't actually getting loaded. Any ideaas?
shadow.cljs.devtools.client.env defines are undefined.shadow-cljs compile test && node out/node-tests.js already with the first step the test actually run:autorun configured?shadow-cljs compile test --config-merge "{:autorun false}"~/p/p/footy (fix-test-run|…) $
shadow-cljs compile test --config-merge "{:autorun false}" && node out/node-tests.js
shadow-cljs - config: /Users/acrotti/projects/personal/footy/shadow-cljs.edn cli version: 2.8.83 node: v13.10.1
shadow-cljs - connected to server
NPM dependency "react" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
[:test] Compiling ...
[:test] Build completed. (175 files, 1 compiled, 0 warnings, 0.56s)
c
Testing footy.handlers-test
Games = [:footy.handlers/games]
^R
e
FAIL in (specs-test) (cljs-runtime/day8/re_frame/test.cljc:99:18)
expected: (db/valid-db? (clojure.core/deref games) (clojure.core/deref players-list))
actual: (not (db/valid-db? [:footy.handlers/games] [:footy.handlers/players-list]))
failed with args [:footy.handlers/failed {:uri /games.edn, :last-method GET, :last-error , :last-error-code 0, :debug-message No Error, :status 0, :status-text Request failed., :failure :failed}]
~/p/p/footy (fix-test-run|…) $ echo $status
0~/p/p/footy (fix-test-run|…) $ which node /usr/local/bin//node
node out/node-tests.js1 when tests fail:runner-ns for example it might not unless you hook it up correctly yourself:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}(deftest specs-test
(testing "Game map is valid"
(rf-test/run-test-async&& in 2 separate steps ... makes it easier to figure out which part is actually failinglein install to install it in your local repo. shadow-cljs will use that without looking at any remotes, just add the dependency by its regular nameyarn start to serve up files
and I'm wondering if that is mandatory, or if there is a more clojure-heavy way to do it{:dev-http {8080 "public"}}
It will serve all the compiled files in the public folder through port 8080.yarn start or what have you just shells out todeps.edn and config a alias to run the main of Shadow-cljs. But I had problem connecting to the ClojureScript repl using this setting.npx create-cljs-project acme-app to bootstrap my appnpx shadow-cljs watch app will run a dev serverlein shadow -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0 watch app test, does shadow load those dependencies? (I'm trying Calva with a fresh Luminus project, and it seems that the dependencies are not satisfied...)[:client] Build failure:
------ ERROR -------------------------------------------------------------------
File: C:\Shared\orgpad\src\orgpad\client\subs\unit.cljs:47:38
--------------------------------------------------------------------------------
47 | {:size/keys [width height]} ((if show-content :unit/size :unit/title-size)
--------------------------------------------^-----------------------------------
Error in phase :compilation
ClassCastException: class clojure.lang.PersistentList cannot be cast to class clojure.lang.Named (clojure.lang.PersistentList and clojure.lang.Named are in unnamed module of loader 'app')
clojure.core/name (core.clj:1595)
clojure.core/name (core.clj:1589)
shadow.build.cljs-hacks/shadow-parse-invoke* (cljs_hacks.cljc:783)
shadow.build.cljs-hacks/shadow-parse-invoke* (cljs_hacks.cljc:730)
cljs.analyzer/parse-invoke (analyzer.cljc:3690)
cljs.analyzer/parse-invoke (analyzer.cljc:3688)
cljs.analyzer/analyze-seq* (analyzer.cljc:3935)
cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
cljs.analyzer/analyze-seq (analyzer.cljc:3963)
cljs.analyzer/analyze-seq (analyzer.cljc:3941)
cljs.analyzer/analyze-form (analyzer.cljc:4150)
cljs.analyzer/analyze-form (analyzer.cljc:4147)
cljs.analyzer/analyze* (analyzer.cljc:4200)
cljs.analyzer/analyze* (analyzer.cljc:4191)
cljs.analyzer/analyze (analyzer.cljc:4220)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4213)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4211)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze-let-binding-init (analyzer.cljc:2273)
cljs.analyzer/analyze-let-binding-init (analyzer.cljc:2271)
cljs.analyzer/analyze-let-bindings* (analyzer.cljc:2293)
cljs.analyzer/analyze-let-bindings* (analyzer.cljc:2282)
cljs.analyzer/analyze-let-bindings (analyzer.cljc:2327)
cljs.analyzer/analyze-let-bindings (analyzer.cljc:2326)
cljs.analyzer/analyze-let (analyzer.cljc:2353)
cljs.analyzer/analyze-let (analyzer.cljc:2337)
cljs.analyzer/fn--1994 (analyzer.cljc:2391)
cljs.analyzer/fn--1994 (analyzer.cljc:2389)
clojure.lang.MultiFn.invoke (MultiFn.java:252)
cljs.analyzer/analyze-seq* (analyzer.cljc:3934)
cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
cljs.analyzer/analyze-seq (analyzer.cljc:3963)
cljs.analyzer/analyze-seq (analyzer.cljc:3941)
cljs.analyzer/analyze-form (analyzer.cljc:4150)
cljs.analyzer/analyze-form (analyzer.cljc:4147)
cljs.analyzer/analyze* (analyzer.cljc:4200)
cljs.analyzer/analyze* (analyzer.cljc:4191)
cljs.analyzer/analyze (analyzer.cljc:4220)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze-seq (analyzer.cljc:3964)
cljs.analyzer/analyze-seq (analyzer.cljc:3941)
cljs.analyzer/analyze-form (analyzer.cljc:4150)
cljs.analyzer/analyze-form (analyzer.cljc:4147)
cljs.analyzer/analyze* (analyzer.cljc:4200)
cljs.analyzer/analyze* (analyzer.cljc:4191)
cljs.analyzer/analyze (analyzer.cljc:4220)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4213)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4211)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/fn--1962 (analyzer.cljc:2252)
cljs.analyzer/fn--1962 (analyzer.cljc:2248)
clojure.lang.MultiFn.invoke (MultiFn.java:252)
cljs.analyzer/analyze-seq* (analyzer.cljc:3934)
cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
cljs.analyzer/analyze-seq (analyzer.cljc:3963)
cljs.analyzer/analyze-seq (analyzer.cljc:3941)
cljs.analyzer/analyze-form (analyzer.cljc:4150)
cljs.analyzer/analyze-form (analyzer.cljc:4147)
cljs.analyzer/analyze* (analyzer.cljc:4200)
cljs.analyzer/analyze* (analyzer.cljc:4191)
cljs.analyzer/analyze (analyzer.cljc:4220)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4213)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/analyze (analyzer.cljc:4211)
cljs.analyzer/analyze (analyzer.cljc:4203)
cljs.analyzer/fn--1770/fn--1774 (analyzer.cljc:1655)
cljs.analyzer/fn--1770 (analyzer.cljc:1655)
cljs.analyzer/fn--1770 (analyzer.cljc:1648)
clojure.lang.MultiFn.invoke (MultiFn.java:252)
--------------------------------------------------------------------------------
48 | unit-map)]
49 | [width height])))(get unit-map (if show-content :unit/size :unit/title-size))everything works, but the original code is correct as well.
release build in a Dockerfile by attempting to cache .shadow-cljs between docker builds. We are seeing cache reads, followed by compiles and writes for files that have not changed between commits. What should I look for regarding inappropriate cache invalidations?:after-load hook?
it is unreasonable to expect
(.getElementById js/document "app")to be mountable?
:after-load gets called upon recompilation:after-load gets called AFTER the recompiled code has been loadedschema-cljs.edn with my app module thus
:modules
{:main {:entries []}}
and I have to fire up the app from with index.html like this
<div id="app"></div>
<script src="js/main.js"></script>
<script>my.app.main();</script>
and I'm complaining about having to repeat the classname of my app in two places: index.html and schema-cljs.edn
but I supppose this is necessary because schema-cljs.edn goes away at release time
but the app's main function will still have to get called:entries is for the google closure compiler and the tree shaking that it does. You probably want to add :init-fn {:init-fn }. then you can remove the second script tag that calls the mainslurp a text file into a variable at compile time at some point using shadow-cljs?project.clj and deps.edn?
Was just nosing around after dnolen mentioned that CLJS 1.10.597 has a regression that leads to an increased bundle size and noticed that project.cljs has 1.10.597 while deps.edn has 1.10.520, which doesn't have the regression.day8.re-frame/http-fx {:mvn/version "v0.2.0"} to our project, it started failing on release builds with:
IllegalStateException: Could not find where to put constant cljs$cst$keyword$method. Used by [ajax.simple.js, ajax.xhrio.js, ajax.easy.js, sablono.core.js, ajax.interceptors.js, company.namespace.events.js, ajax.xml_http_request.js], selected common dep goog.structs.map.jsThere's a reference to a similar issue on https://clojurians-log.clojureverse.org/shadow-cljs/2019-01-09, but we don't use
:modules.
What'd be the next thing to investigate?{:target :npm-module
:output-dir "build/cljs"
:compiler-options {:infer-externs :auto
:source-map true}}[ajax.edn :as edn] instead of just [ajax.edn]) :man-shrugging::npm-module basically creates on :module per namespace. so you are definitely using :modules. I can't really remember the details from this previously. If you have something reproducible I can look at I can investigate further.68 and .93){:error #error {:message Could not require hoplon.core, :data {:tag :cljs/analysis-error}, :cause #error {:message ns hoplon.core not available, :data {:ns hoplon.core}}}}
when i try to compile it (according to this guide (https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html).:bootstrap-support
{:target :bootstrap
:output-dir "public/bootstrap"
:exclude #{cljs.js}
:entries [cljs.js javelin.core cljs.analyzer hoplon.core]
:macros []}
npm shadow-cljs watch my-app and then starting node target/main.js
Am I right that I only need to restart the node target/main.js part every time I test a different version of the npm package?io ns is never used in that file. I had a local versiont that got rid of the io require and this line, which I don't think is valid cljs https://github.com/hoplon/javelin/blob/557b51ce14f31c391aefa8a22c8c2aa42db7b269/src/javelin/core.clj#L200
But strangely, after I got that working I went back to using the github/master version and it still worked fine. (I deleted caches several times too)re-frame-10x in my web workers and it will throw an error because 10xrequires document.:browser-inject :main as advised in the documentation, but I can't overcome this.(require 'day8.re-frame-10x.preload) in the repl after start.:browser-inject:preloads can be specified per module, so just put it into the main module:worker target be used for service workers as well? There is no mention of services workers in the docs as far as I can tell.:dependencies [[reagent "0.8.1" :exclusions [cljsjs/react cljsjs/react-dom]]]
vs
:dependencies [[reagent "0.8.1"]]
We can see in your React native Expo example, Reagent is call wihtout exclusions: https://github.com/thheller/reagent-expo/blob/master/shadow-cljs.edn:missing-nrepl-middleware when running:
(shadow.server/start!) (shadow.api/watch :app) (shadow.api/nrepl-select :app)From inside a repl started with cider through
deps.edn.
I thought cider would inject the nrepl middleware.
Does anyone have any idea how to solve this?.dir-locals.el do you have any idea how to do that? I just found the cider-clojure-cli-parameters:node-script name suggests that is meant for node ...lein rungetSourceName not found error. But after I run lein shadow release app and then immediately build a report it worked. Not sure what was the problem, I'll dig deeper next time I generate a report.import EStyleSheet from 'react-native-extended-stylesheet';to
clojurescript ?["react-native-extended-stylesheet" :default EStyleSheet] and it´s giving Can´t find variable EStyleSheet(EStyleSheet.create)(EStyleSheet.create) thats invalid, should be (.create EStyleSheet)shadow-cljs cljs-repl $BUILD_ID (require '[shadow.cljs.devtools.api :as s]) (s/node-repl $BUILD_ID
:node reader conditionals between those:node stuff read and the Clojure API one doesn’t:node-script build target requires node_modules to run, but the output from :browser doesn’t. Is it possible to make the :node-script build work like :browser such that it doesn’t need to install any node modules?
For my use case I have a code base that runs in several environments; electron, browser, and node server. Most of the NPM dependencies are for the code that runs in the browser, but the node server also uses some of them when it server-side renders.
When releasing the electron version those dependencies should go in "devDependencies" in the package.json so that they’re not included in the final build (the :browser build doesn’t seem to need them). However when I deploy the node server, I do need those dependencies in "dependencies" so that they’ll be installed on the server (the :node-script build seems to need them).
Any ideas for the best way to configure this?node_modules, it only watches package.json files for modifications. so you can touch node_modules/the-dep/package.json which should trigger a rebuild$ANTORA_DJ --fetch doc/dev_svg.yml --stacktrace
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
Error: ENOENT: no such file or directory, open '/Users/jim/git/dysentery/node_modules/bytefield-svg/.shadow-cljs/builds/lib/dev/out/cljs-runtime/goog.debug.error.js'
at Object.openSync (fs.js:436:3)
at Object.readFileSync (fs.js:341:35)
at global.SHADOW_IMPORT (/Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:58:15)
at /Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:2212:1
at /Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:5:26
at Object.<anonymous> (/Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:9:3)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
I am running the command inside my dysentery repository, where I have locally installed my bytefield-svg npm module. Its source is here: https://github.com/Deep-Symmetry/bytefield-svg.shadow-cljs directory in the npm-installed copy of bytefield-svg. That directory does exist in the git repo where I built the module to publish to npm. I am a total npm n00b, and pretty wet behind the ears when it comes to shadow-cljs as well, this project was my first non-JVM Clojure effort, so hopefully someone can help me understand what is going on!)shadow-cljs release your-build and publish that insteadyour-build?name in package.json?:builds mapnpm run buildshadow-cljs compile lib so I am guessing the magic id is lib.release script. Thanks! Trying…node: v11.13.0
shadow-cljs - server version: 2.8.51 running at
shadow-cljs - nREPL server started on port 52448
[2020-03-24 11:42:40.454 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/eth-lib/lib/bytes.js", :requires [{:line 9, :column 193}]}if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("c" + "rypto").randomBytes(bytes);else throw "Safe random numbers not available.";
:dev-http
I have a clojure backend running on pedestal/jetty
I am now at the point where I would like to establish a websocket connection between the two; Ideally I would like to serve the front-end from Pedestal server AND connect a shadow-cljs repl to this session;
When I serve the html pages from pedestal however, I cannot get the cljs repl started; I get
> No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
I can see that shadow-cljs :run-dev somehow injects
into the webpage and I can see that Pedestal server does not do this and I presume that this is why it does not make a repl connection; Where does this repl websocket get injected? How can I get Pedestal server to do the same thing?
:dev-http. that is strictly serving static files only..js files can be served by pedestal as they are just filesnode_modules/highchartsnrepl-client, I'm trying to require it with ["nrepl-client" :as nrepl], shadow-cljs target is node-libraryjs/require it works correctlyindex.html in the browser I get an error in the JavaScript console: ReferenceError: Can't find variable foo where my init-function is foo.core/init . In development mode everything works find…shadow-cljs.edn I tried:
:modules {:main {:init-fn foo.core/init}}
and
:modules {:main {:entries [foo.core]}}
my index.html looks like this:
<html lang="en">
<head>
<!-- ... -->
<script src="/js/compiled/main.js"></script>
</head>
<body>
<div id="app"></div>
<script>foo.core.init();</script>
</body>
</html>foo/core.cljs I have:(defn ^:export init [] ...)
TypeError: undefined is not an object (evaluating '$N.call') iO — main.js:1126:113 cN — main.js:1128:348 (anonymous function) — main.js:1061:406 (anonymous function) — main.js:1061:441 Global Code — main.js:1800 ReferenceError: Can't find variable: foo Global Code — where `where line 18 of index.html is:
<script>foo.core.init();</script>
shadow-cljs release foo --debug did the trick and produced some useful output to the JavaScript console in the browser to track down the problem. Instead of (evaluating '$N.call') in the logs above I got some hints to hat it was related to pprint…node_modules/highcharts/modules so tried adding ‘[“highcharts/modules/sankey.js”]’ to the namespace, but I still get the “error 17, missing module for sankey”. Do I need to add the dependency somewhere else? which apparently includes the sankey stuff directly so I don’t get the “Error 17", but if fails in a different way: “undefined is not an object (evaluating ‘t.chart’)” Now I’m trying to get some source-maps, so I have a chance of figuring out what this issue really is (shadow-cljs noob).[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
"åäö", they end up as "???" in the repl.$ shadow-cljs browser-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn shadow-cljs - connected to server [:browser-repl] Configuring build. [:browser-repl] Compiling ... [:browser-repl] Build completed. (135 files, 134 compiled, 0 warnings, 6.31s) cljs.user=> "åäö" "åäö"
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9b3b6b7b89993b6b7b8aaf494b8ba9bb6b6b2f489abb6"}, :content ("[email protected]")}% export LANG="UTF-8"LANG="UTF-8", but I still get ??? when in the cljs-repl:refer-clojure :rename and shadow-cljs, I’m now facing an issue with :refer-clojure :only in my .clj file with macros, the file is expected to work, but fails with shadow-cljs with a stack trace originating from shadow.build.macros$load_macros, I didn’t find a relevant issue in shado-cljs github repo, just wondering if I should dig into it and create one:only, so it is not shadow-cljs problem at all, I was able to reproduce it with plain clj as wellorg.clojure/clojurescript {:mvn/version "1.10.597"
:exclusions
[com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20191027"}
org.clojure/google-closure-library {:mvn/version "0.0-20191016-6ae1f72f"
:scope "provided"}
org.clojure/google-closure-library-third-party {:mvn/version "0.0-20191016-6ae1f72f"}
shadow-cljs release can include different versions of npm libs than the one generated by shadow-cljs watch ? (it sounds impossible just writing it 😅 but want to be sure as i'm having a weird bug between in my release build, and it's not a typical extern missing bug, more like a js library outdated and thus returning an error)node_modules/lib filesobject.constructor.name which returns "BigNumber" in dev but a u in prod, because i'm requiring the bignumber.js lib in one of my cljs file it gets optimized.
can i fix that with this method? https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs:js-options {:property-renaming :off}# externs/app.txt BigNumber
(ns my-ns (:require ["bignumber.js" :as BigNumber])) (defn to-big-number [num] (BigNumber num))
:simple:js-options {:variable-renaming false}instanceof? seems rather weird to me to be checking a nameisBigNumber once so i can find a work-around in my code 👍isBigNumber method seems to be working as well 🤓node-library and node-script . After I earlier thought that everything is actually working I now created a repro case that exhibits the same problems I’m seeing in a larger code base: https://github.com/martinklepsch/shadow-cljs-broken-node-source-maps:simple?:optimizations value:whitespace a try:advanced. it just moving code all over the place so the actual source-maps.core ns/file doesn't exist anymore since its just inline elsewhere:advanced$ node -r source-map-support/register out/main.js 0
Error: boom
at new $cljs$core$ExceptionInfo$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:11304:31)
at Function.<anonymous> (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/source_maps/core.cljs:4:9)
at $cljs$core$apply_to_simple$cljs$0core$0IFn$0_invoke$0arity$03$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:3890:15)
at $cljs$core$apply$cljs$0core$0IFn$0_invoke$0arity$02$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:3924:30)
at /mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:10028:46
at Object.<anonymous> (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/main.js:5698:3)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)(ns source-maps.core)
(defn main [x]
(when (zero? (js/parseInt x 10))
(throw (ex-info "boom" {:x x})))){:deps true
:builds
{:main
{:target :node-script
:main source-maps.core/main
:output-to "out/main.js"
:compiler-options {:source-map true}}}}sourcemap.clj returns lines in cljs-node-io.core as part of the stacktrace but the error is thrown elsewhere--debugrelease --debug?source-map-support/register?sourcemap.clj? that’s convenient 😅--debug fixing the issuesourcemap.clj--debug is basically :pseudo-names true + source mapspseudo-names and pretty-print
but also there’s so many variables that I’m losing trust that I can actually hold the different combinations in my head 😄--debug seems to do the trick and that is all I usepseudo-names and pretty-print individually but I’ll give --debug another try as well--debug is basically :source-map true :pseudo-names true :pretty-print true--pseudo-names is pseudo and pretty because sometimes its easier to debug without source mapsnpm install --save weakset and included ["weakset"] in my top-level require, but I'm still getting the error. Do I need to explicitly set js/window.WeakSet? Declare an extern? The user guide says that everything should be polyfilled down to IE10+, but I think I must be taking that out of context or something. Thanks!
(ns multicare-dfd.core (:require ["weakset"] [reagent.core :as reagent] ,,, ))
npm ls weakset just shows that my top-level module is the thing including it. What do you mean by polyfills like that?require call in it’s code was importing the package in the root of my project’s node_modules directory, which came from another libraries dependencies. I don’t think this is wrong but does anyone know what’s happening in JS land that some dependencies get flattened out"history" {:target :npm :require "@elastic/search-ui/node_modules/history"}util package before? https://www.npmjs.com/package/util
Should all users of shadow-cljs just run npm i util if some other package assumes that util is available?devDependencies. picard-facepalmdependencies.
This is not fine on Heroku, where it builds the production build, thus not installing anything in devDependencies.dev because anything unneeded just won't be used at all, thus there's no point in this explicit separation. But never mind.
The thing is, I didn't really need shadow-cljs as an NPM package in order to build the release version.
And of course it broke when I upgraded tinymce-react.
I'd blame tinymce-react for not specifying util as one of the dependencies. Hate this implicit stuff.The required JS dependency "inherits" is not available, it was required by "node_modules/util/util.js".Why does everything have to be implicit with all this stuff?
dependencies. I even upgraded NPM and removed node_modules. And would you look at that. And of course it doesn't work.npm ci.gh-pages is for GitHub pages) and version only your production artifacts in there, and this is what you push up to Heroku, not your dev branch. Another way to do it is have a separate shadow-cljs declaration for generating your prod build artifact which builds to a different location than the dev version, and have the build artifact versioned also.npm install on the remote as everything is bundled into the artifact.:dev/after-load aren’t working:preload namespaces are never loaded and :dev/after-load are never run{:paths ["src"]
:deps {thheller/shadow-cljs {:mvn/version "2.8.94"}
lilactown/helix {:local/root "../helix"}}}
how would I look for a dependency conflict in this case?clj -Stree to be sure thoughThe required JS dependency "core-js/library/fn/parse-int" is not available, it was required by "node_modules/@babel/runtime-corejs2/core-js/parse-int.js".
Search in:
/c/Users/Slawek/Work/foo/bar/node_modules
You probably need to run:
npm install core-js/library/fn/parse-int
See:
My dependencies are:
:dependencies [[reagent "0.8.1"]
[secretary "1.2.3"]
[venantius/accountant "0.2.4"]
[re-frame "0.10.5"]
[day8.re-frame/http-fx "0.1.6"]
[re-com "0.9.0"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[re-frisk "0.5.3"] ;NOTE enable only for debugging
]
have you seen something like that?npm ls and see which packages are doubledcore-jspackage.json file and I want to use that library in another project, do I have to declare the library's dependencies again in that project's package.json or can I somehow tell shadow-cljs to look at the library's package.json as well?deps.cljs file with {:npm-deps {"a-dependency" "version"}}npm install -g shadow-cljsThen I created a shadow-cljs.edn file, with the following:
{:source-paths
["src/cljs" "src/cljc" "dev"]
:dependencies
[]
:builds
{:app
{:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:myapp {:entries [myapp.system]}}}}}
Then in the already running clj repl, I do M-x cider-connect-sibling-cljs, and select the shadow repl option. But I get that shadow-cljs Clojurescript REPL is not available. How do I get shadow cljs to work?project.cljlein with-profiles +cljs run -m shadow.cljs.devtools.cli ...project.clj will apply but it has nothing to do with shadow-cljs:compiler-options {:output-feature-set :ecmascript-next}. that will basically not make it transpile anything.clojure -A:cider:cljs:shadow watch jarvis , it’s will build success. M-x cider-jack-in-cljs => chose shadow-cljs => chose :jarvis , i will get this Error: Build failure , The required namespace “shadow.remote.runtime.cljs.browser” is not available. {:deps {:aliases [:cljs]}
:builds {:jarvis {:target :browser
:output-dir "resources/public/js"
:modules
{:jarvis {:init-fn functor-api.core/init!}}
:devtools
{:http-port 8801
:http-root "resources/public"
:after-load functor-api.core/mount-components
:preloads [shadow.remote.runtime.cljs.browser]}}
:test {:target :browser-test
:test-dir "src/test/resources/public/js/test"
:devtools
{:http-port 8821
:http-root "src/test/resources/public/js/test"}}}}shadow.remote.runtime.cljs.browser what is this preload?2.8.94. the version you have didn't have that nsshadow-cljs alias. Are you adding this to the startup command when cider-jack-in?clojure -A:cider:cljs:shadow watch jarvis , then i cider-connect-in-cljs , it’s work require shadow.remote.runtime.cljs.browser.(compile '(.log js/console "hi")onclick attributeimport { Card } from 'antd'; -> ["antd" :refer (Card)] but const { Meta } = Card; ?(def Meta (.-Meta Card))server hosting cljs rest api server
localhost localhost:1234
shadow-cljs dev-release app and keep the server-config in :closure-defines?<script>your.app.init("the-server-url");</script> in your HTML and (ns ) (defn ^:export init [server-url] ...) in your codeshadow/node-repl with :reader-features #{:node} ? (i.e. without attaching to a specific build and with a “built in” runtime as node-repl provides)(shadow/node-repl {:config-merge [{:compiler-options {:reader-features #{:node}}]})Content-Security-Policy header is not being sent. Am I using :push-state/headers wrong?
{:source-paths ["src"]
:dependencies [[binaryage/devtools "0.9.7"]
[reagent "0.8.0-alpha2"]]
;; serve the public directory over http at port 8700
:dev-http {8700 {:root "public"
:push-state/headers {"Content-Security-Policy" "default 'self'"}}}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:common {:entries []}
:main {:entries [pwa.core]
:depends-on #{:common}}
:service-worker {:web-worker true
:depends-on #{:common}
:init-fn pwa.service-worker/init}}}}}lein new shadow-cljs pwa +reagent:push-state/headers look right?deps.cljs in the .jar it ships. they won't conflict..getResource vs .getResourcesdeps.cljs)"dependencies": {
"@auth0/auth0-spa-js": "^1.6.5",
and then from within cljs
(:require ["@auth0/auth0-spa-js" :as auth0] ... (auth0/createAuth0Client auth0-config)but I just see a
main.js:2226 failed to load uix.control_auth.js TypeError: module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.createAuth0Client is not a function
at eval (control_auth.cljs:23)
at eval (alpha.cljc:162)
at eval (alpha.cljc:140)
and when I look in the repl I see that the namespace is a function
(require '["@auth0/auth0-spa-js" :as nsauth]) => nil (type nsauth) => #object[Function]the
resources/public/js/cljs-runtime/module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.js.map
looks like
"names":[..., "createAuth0Client", ...]the original function is declared as
export default async function createAuth0Client(options: Auth0ClientOptions) {
so it IS default, (which I can call),
but why cannot I call the real function?
is it the ES8-only async causing linking problems?:compiler-options to
:compiler-options
{:infer-externs :auto
:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true#}
:output-feature-set :es8}
but it doesn't seem to have helped...createAuth0Client is not a function(type nsauth) => #object[Function]
(nsauth config)export default the only name that has is defaultdefault exports don't have a name. it is just the defaultimport Foo from "@auth0/auth0-spa-js" is just as valid as import createAuth0Client from "@auth0/auth0-spa-js":default exports are weirddocs/ instead of the default public/ and in Github's repo settings, enable pages from docs folder.npx shadow-cljs release app (assuming app is your build target) and 3) git push!index.html between two builds? By copying as part of the build step, perhaps?:release {:output-dir "foo"} in your build config:release :output-dir option :+1:public to build.material-ui). Is there something I am doing wrong? We're talking about < 1 second with figwheel and > 5 seconds with shadowmaterial-ui). Is there something I am doing wrong? We're talking about < 1 second with figwheel and > 5 seconds with shadow["@material-ui/core" :refer [Button Container]]
You don't only require Button and Container, but everything in core. To prevent that I had to require each component individually.
["@material-ui/core/Button" :default Button]
["@material-ui/core/Container" :default Container]
...
Maybe you're experiencing the same issue?["@material-ui/core/Button" :default Button] is it :default or :as ?[:> Component (for ...)] acting up with seqs, solvable by writing (into [:> Component] (for ...)) -- -- https://github.com/reagent-project/reagent/issues/369
• material-ui has started using hooks, which are messy to use in reagent (imo). I've just avoided them, but supposedly they can be used -- info: https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#hooks"dependencies": {
"@material-ui/core": "^4.9.8",
"@material-ui/icons": "^4.9.1",
"create-react-class": "^15.6.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"shadow-cljs": "^2.0.80"
}["@material-ui/core/Button" :default Button] it is much faster now, thanks!:target become a required field in a build in shadow-cljs.edn? all my builds have started complaining about it but i'm not sure why:target was always required(defn start-shadow [] (shadow-server/start!) (shadow/watch :app) (shadow/watch :bootstrap-support))This always worked but very suddenly started giving me a stack overflow error:
#error {
:cause nil
:via
[{:type java.lang.StackOverflowError
:message nil
:at [jt14$start_shadow invokeStatic "jt14.clj" 67]}]
:trace
[[jt14$start_shadow invokeStatic "jt14.clj" 67]
[jt14$start_shadow invoke "jt14.clj" 66]
[jt14$start_shadow invokeStatic "jt14.clj" 67]
[jt14$start_shadow invoke "jt14.clj" 66]
[jt14$start_shadow invokeStatic "jt14.clj" 67]
[jt14$start_shadow invoke "jt14.clj" 66]
[jt14$start_shadow invokeStatic "jt14.clj" 67]
[jt14$start_shadow invoke "jt14.clj" 66]
...
It works if I do each one of the three steps sequentially in a repl but not when I call the start-shadow function.
I tried updating my shadow dependency to the most recent version (from 8.69 to 8.94). Any clues what might be happening here? Is there a better way to fire up multiple watchers?shadow-cljs watch app bootstrap-supportshadow-cljs . Thank you ❤️import Cropper from 'react-easy-crop'so I am adding it like this:
["react-easy-crop" :default Cropper]But I am getting an error that
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.When printed, Cropper is undefined. Do I have to include it in another way?
["react-easy-crop" :as Cropper][{:type clojure.lang.ExceptionInfo
:message "aborted par-compile, [:shadow.build.classpath/resource \"re_frame/core.cljc\"] still waiting for #{re-frame.interop re-frame.interceptor re-frame.events re-frame.fx re-frame.registrar re-frame.router re-frame.std-interceptors re-frame.subs re-frame.cofx re-frame.db}"
:data {:aborted [:shadow.build.classpath/resource "re_frame/core.cljc"], :pending #{re-frame.interop re-frame.interceptor re-frame.events re-frame.fx re-frame.registrar re-frame.router re-frame.std-interceptors re-frame.subs re-frame.cofx re-frame.db}}
:at [shadow.build.compiler$par_compile_one invokeStatic "compiler.clj" 955]}] ...
What would cause these namespaces to be waited for like this?js field accesses with some-> instead of ->:
(def window (if (exists? js/window) js/window nil)) (def ^js jswindow (if (exists? js/window) js/window nil)) (js/console.log (-> js/window .-test)) (js/console.log (-> jswindow .-test)) (js/console.log (-> window .-test)) (js/console.log (-> js/window .-test .-identity)) (js/console.log (some-> js/window .-test .-identity)) (js/console.log (-> jswindow .-test .-identity)) (js/console.log (some-> jswindow .-test .-identity)) (js/console.log (-> window .-test .-identity)) ;; <---- Inference warning only here (js/console.log (some-> window .-test .-identity))It was observed on
2.8.68 and reproduced on 2.8.93.
Is it expected/unavoidable?:closure-defines in shadow-cljs.edn. There is also the debugging library that forces to have different version between dev/prod for re-frame.:repl-init-ns , but it does not seem to work. I'm connecting with the command (shadow.api/nrepl-select :app){:builds
{:app {:asset-path "/js"
:modules {:main {:init-fn app.main/init}}
:output-dir "public/js"
:target :browser
:devtools {:repl-init-ns app.main}}}
:dependencies [[reagent "0.8.1"]]
:dev-http {3000 "public"}
:http {:port 9631}
:source-paths ["src"]}:devtools key in the build map. but the example shows it there~/p/c/asg-ignite-app ❯❯❯ shadow-cljs cljs-repl app shadow-cljs - config: /Users/dan/projects/clojure/asg-ignite-app/shadow-cljs.edn cli version: 2.8.83 node: v12.1.0 shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.83 running at shadow-cljs - nREPL server started on port 63308 app.main=>
(defn start! [] (shadow.server/start!) (shadow.api/watch :workspaces) (watch-with-profile :app :dev) (shadow.api/nrepl-select :app))
------ WARNING #1 - ----------------------------------------------------------- Resource: Failed to resolve sourcemap at out/cljs/pprint.js.map: out/cljs/pprint.js.map --------------------------------------------------------------------------------I was earlier using
shadow-cljs.edn for dependencies and it was throwing the same set of warnings but still worked. Now I moved dependencies to deps.end and it stopped working entirely.
;; deps.edn
{:paths ["src"]
:deps {cljs-http {:mvn/version "0.1.46"}
reagent {:mvn/version "0.10.0"}
re-frame {:mvn/version "0.12.0"}
re-frame-utils {:mvn/version "0.1.0"}
thheller/shadow-cljs {:mvn/version "2.8.94"}}}
;; shadow-cljs.edn
{:builds {:app {:asset-path "/js"
:modules {:app {:init-fn com.github.hindol.twenty-nine/init}}
:output-dir "public/js"
:target :browser
:http-root "public"
:release {:output-dir "../docs/js"}}}
:deps true
:dev-http {3000 "public"}}
All the warnings started after I added re-frame-utils to the mix. I kind of need the FX and COFX stuff from the library. I am willing to copy those functions over if there is no easy fix.[clojure.pprint :as pp] in a couple of places.
There are a bunch of other errors (total 29 of them, all same type of warning),
------ WARNING #21 - ---------------------------------------------------------- Resource: Failed to resolve sourcemap at out/reagent/debug.js.map: out/reagent/debug.js.map -------------------------------------------------------------------------------- ------ WARNING #22 - ---------------------------------------------------------- Resource: Failed to resolve sourcemap at out/reagent/dom.js.map: out/reagent/dom.js.map --------------------------------------------------------------------------------
0 Thu Oct 05 10:21:04 CEST 2017 out/reagent/ 10627 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.cljs 33164 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.cljs.cache.edn 30952 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.js 12618 Thu Oct 05 10:21:04 CEST 2017 out/reagent/core.js.map 614 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.cljs 2007 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.cljs.cache.edn 2864 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.js 1150 Thu Oct 05 10:21:02 CEST 2017 out/reagent/debug.js.map 2702 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.cljs 7765 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.cljs.cache.edn 6720 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.js 3362 Thu Oct 05 10:21:04 CEST 2017 out/reagent/dom.js.map
out folder shouldn't be included in the distributed .jar fileproject.clj? I don't see how that is being included in the jar.deps.edn, it stopped working.:deps true i have this error with devtools:
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.thheller/shadow-cljs {:mvn/version "2.8.94"}nubank/matcher-combinators with Shadow? I'm requiring matcher-combinators.test in my cljc ns, but the :browser-test target is not picking up any such assertions: (is (match? 2 1)) If I switch to (is (= 2 1)) the error is reported and I have +1 assertions total.:match return value here: https://github.com/mauricioszabo/check/blob/master/src/check/core.cljc#L13-L24{:paths ["src/cljs"]
:deps
{thheller/shadow-cljs {:mvn/version "2.8.94"}
binaryage/devtools {:mvn/version "1.0.0"}
reagent {:mvn/version "0.10.0"}
re-frame {:mvn/version "0.12.0"}
day8.re-frame/http-fx {:mvn/version "v0.2.0"}}
:aliases
{:dev
{:extra-deps
{day8.re-frame/tracing {:mvn/version "0.5.3"}}}
:prod
{:extra-deps
{day8.re-frame/tracing-stubs {:mvn/version "0.5.3"}}}}}
[:app] Build failure:
The required namespace "day8.re-frame.tracing" is not available, it was required by "frontend/events.cljs".node_modules/vega-lite. so make sure that is actually the version you want.shadow$provide["module$node_modules$vega_lite$build$vega_lite"] = function(global,require,module,exports) {
var Buffer = require('buffer').Buffer;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.vegaLite = {}));
}(this, (function (exports) { 'use strict';
var name = "vega-lite";
var author = "Dominik Moritz, Kanit \"Ham\" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer";
var version = "4.2.0";
var collaborators = [
"Kanit Wongsuphasawat ()",
"Dominik Moritz ()",
"Arvind Satyanarayan ()",
"Jeffrey Heer ()"
];
etc...
At the address http://js/compiled/cljs-runtime/node_modules/vega-lite/build/vega-lite.js
Which is maybe derived from ./resources/public/js/compiled/cljs-runtime/module\$node_modules\$vega_lite\$build\$vega_lite.js
(which states the version as 4.2.0)
I grepped the project, and this is the only vega-lite + 4.2.0 mention I found.
Also, an error message says that the version running is 4.2.0.
I wonder what may cause it.node_modules?<project>/node_modules/vega-lite assuming you didn't overwrite any path related stuff in your config{:lein true
:nrepl {:port 8777}
:builds {
:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn crystal-web-client.core/init
:preloads [devtools.preload
day8.re-frame-10x.preload]}}
:dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:devtools {:http-root "resources/public"
:http-port 8280}
}
resources/public/js/compiled dir or the .shadow-cljs/builds cache dir:target in shadow-cljs is likely not what you mean?:modules:init-fn is shadow-specific, right?{:init-fn foo.bar/init} is basically sugar for {:entries [foo.bar] :append-js "foo.bar.init();"} but :append-js per module is also shadow-cljs specific:modules integration in shadow-cljs is so completely different that it will be non-trivial to adopt this for core:simple compiled CLJS for the "normal" pages that aren't even using CLJS?:advanced build for regular page stuff:advanced one will be much much smaller:simple compiled version of cljs?:advanced compiled CLJS build. highly optimized for one particular thing and not extensible at all 😛—config-merge with a edn files? (Having a $(cat config.edn) I guess?)Exception in thread "async-dispatch-17" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: clojure.
lang.PersistentVector
at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:979)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async$ioc_alts_BANG_$fn__3086.invoke(async.clj:385)
at clojure.core.async$do_alts$fn__3018$fn__3021.invoke(async.clj:254)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__670.invoke(channels.clj:265)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)[org.clojure/core.async "1.0.567"] if you are on .94[org.clojure/core.async "1.1.587"] with the next release:asset-path:asset-path.:bootstrap support build target right?:asset-path as you suggested.:bootstrap target ...Davids-MBP:~ Dave$ cd projects Davids-MBP:projects Dave$ cd hone-master/ Davids-MBP:hone-master Dave$ shadow-cljs watch app shadow-cljs - config: /Users/Dave/Projects/hone-master/shadow-cljs.edn cli version: 2.8.83 node: v13.12.0 shadow-cljs - starting via "clojure" running: npm install --save
npm install react does nothingpackage.jsonnpm init in your project and then npm install shadow-cljs react react-domshadow-cljs watch app again and got a different error
NPM dependency "react" has installed version "^16.13.1"
"16.9.0" was required by jar:file:/Users/Dave/.m2/repository/reagent/reagent/0.9.1/reagent-0.9.1.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.13.1"
"16.9.0" was required by jar:file:/Users/Dave/.m2/repository/reagent/reagent/0.9.1/reagent-0.9.1.jar!/deps.cljs
[2020-04-07 12:51:04.188 - WARNING] :shadow.cljs.devtools.server.nrepl04/middleware-fail - {:sym refactor-nrepl.middleware/wrap-refactor}
FileNotFoundException Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
the print out was very long but that seems to be the meat and potatoes(js/window.addEventListener "beforeunload"
(fn []
(when-let [s @socket-ref]
(.close s)))):builds:modules. see https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers:devtools {:browser-inject false} I guess(tap> #'re-frame.db/app-db)with this
Datafiable protocol extension:
(ns foo.utilities.debug
(:require [clojure.core.protocols :as p]
[reagent.ratom]
[shadow.remote.runtime.cljs.browser]))
(extend-type reagent.ratom/RAtom
p/Datafiable
(datafy [x]
@x))datafy is called when the object is added and "described"(tap> {:foo re-frame.db/app-db}){:type java.lang.IllegalArgumentException
:message "Cannot open <nil> as a Reader."
:at [$fn__11520 invokeStatic "io.clj" 288]}
shadow-cljs watch app i mean there is a lot more I just wanted to avoid putting the whole thing in here because it would be very long:release {:output-dir "build/js"}? I only learned of this option recently myself.:modules {:main ...}:main becomes main.js:output-dir specifies which directory the files are written to:output-dirappropriatemain-production.js or whatever it is advised to use a different directory for ALL files/js/compiled/main.js or /js/dev/main.js or whatever:modules {:main ...} becomes main.js. :modules {:foo ...} becomes foo.js{:output-dir "../dist" :modules {:new-filename {:init-fn app.core/main}}} creates ../dist/new-filename.js
I am sorry for being thick headed at first:output-dir "../dist/js" or soui at the top level. its shadow-cljs.edn specifies :output-dir "static/dev/admin-ui" (note the "dev" folder). I have :release {:output-dir "static/admin-ui"} (note the lack of "dev". Then in my Django settings:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_DEV = os.path.join(BASE_DIR, "ui", "static", "dev")
STATICFILES_DIRS = []
if os.path.isdir(STATIC_DEV):
STATICFILES_DIRS += [STATIC_DEV]
STATICFILES_DIRS += [os.path.join(BASE_DIR, "ui", "static")]
What this does is cause /static/ to resolve files in ui/static/dev and also in ui/static and the "dev" variant only exists on my local while running npx shadow-cljs watch app. It never appears on the live site. Note that ui/static/dev and ui/static appear to be overlayed, so if you request /js/main.js it will first look relative to the dev folder, and then look relative to the other non-dev folder.(ns status-im.react-native.js-dependencies-mock):build-options {:ns-aliases {status-im.react-native.js-dependencies status-im.react-native.js-dependencies-mock}}js-dependencies use the mock instead:resolve option to mock things https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve:js-options {:js-provide :require} (assuming its a :browser) build and provide your own require fn that returns the mocks<script>window.require = function(name) { if (name == "foo") { return {} } else ... }; </script>require fnreact -> preact or soCouldn't satisfy such-that predicate after 10 tries when trying to generate a schema.
I’m asking for help here because if I use clojurescript version 1.10.597 and the cljs.build.api everything works fine. Do you have any clue about what may be happening?
I thought it could a dependecy issue, but I compared both dependency trees (printed with lein deps :tree) and the tree using version 2.8.83 and 2.8.84 are identical (with exclusions loom pathom and core.async). Maybe I’m missing something when checking the dependencies. I have a sample project reproducing the issue at:
https://github.com/felipethome/sg-issue[com.google.javascript/closure-compiler-unshaded "v20191027"] [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"] [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
shadow-cljs watch appAnd
shadow-cljs release appI different config-variables for each environment. On the serverside I use yogthos/config with lein. And I simply specify which profile to use.
The required namespace "cljs.user" is not available. Evaluating more code with Fireplace still works...shadow-cljs watch app and that’s when I would get the issue, so I instead tried starting shadow as a clj repl shadow-cljs clj-repl, then doing (shadow/watch :app), and then when I connect Fireplace and run CljEval (shadow/repl :app), it seems to be working fine now?The required namespace "cljs.user" is not available. comes and goes away sporadicallywhen body in
(goog-define X "") (when (seq X) ...)?
(when-not (identical? X "") ..) might have better chances$ node
> const admin = require('firebase-admin');
undefined
> admin.initializeApp();
FirebaseApp { ... }
> const functions = require('firebase-functions')
undefined
> functions.config()
{}
> functions.config().constructor
[Function: Object]
> functions.config().constructor == Object
true
$ npx shadow-cljs cljs-repl :functions
shadow-cljs - config: /Users/martinklepsch/code/06-commercial/icebreaker/shadow-cljs.edn cli version: 2.8.37 node: v10.16.3
shadow-cljs - connected to server
> (.-constructor (.config fb-functions))
#js {:some :js-obj}
> (object? (.config fb-functions))
false$ node
> const admin = require('firebase-admin');
undefined
> admin.initializeApp();
FirebaseApp { ... }
> const functions = require('firebase-functions')
undefined
> functions.config()
{}
> functions.config().constructor
[Function: Object]
> functions.config().constructor == Object
true
$ npx shadow-cljs cljs-repl :functions
shadow-cljs - config: /Users/martinklepsch/code/06-commercial/icebreaker/shadow-cljs.edn cli version: 2.8.37 node: v10.16.3
shadow-cljs - connected to server
> (.-constructor (.config fb-functions))
#js {:some :js-obj}
> (object? (.config fb-functions))
false> (.config fb-functions) == JS EXCEPTION ============================== ENCODING FAILED, check host console ==============================================
object? check?== Object does?== Object so I don't quite see the point of that check?object? basically{}js/Symbol, etc(js/console.dir (.config functions)) or soclj->js or cljs-bean(js/console.dir (.config functions)) logs the config data to the consolejs/console.log does too actually(shadow.json/to-clj (.config functions))to-clj doesn’t exist somehowCannot read property 'findInternedVar' of null when using eval-str Here is my http://shadow.cl-cljs.edn
{:deps true
:builds
{:app
{:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:optimizations :simple}
:modules {:main {:entries [jt.jt16]}}
:devtools {:repl-init-ns jt.jt16}}
:bootstrap-support
{:target :bootstrap
:output-dir "resources/public/bootstrap"
:exclude #{cljs.js}
:entries [javelin.core diy.core diy.hoplon.tpl #_ui]
:macros []}}}x.findInternedVar() is called where x is nilmain.js:3742 Uncaught ReferenceError: goog is not defined
at eval (/bootstrap/js/3bcbd8d8.cljs.core$macros.js:1)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:461)
at Object.shadow.cljs.bootstrap.browser.script_eval (main.js:10070)
at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (main.js:10073)
at main.js:10083
at goog.async.run.processWorkQueue (main.js:3749)
type errorsgoog isn't defined when bootstrap/init tries to load the first bootstrap file and this is breaking all my eval-str calls:compiler-options {:output-wrapper false} in your :app configshadow-cljs currently provides no support for directly compiling CSS but the usual tools will work and should be run separately. Just make sure the output is generated into the correct places.public dispose(disposeAll = true): void {
super.dispose(disposeAll);
if (this._depthRenderer && disposeAll) {
delete this._depthRenderer.getDepthMap().getScene()?._depthRenderer[this._depthRendererId];
this._depthRenderer.dispose();
this._depthRenderer = null;
}
}
and the error I get is: "Invalid delete operand. Only properties can be deleted."
If I understand correctly the issue is the usage of the "?." operator together with "delete" and it can be fixed by using an if statement instead.
However I'd rather avoid patching the library. Do I have other options here like maybe a compiler flag to pass to shadow-cljs ?DepthReducer.prototype.dispose = function (disposeAll) {
if (disposeAll === void 0) { disposeAll = true; }
var _a;
_super.prototype.dispose.call(this, disposeAll);
if (this._depthRenderer && disposeAll) {
if(this._depthRenderer.getDepthMap().getScene())
delete this._depthRenderer.getDepthMap().getScene()._depthRenderer[this._depthRendererId];
this._depthRenderer.dispose();
this._depthRenderer = null;
}
};delete or a bug in the closure compilerDepthReducer.prototype.dispose = function (disposeAll) {
if (disposeAll === void 0) { disposeAll = true; }
var _a;
_super.prototype.dispose.call(this, disposeAll);
if (this._depthRenderer && disposeAll) {
delete ((_a = this._depthRenderer.getDepthMap().getScene()) === null || _a === void 0 ? void 0 : _a._depthRenderer[this._depthRendererId]);
this._depthRenderer.dispose();
this._depthRenderer = null;
}
};{:devtools {:after-load my-devtools/reload}.
But the hook is not called (`reloading code but no :after-load hooks are configured!`).
I imagine that because I'm not requiring my namespace (`my-devtools`) anywhere in my code it is not running the function. Because, when I add a require into my main-file it runs the hook.
Is this the expected behavior? I would think that shadow-cljs would require que namespace specified in the devtools.:devtools {:preloads [your.ns.with-hooks]}(defn ^:dev/after-load the-hook [] ...)(:require [my-devtools]) at some file that is compiled and loaded by shadow and then trigger the reload by editing some file, the hook runs.shadow-cljs watch app --config-merge "{:devtools {:preloads [hooks.that.only.i-want]}"shadow.cljs.devtools.api .(defn watch-with-profile
[build-id profile]
(println "Running " build-id " with profile " profile)
(-> (shadow.config/get-build! build-id)
(assoc :profile profile)
set-devtools-hooks
shadow.api/watch))(shadow.api/watch :the-build {:config-merge [{:devtools {:preloads '[the.extra]}}]})shadow.api/watch had this option, cool!:cljs-tests with the following config:
{:target :node-test
:js-options {:node-modules-dir "../"}
:output-to "out/node-tests.js"
:autorun true
:main my-app-name.events-test/start}
From the documentation, it's my understanding that I can specify a main as the entry point to running the tests. For now, I just have that hardcoded to a my-app-name.events-test/start , which just invokes cljs.test/run-tests:
(defn start [] (cljs.test/run-tests))In CLI, I'm running
npx shadow-cljs compile cljs-tests . The process outputs "Compiling..." for a while, then spits out this error:
aborted par-compile, [:shadow.build.classpath/resource "my_app_name/events_test.cljs"] still waiting for #{my-app-name.events-test}
{:aborted [:shadow.build.classpath/resource "my_app_name/events_test.cljs"], :pending #{my-app-name.events-test}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "my_app_name/events_test.cljs"] still waiting for #{my-app-name.events-test}
shadow.build.compiler/par-compile-one (compiler.clj:854)
shadow.build.compiler/par-compile-one (compiler.clj:819)
shadow.build.compiler/par-compile-cljs-sources/fn--12733/iter--12755--12759/fn--12760/fn--12761/fn--12762 (compiler.clj:937)
clojure.core/apply (core.clj:665)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/apply (core.clj:669)
clojure.core/bound-fn*/fn--5734 (core.clj:2003)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
java.lang.Thread.run (Thread.java:834)
Do you know what I might be missing?:main at all because its what it does by default?main option. Thanks:main applies to :node-script only:node-test you'd use :runner-ns if a custom runner is needed:main just confuses the compiler I guess:main should work fine:main for node-test target. I can send a PR if that's alright?window is not defined, which makes sense in a node runtime. Wondering if I should try to mock window or use the :browser-test target.
I'm not performing any UI tests, just business rule logic in CLJS, but cljs/shadow-cljs seem to be pulling in all of my NPM dependencies, many of which reference window:node-test:ns-regexp to get only the tests and which will probably not depend on the window object. https://shadow-cljs.github.io/docs/UsersGuide.html#_testing(:require [cljs.repl :refer [doc]]) regardless of which ns I'm in(cljs.repl/doc foo) from anywhere. having (doc foo) available does not work without you requiring it(require 'cljs.repl) was done somewhere so that the ns is loaded(shadow/repl :main) ;=> [:selected :main] (import 'goog.Uri) ;------ REPL Error while processing --------------------------------------------- ;(import 'goog.Uri) ;... ;ExceptionInfo: ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form) ; shadow.build.compiler/post-analyze (compiler.clj:95)? OK, the error says I cannot use import, but why not / why does the page above (which, of course, is not about Shadow) talks about REPL? Is that a limitation of shadow REPL compared to vanilla cljs? (I can use the classes, just not import them)
shadow-cljs.edn:
{:devtools {:repl-pprint true}}
doc: https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_3(require 'goog.Uri) does the sameimport so I keep forgetting to implement it properlynet::ERR_CONNECTION_REFUSED means the browser failed to connect to localhost:9631shared.js:180 shadow-cljs - failed to load 7
LB @ shared.js:180
shadow$provide.<computed> @ main.js:18
LB @ shared.js:180
$APP.Ho @ shared.js:180
(anonymous) @ main.js:3198
(anonymous) @ main.js:4036
shared.js:180 shadow-cljs - failed to load 11
LB @ shared.js:180
$APP.Ho @ shared.js:180
(anonymous) @ main.js:3198
(anonymous) @ main.js:4036
shared.js:180 Uncaught TypeError: $jscomp.initSymbol is not a function
at Object.shadow$provide.<computed> (main.js:9)
at LB (shared.js:180)
at Object.shadow$provide.<computed> (main.js:18)
at LB (shared.js:180)
at Object.$APP.Ho (shared.js:180)
at main.js:3198
at main.js:4036
Any idea what could be causing this??failed to parse websocket message {:type :repl/init, :repl-state {:shadow.cljs.repl/repl-state true, :current-ns ....Wh = function(a, b) {
var c = oaa[a];
if (void 0 !== c)
return c;
try {
Th.push(a);
var d = Uh[a]
, e = shadow$provide[a];
if (void 0 === d) {
if (void 0 === e)
throw "Module not provided: " + a;
d = {
exports: {}
};
Uh[a] = d
}
if (e) {
delete shadow$provide[a];
try {
e.call(d, $APP.Vh, Wh, d, d.exports)
} catch (k) {
throw console.warn("shadow-cljs - failed to load", a),
k;
}
if (b) {
var f = b.globals;
if (f)
for (c = 0; c < f.length; c++)
window[f[c]] = d.exports
}
}
} finally {
Th.pop()
}
return d.exports
}:compiler-options {:output-wrapper false} too. looks like it has an issue with scoping somewhere?require must always be completely static so even if it was allowed outside the ns you still can't do anything that you can't do with ns anways(def foo (some-fn foo)) (def bar (some-fn bar)) (def baz (some-fn baz))for some reason I'm not able to resolve the symbol
data in a clojurescript macro 😕(def data ["foo" "bar" "baz"])
(defmacro test-macro
[data]
`(do
resolve part(defn ^:export ready
"Returns true the tick after no events are left to process in the re-frame queue"
[]
(let [state (.-fsm-state (:event-queue re-frame/default-frame))
dr @deferred-ready]
(cond
(and (= state :idle) (not dr))
(do
(if (exists? js/requestIdleCallback)
(js/requestIdleCallback #(reset! deferred-ready true))
(js/requestAnimationFrame #(reset! deferred-ready true)))
false)
(and (= state :idle) dr)
true
:else
(reset! deferred-ready false))))(defn ^:export ready
"Returns true the tick after no events are left to process in the re-frame queue"
[]
(let [state (.-fsm-state re-frame.router/event-queue)
dr @deferred-ready]
(cond
(and (= state :idle) (not dr))
(do
(if (exists? js/requestIdleCallback)
(js/requestIdleCallback #(reset! deferred-ready true))
(js/requestAnimationFrame #(reset! deferred-ready true)))
false)
(and (= state :idle) dr)
true
:else
(reset! deferred-ready false)))):devtools {:reload-strategy :full} in your build configdom-utils.js from a js module js-main.js which is required by a root.cljs .
js-main.js is loaded just fine, but dom-utils.js isn’t.
;root.cljs
(ns website.main
(:require ["./js-main" :as main]))
(defn init []
(main/onDomReady))
; js-main.js
import {func1} from "./dom-utils.js"
export const onDomReady = () => func1("bar")
; dom-utils.js
export const func1 = (x) => foo(x)
All js files are laying in the same dir/package as main.cljs.
In shadow cljs target is
:dev
{:target :browser
:modules {:main {:init-fn website.main/init}}
:output-dir "resources/public/website"
:asset-path "/website"
:compiler-options {:output-feature-set :es8}}
___________
Issue
Browser says TypeError: Cannot read property 'func1' of null
---------
I see dom-utils.js file in sources tab, by the path /website/cljs-runtime/website/dom-utils.js
So perhaps I misconfigured output path or import.export const function func1(x) ... or so?=> so I don't know if it should be considered a bug or not:compiler-options
{:output-feature-set :es8}
:output-feature-set :es8 part. Arrows work now.
If I re-enable that it doesn’t matter arrows or not, nothing from dom-utils.js will be visible in js-main.js.shadow-cljs/builds to even get Shadow-cljs to use the new sources.------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/ol/Feature.js:107:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: node_modules/ol/layer/BaseVector.js:106:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #3 - ----------------------------------------------------------- Resource: node_modules/ol/layer/Layer.js:131:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #4 - ----------------------------------------------------------- Resource: node_modules/ol/renderer/Layer.js:52:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #5 - ----------------------------------------------------------- Resource: node_modules/ol/renderer/canvas/Layer.js:57:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #6 - ----------------------------------------------------------- Resource: node_modules/ol/renderer/webgl/Layer.js:87:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #7 - ----------------------------------------------------------- Resource: node_modules/ol/source/Vector.js:89:20 Parse error. name not recognized due to syntax error. -------------------------------------------------------------------------------- ------ WARNING #8 - ----------------------------------------------------------- Resource: node_modules/ol/source/Vector.js:216:20 Parse error. name not recognized due to syntax error. --------------------------------------------------------------------------------
_this.geometryChangeKey_ = null;@type {?import("./events.js").EventsKey}:infer-externs , and I am getting a warning from anything in my code that implements reagent.ratom.IReactiveAtom, which is just a methodless tag interface. The error looks like: Cannot infer target type in expression (. (. Example -prototype) -reagent$ratom$IReactiveAtom$)(deftype Example [] reagent.ratom.IReactiveAtom)
(:require [reagent.ratom :as ratom]) and (deftype Example [] ratom/IReactiveAtom)2.8.96lein classpath or clojure -Spath but I could not find something similar for shadow-cljs. Any tips on getting the classpath for a shadow-cljs project?shadow-cljs --helpshadow-cljs classpathshadow-cljs, deps.edn and cider working nicely together?
Things work perfectly just using shadow-cljs and cider but when I try to use deps.edn as well the cider-jack-in-cljs stops working.
I select cider-jack-in-cljs -> clojure-cli and then my build and I get the following error.
error in process filter: The shadow-cljs ClojureScript REPL is not available. Please check for detailsCannot infer target type in expression (. c__41761__auto__ -ratomGeneration) when using r/with-let -form in reagent (in a react native project). The article would suggest that I should be use to tag it using ^clj but this does not help. Is this a known issue? I can always revert back to (let [] (fn [] ...)) and it works.^clj tag so should workreactand
react-dom
.css file for you<link rel="stylesheet" href="/css/whatever.css"><link href="" rel="stylesheet">resources/ path? I have resources as a source path in my deps.edn and :deps true in shadow-cljs.edn but when I try to require public.code.myns which is located in resources/public/code/myns.cljs I'm getting "The required namespace "public.code.myns" is not available"(ns public.code.myns)?resources/public is filtered by default because it is were people usually output there code toimport React from ‘react’; this is the issue, should be import * as React from "react";.default property which react doesn't havefailed to parse websocket message... when whatching my project and running electron.
I was just abouit to open an issue right now, and it's already fixed! Thanks a lot 😄failed to parse websocket message {:type :repl/init, :repl-state {...lots of things here...[:browser-repl] Build completed. (130 files, 0 compiled, 0 warnings, 2.55s) null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:535). Assert failed: (symbol? read-ns)
2.8.98, I accidentally broke the REPL in 2.8.9519:40:50.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 19:40:51.646 [main] INFO io.undertow - starting server: Undertow - 2.0.30.Final 19:40:51.655 [main] INFO org.xnio - XNIO version 3.8.0.Final 19:40:51.664 [main] INFO org.xnio.nio - XNIO NIO Implementation Version 3.8.0.Final 19:40:51.728 [main] INFO org.jboss.threads - JBoss Threads version 3.1.0.Final 19:40:51.737 [XNIO-1 I/O-2] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-2', selector
shadow-cljs clj-repl ( "logback.xml") or solog4j.properties in one classpath root with
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{HH:mm:ss,SSS}] %m%n.js files. the system isn't really tuned for that and has a lot of issues I haven't had time to work on.{init-fn app.core/init} is incorrect though{:source-paths ["src"]
:dependencies [[nrepl "0.7.0"]
[cider/cider-nrepl "0.25.0-alpha1"]
[proto-repl "0.3.1"]
[binaryage/devtools "1.0.0"]
[reagent "0.10.0"]
[re-frame "0.12.0"]
[day8.re-frame/re-frame-10x "0.6.2"]
[bidi "2.1.6"]
[kibu/pushy "0.3.8"]]
:nrepl {:port 3334}
:dev-http {8080 "public"}
:builds
{:app
{:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main
{:init-fn app.core/init
:preloads [day8.re-frame-10x.preload]}}
:dev
{:compiler-options
{:closure-defines {re-frame.trace/trace-enabled? true
day8.re-frame.tracing/trace-enabled? true}}}}}}shadow-cljs watch app should complain about the bad {init-fn ...}?{init-fn ...} will fail properly and show an error.js you are loading was not produced by the running watchpublic/js(ns app.foo) you also have (ns app.foo-spec) and then load that ns via :preloads or some other means:preloads is badly named yes but it is what it is. It is for namespaces that should only be added to the build in development.(ns foo.bar) should be foo/bar.cljs(ns foo.with-a-dash) should be foo/with_a_dash.cljsprn not showing up I don't know. if you do everything correctly it should.$jscomp errors when using dependencies that ship es6+ code, unless I bump :output-feature-set to match the level required not to compile them$jscomp.makeIterator
changing the :output-feature-set to :es6 makes these go away.
then I try and type something in a field, which throws an error about $jscomp with the stacktrace pointing at an async function.
bumping the :output-feature-set to :es8 makes this go away.losure compilation failed with 1 errors --- App.js:6 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
[:dev] Build failure: ------ ERROR ------------------------------------------------------------------- File: /Users/spacegangster/clj/lightpad/client/src/flow/views/tasks/microtasks.cljs:6:1 -------------------------------------------------------------------------------- 3 | [space-ui.style.constants :as sc] 4 | [space-ui.style.constants :as sc])) 5 | 6 | (def ^:const dim-item-side-px (sc/px sc/dim-step)) -------^------------------------------------------------------------------------ Error in phase :compilation Can't redefine a constant at line 6 flow/views/tasks/microtasks.cljs -------------------------------------------------------------------------------- 7 | (def ^:const dim-fs ".9rem") 8 | 9 | (def rules1 10 | [:.microtasksVersion output
=== Version jar: 2.8.97 cli: 2.8.97 deps: 1.3.2 config-version: 2.8.97Previously was on: ^2.8.91
^:const. it doesn't do what you think it does. do not use it. there is no point. also why is [space-ui.style.constants :as sc] imported twice? line 3/4?bash was bad but the syntax of powershell is ridiculous .. who comes up with this shit ...:configure step, and the :compile-prepare step, but that’s not working so swellrequire for node-test target how can I make sure it's added at the top of the js filerequire(function(){
var Module = require('module');
var originalRequire = Module.prototype.require;
Module.prototype.require = function(){
// if react-native module return mock
return originalRequire.apply(this, arguments);
};node --require=./your-require-override.js the-output.jsrequire is first used:preloads but there is no :preloads-that-also-apply-in-releaseSyntaxError: Cannot use import statement outside a module
shadow.js.shim.module$react_native_languages = require("react-native-languages");init fn that is called when your code is loaded<script>your.app.init("with-the-data-you-need");</script>(defn init [the-data] ...)<script>your.app.init("with-the-data-you-need");</script>index.html index-dev.html index-boss.html etc:init-fn some.ns/init then yes that calls init without args. you can will put the config into the html via <script>_CONFIG = "whatever";</script> and access it in into via (js/console.log js/MY_CONFIG)SHADOW import error /home/yenda/status-react/target/test/cljs-runtime/shadow.module.main.append.js
/home/yenda/status-react/node_modules/source-map/lib/util.js:343
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
^
RangeError: Maximum call stack size exceeded
at compareByGeneratedPositionsDeflated (/home/yenda/status-react/node_modules/source-map/lib/util.js:343:45)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:88:11)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)(let [react-dom-server (js/require "react-dom/server")]
(.renderToStaticMarkup react-dom-server src))))
I’m just wondering, is this kind of approach something that Shadow’s npm module system supports?js/require calls in browser builds. if this runs in an environment that has an actual js/require then it would work but shadow-cljs has no hand in that?ns require is needed for the npm module to be included in release builds? I hope that question makes more sense, sorry 🙂require("a-thing") if you (:require ["a-thing" :as x])ns form. it does not pick up js/require calls in the codejs/require calls but that might give people ideas of using it dynamically and so on which won't work.js file that still has require calls in the codereact and so on while a node build will not (by default){...
:builds
{:app
{:target :browser
...
:modules {:app {:entries []}}
;; to enable in development only
:dev {:closure-defines { true}}
;; to enable always
:closure-defines { true}
;; you may also enable it for release as well
:release {:closure-defines { true}}
}}(ns ) (goog-define VERBOSE false)
(def VERBOSE false)defTesting status-im.test.chat.models.message
SHADOW import error /home/yenda/status-react/target/test/cljs-runtime/shadow.module.main.append.js
/home/yenda/status-react/node_modules/source-map/lib/util.js:373
function strcmp(aStr1, aStr2) {
^
RangeError: Maximum call stack size exceeded
at strcmp (/home/yenda/status-react/node_modules/source-map/lib/util.js:373:16)
at compareByGeneratedPositionsDeflated (/home/yenda/status-react/node_modules/source-map/lib/util.js:354:9)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:88:11)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
yarn shadow-cljs compile mocks && yarn shadow-cljs compile test && node --require ./test-resources/override.js target/test/test.js
override.js is here https://github.com/status-im/status-react/pull/10217/commits/80e7685cc772b8e0aa08f6c9325aeed7266902d5#diff-31223e9c64942d5ed5214807141c977esource-map also modifies require I think so you might just get in its way?release build. that won't include the source-map package (unless you do manually)Resource: mocks/js_dependencies.cljs:47:1 constant ReactNative assigned a value more than once. Original definition at externs.shadow.js:2
Testing status-im.test.chat.models.message ERROR in (add-received-message-test) (TypeError:NaN:NaN) Uncaught exception, not in assertion. expected: nil actual: #object[TypeError TypeError: lV.a is not a function] DEBUG [status-im.native-module.core:259] - [native-module] is24Hour
ERROR in (add-received-message-test) (TypeError:NaN:NaN) Uncaught exception, not in assertion. expected: nil actual: #object[TypeError TypeError: status_im.chat.models.message.add_message.cljs$core$IFn$_invoke$arity$2 is not a function]than random max call stack exceeded 😄
shadow-cljs release tests --debug also helps:compiler-options {:static-fns false}npm install it and start using it right?lein new re-frame <project-name>
main: cjs/index.js, and if you go to that file it’s exporting everything["react-bootstrap" :refer (Button)][Button] too@microsoft/office-js``. I use the shadow-cljs re-frame example for
experiments and modified the namespace declaration in views.clj`` to be
(ns demo.views
(:require [demo.routes :as routes]
[demo.subs :as subs]
[re-frame.core :as re-frame]
["@microsoft/office-js" :as office]))
and get the error
[:app] Compiling ...
[:app] Build failure:
module without entry or suffix: @microsoft/office-js… ExceptionInfo: module without entry or suffix: @microsoft/office-js Clojure.core/ex-info (core.clj:4739) clojure.core/ex-info (core.clj:4739) shadow.build.npm/find-package-require (npm.clj:207) shadow.build.npm/find-package-require (npm.clj:165) shadow.build.npm/find-file (npm.clj:387) shadow.build.npm/find-file (npm.clj:358) shadow.build.npm/find-resource* (npm.clj:618) shadow.build.npm/find-resource* (npm.clj:610)Any hints to where I might start looking for the problem?
<script src="/assets/office-js/office.js"></script>
resources/public/js]js/office:configure stage on startup, and then just running my own fs-watch that runs independently, so it’ll run even if shadow fails. Thanksshadow-cljs-jar npm dependency which contains an uberjar to download maven dependencies yes:shadow.build/mode key in the macro &env, like this
(core/defmacro defonce
"defs name to have the root value of init iff the named var has no root value,
else init is unevaluated"
[x init]
(if (= :release (:shadow.build/mode &env))
;; release builds will never overwrite a defonce, skip DCE-unfriendly verbose code
`(def ~x ~init)
`(when-not (exists? ~x)
(def ~x ~init))))The required JS dependency "/js/react-fitted-image/index" is not available, it was required by "nosco/views/ideabox_copy_select_template.cljs". Dependency Trace: nosco/views/main.cljs nosco/views/ideabox_copy_select_template.cljs
(io/resource "js/react-fitted-image/index.js") returns a correct file.["/js/react-fitted-image/index.js" :as FittedImage] nor ["/js/react-fitted-image/index" :as FittedImage] work..js files aren't reported to the proper place. look at the server output, maybe there is something about a parse errorfunction foo(){ alert("hi"); }) and I get the same error.- vs _ as in cljs files? not actually sure."/js/react_fitted_image/index.js" as the name?["/js/foo.js" :as foo] has the same issue, I thought of the dash vs underdash.shadow-cljs clj-repl? no other tool, no nrepl, etc?$ shadow-cljs clj-repl shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn shadow-cljs - connected to server shadow-cljs - REPL - see (help) To quit, type: :repl/quit > (require '[ :as io]) nil > (io/resource "js/foo.js") #object[.URL 0x240a2e93 "file:/Users/orestis/dev/nosco/gamma/dev-resources/js/foo.js"] shadow.user=>
> (slurp (io/resource "js/foo.js")) "var x = 1;\n"
cljs/core.cljs file in a .jar that is not clojurescriptresources ? 😄(shadow/repl :the-build-id)foo file outside to some non-resources folder seems to work. Good to know in the future..jar files that contain compiled code in bad places(js/confirm "confirm or deny?")js/alert worksWebSocket network error: WebSocket connection failed because it violates HTTP Strict Transport Security. I’m looking into it now, but just posting it here to see if anyone has run into this issue before? It’s preventing the hot reloading.lein-shadow. so you are going to have to ask the authors how this is meant to work..css files come from. they just need to be somewhere.var CodeMirror = require('codemirror/lib/codemirror')
require('codemirror/mode/javascript/javascript')
require('codemirror/addon/hint/javascript-hint')
require('codemirror/addon/hint/show-hint')
require('codemirror/addon/selection/mark-selection')
require('codemirror/addon/comment/comment')
console.log("cm",CodeMirror)
The problem is that CodeMirror is undefined. How can I import it?console.log("cm",CodeMirror) logs CodeMirror as being undefined?(ns algoradio.core
(:require
[algoradio.state :refer [app-state]]
[cljs.user :refer [spy]]
[algoradio.archive :as archive]
[reagent.core :as reagent]
[algoradio.freesound :as freesound]
[algoradio.player :as player]
["/hydra_editor/dist/index" :as h]))
;; more code
(comment (h/init (clj->js {:editorContainerId "editor-container"})))parcel, but I wonder I am doing something wrongparcel (kind of like webpack)const CodeMirror = require('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)
export default {}export default caused the failure on my sideexport seems to provoke itrequire with export. either use require with exports.foo or import and export foo. don't use commons and ESM in one file.import CodeMirror from 'codemirror/lib/codemirror'
//const CodeMirror = require ('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)import * as CodeMirror from ...require(js/require "../resources/images/ui/welcome.jpg") works but (js/require "../resources/images/ui/fleets.json") doesn't:dependencies [[lambdaisland/kaocha "1.0-612"]]But upon doing (use 'kaocha.repl), I get:
Error in phase :compilation
Only [lib.ns :only (names)] and optionally `:rename {from to}` specs supported in :use / :use-macros; offending spec: [kaocha.repl] at line 1 cljs/user.cljs
Why is this?(use 'kaocha.repl) are instructions for CLJ not CLJS(not= last-mod prev-mod)(> last-mod prev-mod)# shadow-cljs.edn
{
...
:builds {:dev {:target :react-native
:init-fn env.main/main
:output-dir "target/dev"
:devtools {:autoload true
:after-load my.core/print-debug-stmt}
...
}npx shadow-cljs watch :devmy.core/print-debug-stmt maybe not included in the regular build?:preloads [my.core] into :devtools so the ns is actually compiled?:preloads with no change(println "ABC") in the top level of my.core that’s printed only the first time the app is loaded but not after edits and recompilesException in thread "async-dispatch-9" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: clojure.lang.PersistentArrayMap at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583) at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575) at clojure.core.async.impl.protocols$eval256$fn__257$G__245__262.invoke(protocols.clj:21) ...
npx shadow-cljs watch :dev[org.clojure/core.async "0.3.442"][org.clojure/core.async "1.1.587"]shadow-cljs.edn:dependencies [[binaryage/devtools "1.0.0"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.cognitect/transit-cljs "0.8.256"]
[com.rpl/specter "0.13.1"]
[cljsjs/libphonenumber "8.10.18-0"]
[orchestra "2017.07.04-1"]
[expound "0.5.0"]
[org.clojure/test.check "0.9.0" :scope "test"]
[pjstadig/humane-test-output "0.8.1" :scope "test"]
[re-frame "0.11.0-rc3"]
[reagent "0.9.0-rc4" :exclusions [cljsjs/react-dom
cljsjs/react
cljsjs/react-dom-server
cljsjs/create-react-class]]
[day8.re-frame/test "0.1.5" :scope "test"]]0.8.4 without results 😞(println "something-new") and can see that "something-new" appears in index.js 😄shadow-cljs - websocket connectedshadowshadow-cljs watch dev --verboseUsing IP: 192.168.1.208shadow-cljs.edn only. lein or deps.edn have options for that.npx npm-check -u for npm deps{:paths ["src"]
:deps {thheller/shadow-cljs {:mvn/version "2.8.94"}
binaryage/devtools {:mvn/version "1.0.0"}
reagent {:mvn/version "0.10.0"}
re-frame {:mvn/version "0.12.0"}}}
shadow-cljs.edn
{:deps true
:builds {:app {:target :browser
:output-dir "public/out"
:modules {:app {:entries []
:init-fn
:devtools {:http-root "public"
:http-port 8020}}}}
and now I’m getting a bunch of console warnings along with my page no longer rendering
failed to load shadow.module.app.append.js TypeError: alpha_journal.app.render is not a function
at Object.alpha_journal$app$main [as main] (:8020/js/cljs-runtime/alpha_journal.app.js:15)
at eval (:8020/js/cljs-runtime/shadow.module.app.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:836)
at Object.env.evalLoad (app.js:2224)
at app.js:2414
DevTools failed to parse SourceMap:
...
I was following the cljs-devtools example (https://github.com/binaryage/cljs-devtools/tree/master/examples/shadow) for shadow-cljs and it seems like I didn’t need to explicitly set a :preloads or anything.
Thanks for any help 🙂alpha_journal.app.render is not a function this is likely the result of something else failing before itDevTools failed to parse SourceMap: DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: DevTools failed to parse SourceMap: ...I didn’t explicitly require any DevTools package in my main file. Is that a possible problem? app.cljs
(ns (:require [reagent.core :as r] [reagent.dom :as dom]))
Failed to load resource: the server responded with a status of 404 (Not Found) app.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) app.css:1 Failed to load resource: the server responded with a status of 404 (Not Found) DevTools failed to parse SourceMap: DevTools failed to parse SourceMap:
:output-dir? what is your :asset-path? what is the path you are loading your JS from in your HTML?{:deps true
:builds {:app {:target :browser
:output-dir "public/out"
:modules {:app {:entries []
:init-fn
:devtools {:http-root "public"
:http-port 8020}}}}
and my index page is loading from <script _src_="out/app.js" _type_="text/javascript"></script>
which I believe is correct:asset-path "/out" (right after :output-dir) since that defaults to /js:entries [] since :init-fn already implies that:output-dir I should remember to set my :asset-path (otherwise it uses the default path which is wrong)
That seemed to clear up most of my sourcemap warnings. I just have a preload and postload warning?:entries does. Some of the config keys have been confusing me since I’ve been following a lot of tutorials and examples but a lot of them have very different config layouts in their shadow-cljs.edn. Thanks!:init-fn basically is sugar for :entries [] and calling the main fn on loadshadow-cljs.edn to a deps.edndeps.edn won't work. the lib has no deps.edn.[:app] Build failure: The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js".
:target is this?:browser@aws-sdk/node-http-handler?http2 is a node thing not an npm packagehttp2 is a node built-in package2.8.99? I’m running 2.8.96The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js". Dependency Trace: omnyway/mock_checkout_page/core.cljs node_modules/@aws-amplify/core/lib/index.js node_modules/@aws-amplify/core/lib/Credentials.js node_modules/@aws-sdk/credential-provider-cognito-identity/dist/cjs/index.js node_modules/@aws-sdk/credential-provider-cognito-identity/dist/cjs/fromCognitoIdentity.js node_modules/@aws-sdk/client-cognito-identity/dist/cjs/index.js node_modules/@aws-sdk/client-cognito-identity/dist/cjs/CognitoIdentityClient.js node_modules/@aws-sdk/client-cognito-identity/dist/cjs/runtimeConfig.js node_modules/@aws-sdk/node-http-handler/build/index.js node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js
requre:
["@aws-amplify/core" :default Amplify :as amp] ["aws-amplify-react" :refer (withAuthenticator)] ["/aws-exports.js" :default aws-exports]
:js-options {:resolve {"http2" false}} in your build config:js-options {:resolve {"http2" false}}`` Did the trick!shadow-cljs and one of the dependencies I include is a react component from NPM that includes its own assets that is itself bundled with (using rollup.js). For example, that package has some code like:
const img = require('my-image.jpg')
// then, later
<image src={img} />
But when build my shadow-cljs project, in the browser, I get:
Failed to load app.views.js Module not provided: ./my-image.pngif I include the package with
(:require '[my-npm-package])
Some thoughts from a colleague who has looked into this a bit more:
> I have a shadow-cljs question for anyone who has worked with it. It seems to do some translation of commonJS's `require` with npm modules, but how do I get it to do the same with relative imports internal to those modules?
> That is, it correctly figures out how to load npm modules so that e.g. `(:require '[react])` is equivalent to `require("react")` in plain old javascript. However, I'm working with a module that internally does a `require('./logo.png')`.
> Now, `logo.png` is present in the distributed npm package (it sits right next to the js file in question inside `node_modules`) but shadow-cljs cannot figure out how to load it!
> ...
> I think the issue might just be that shadow-cljs is not intended to be a full asset bundler like webpack.
> Other projects are using webpack which is loading (and inlining) the image as a data URI; however your shadow-cljs is not.
Let me know if anything isn't clear and I appreciate any insights! 🙂bundle target ?:bundle enables (and more) has already been supported for years by shadow-cljs:bundle is a bad idea for the reasons I listed here https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.htmlrepl/invoke error SyntaxError: Unexpected token '.'
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (browser.cljs:184)
at eval (browser.cljs:187)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (env.cljs:117)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (browser.cljs:187)
at shadow$cljs$devtools$client$browser$handle_message (browser.cljs:240)
at eval (env.cljs:196)
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (env.cljs:184)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (env.cljs:197)
at WebSocket.eval (browser.cljs:340)
shadow$cljs$devtools$client$browser$repl_error @ browser.cljs:173
shadow$cljs$devtools$client$env$repl_call @ env.cljs:138
shadow$cljs$devtools$client$browser$repl_invoke @ browser.cljs:187
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:240
eval @ env.cljs:196
shadow$cljs$devtools$client$env$process_next_BANG_ @ env.cljs:184
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:197
eval @ browser.cljs:340
This error sometimes occurs when I attempt to load a function in cider, and I find it hard to reach the underlying problem.(deftest cart-show-on-click-test (db-refresh) (user/click-cart-btn) (is @sub/cart-shown?) )
:type :repl/invoke message:repl/invoke will also have a :js keyUse of undeclared Var dom/img-idHow about the msg key's value were shown in the console directly?
cljs.user=> (+ 1 foo) ------ WARNING - :undeclared-var ----------------------------------------------- Resource: :1:6 Use of undeclared Var cljs.user/foo -------------------------------------------------------------------------------- ##NaN
dom namespace but using dom/img-id gives that dom is not defined.dom" does not mean anything to me(:require [vendo.workspaces.dom :as dom])But
dom/img-idin this namespace gives:
dom is undefined
(:require [vendo.workspaces.dom :as dom]) you are literally doing a keyword lookup of the vectorns(require '[vendo.workspaces.dom :as dom])2.8.102 with the new CLJS version if that is what you are asking?(.toBeInTheDocument (expect (.getByText screen "Some Component")))But I get that expect is undefined. js/expect gives undefined as well. How to get jest to work with clojurescript?
ana stand for? That is the folder that stores all the Clojure dependencies.
Thanks for entertaining my curiosity 🙂shadow.js.shim.module$electron_updater.AppUpdater.checkForUpdatesAndNotify is not a functionshadow.js.shim.module$electron_updater = require("electron-updater"); is basically what it doesAppUpdater. maybe you need to instantiate it?^js like in this part of the doc: https://shadow-cljs.github.io/docs/UsersGuide.html#externs? If you do that it shouldn't rename that function during compilation.require data from a .edn file?.json file?;; shadow-cljs.edn in project
{:deps {:aliases [:cljs]}}
;; ~/.shadow-cljs/config.edn
{:deps-aliases [:cider]}
What's difference between using :deps and :deps-aliases ?:deps-aliases allies to all projects and thus uses a different nameno source by provide: myapp.workspaces.dom
{:provide myapp.workspaces.dom}
ExceptionInfo: no source by provide: myapp.workspaces.dom
shadow.build.data/get-source-id-by-provide (data.clj:184)
shadow.build.data/get-source-id-by-provide (data.clj:181)
shadow.build.data/get-source-by-provide (data.clj:187)
shadow.build.data/get-source-by-provide (data.clj:186)
shadow.cljs.repl/repl-compile/fn--37359/fn--37360 (repl.clj:453)
shadow.cljs.repl/repl-compile/fn--37359 (repl.clj:429)
shadow.cljs.repl/repl-compile (repl.clj:427)
shadow.cljs.repl/repl-compile (repl.clj:424)
shadow.cljs.repl/process-read-result (repl.clj:515)
shadow.cljs.repl/process-read-result (repl.clj:491)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:859)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:813)
shadow.cljs.devtools.server.worker.impl/eval38290/fn--38291 (impl.clj:894)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823/fn--37831 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--37822 (util.clj:257)
java.lang.Thread.run (Thread.java:748)
And the only way out is to quit the repl and start it again. Why would this be?shadow-cljs clj-repl and try ( "shadow/cljs/repl.clj") and post the result( "shadow/cljs/repl.clj") #object[.URL 0xfee791d "jar:file:/private/var/root/.m2/repository/thheller/shadow-cljs/2.8.93/shadow-cljs-2.8.93.jar!/shadow/cljs/repl.clj"]
js/alert but i should probably just install proper tooling instead. or just a pre tag facepalm sorry it was late.:node-library , atm. The nrepl load-file op works, but not eval. It never returns. This happened w/o me upgrading shadow-cljs, which was still on 2.8.77. Using .102 makes no difference. The only thing I think has changed is my node version, which is now v12.13.0. Could that be the issue?.103 earlier which should log REPL errors more visibly.103, and see if it says something more about the condition.No matching version found for 2.8.103. at least the errors should log more info now. hopefully that makes figuring out what is happening easier for me. Its just a raw data dump so I don't expect anyone to make sense of it, just report it.require("fs"), making shadow-cljs complain with The required JS dependency "fs" is not available
I reverted to 2.8.101 and everything started working again 🙂npx create-cljs-project foorequire("fs") in the source file then only package.json can modify what that would dorequire("fs"){:tag :shadow.build.npm/missing-entries, :entries ["dist/index.js"], :package-dir #object[.File 0x69de6ee "/src/project-mine/node_modules/foo"]}
ExceptionInfo: package in /src/project-my/node_modules/foo specified entries but they were all missingnode_modules if individual files are modified but it should recompiled if the package.json of that package is modifiedtouch node_modules/foo/package.json/src/project-my/node_modules/foo/dist/index.js exist?println functions in my on-change function, after typing a char the input method would be automatically switched back from Chinese to system default (English)println would cause this problem, OTOH js/console.log is fine2.8.104libadd.js is commonjs but you glue.js was ESMimport WasmAdder ... was the problemconst WasmAdder = require('./libadd.js');
let add, malloc, free;
const wait = new Promise(done => {
WasmAdder().then(Module => {
malloc = Module._malloc;
free = Module._free;
add = Module.cwrap('add2', 'number', ['number', 'number']);
done();
});
});
exports.add2wasm = function add2wasm(x, y) {
return wait.then(() => { return add(x, y); });
}
and then you can just compile it with only shadow-cljsshadow-cljs - dependencies updated
[2020-04-27 12:10:51.037 - WARNING] :shadow.build.classpath/bad-jar-contents - {:jar-file "/Users/myuser/.m2/repository/cljs-bean/cljs-bean/1.5.0/cljs-bean-1.5.0.jar", :bad-prefix "cljs_bean/from/", :bad-count 1}
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.8.104 running at
shadow-cljs - nREPL server started on port 9999
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "cljs-bean.from.cljs.core" is not available, it was required by "cljs_bean/core.cljs".
after clearing my project's .shadow-cljs dir, i started getting the same error locally. when i unzip the cljs-bean-1.5.0.jar in my m2 folder, i can see the namespace is there:
system:cljs myuser$ pwd /Users/myuser/.m2/repository/cljs-bean/cljs-bean/1.5.0/unzipped/cljs_bean/from/cljs system:cljs myuser$ ls core.cljsany thoughts are much appreciated!
/cljs/core.cljs2.8.105shadow-cljs server shadow-cljs - config: /home/dave/projects/owsy/gondola-client/shadow-cljs.edn shadow-cljs - starting via "clojure" Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1). ES3 Full report at: /tmp/clojure-6373547123142623863.edn
:chunks {:foo {:entries [some.ns]}} in addition to the usual stufffoo.js in the output-dir(js/require "./foo.js") in your code:chunks {:foo some.ns/foo}(js/require "./foo.js") in your code you get some.ns/foo:chunks is the new name the closure stuff uses, moving away from :modules so I just called in chunks to start:modules from a browser build. works slightly differently so that react-native can do its thing properly(js/console.log "I'm loaded!") the the ns that was supposed to be loaded when I click a button2020-04-27 15:43:14,333 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=20.2 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.4 ms, state=CONNECTED}]
2020-04-27 15:43:14,333 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=20.2 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}]
2020-04-27 15:43:14,932 [XNIO-1 I/O-13] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1
2020-04-27 15:43:22,145 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of
2020-04-27 15:43:22,145 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016580, "i": 2}}, "signature": {"hash": {"$binary": {"base64": "w/czHSxejSRK/C/k02tdLQnaRxk=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25260 to database admin on connection [connectionId{localValue:100, serverValue:103115}] to server
2020-04-27 15:43:22,161 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25260 completed successfully in 16.51 ms on connection [connectionId{localValue:100, serverValue:103115}] to server
2020-04-27 15:43:22,162 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}]
2020-04-27 15:43:24,338 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of
2020-04-27 15:43:24,338 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of
2020-04-27 15:43:24,339 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016595, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "rOVQeuBwIEgQnmmAJs4ylRWzPtA=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25261 to database admin on connection [connectionId{localValue:101, serverValue:107380}] to server
2020-04-27 15:43:24,339 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016595, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "rOVQeuBwIEgQnmmAJs4ylRWzPtA=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25262 to database admin on connection [connectionId{localValue:102, serverValue:132898}] to server
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25261 completed successfully in 23.75 ms on connection [connectionId{localValue:101, serverValue:107380}] to server
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.8 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}]
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25262 completed successfully in 23.93 ms on connection [connectionId{localValue:102, serverValue:132898}] to server
2020-04-27 15:43:24,364 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.8 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=23.0 ms, state=CONNECTED}] (ns my-proj.data (:require #?(:clj [com.wsscode.pathom.connect :as pc])) #?(:clj ::pc/hi)the shadow cljs build is failing with:
Invalid keyword: ::pc/hi.Is there something obvious I'm missing here?
::pc/hilogback.xml in the project?log4j.xml?<logger name="io.netty" level="warn" /><logger name="org.mongodb" level="warn" /> after it<root level="DEBUG"> to <root level="INFO">(:import org.slf4j.LoggerFactory
ch.qos.logback.classic.Level))
(defonce server (atom nil))
(def mongo-logger (LoggerFactory/getLogger "org.mongodb.driver"))
(def jetty-logger (LoggerFactory/getLogger "org.eclipse.jetty"))
(defn log-level
[level]
(let [levels {:error Level/ERROR}
l (get levels level Level/DEBUG)]
(.setLevel mongo-logger l)
(.setLevel jetty-logger l)))
This what I got for controlling log-level(log-level :error)(ns my-proj.data
(:require #?(:clj [com.wsscode.pathom.connect :as pc]
:cljs [clojure.string :as pc]))/usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.23.0 serverGiven this, where do I put the functions I need to run on the repl startup?
.dir-locals.el file:
((clojure-mode (cider-preferred-build-tool . "clojure-cli") (cider-clojure-cli-global-options . "-A:dev"))
(run 'vendo.workspaces.cards_test) ;; cljs file Caused by: clojure.lang.ExceptionInfo: No such namespace: @testing-library/react, could not locate _CIRCA_testing_library_SLASH_react.cljs, _CIRCA_testing_library_SLASH_react.cljc, or JavaScript source providing "@testing-library/react" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file /Users...I installed this library through npm and it's in that cards_test namespace. How do I run kaocha tests then that include npm dependencies?
handle-asset-watch , e.g. add a '.disable-animation' class to the html body to make sure the animation rules is not in effect, and remove this class after the css update.:http-port 3000
[org.clojure/core.async "1.1.587"][org.clojure/core.async "0.7.559"] in project.clj, thanks"1.1.587" didn't help, same Exceptionjps<body class="load-anim"> or so and then remove that class yourself at some point? I didn't even know that replacing the css would restart animations? do you have an example of that so I can reproduce and test?lsof -i -nP | grep LISTENshadow-cljs clj-repl and then ( "clojure/core/async.clj") to see which version you get( "clojure/core/async__init.class") to see if there are some AOT files that would break this as well* {
margin: 0;
padding: 0;
text-align: center;
}
html {
background: white;
width: 100%;
height: 100%;
}
body {
height: 100px;
background-color: red;
position: absolute;
transition: background-color 3s linear 50ms;
width: 100%;
}
h3 {
margin-top: 1em;
}{:type :dtd, :data ["html" nil nil]}html bg white is first applied and then body with transitionshadow-cljs - starting via "clojure"
Unknown option: "-m"
Usage:
shadow-cljs <action> <zero or more build ids>
Supported actions are:
compile - ...
watch - ...
check - ...
release - ...
classpath - ...
node-repl - ...
browser-repl - ...
cljs-repl - ...
clj-repl - ...
clj-eval - ...
clj-run - ...
run - ...
info - ...
pom - ...
npm-deps - ...
test - ...
aot - ...
init - ...
help - ...
server - ...
start - ...
stop - ...
restart - ...
shadow-cljs.edn
{:deps {:aliases [:frontend]}
:dev-http {8080 "public"}
:builds {:app {:target :browser
:output-dir "public/js"
... }}}clojure on your classpath thats not from the official tools.deps dist?clojure -m shadow.cljs.devtools.cli help manuallyshadow-cljs -m something?shadow-cljs -m is not supposed to work. what are you actually calling?{ :frontend
{:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.742"}
thheller/shadow-cljs {:mvn/version "2.8.106"}
reagent {:mvn/version "0.10.0"}
re-frame {:mvn/version "0.12.0"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}shadow-cljs compile app:main-opts thats redundantclj -A:frontend compile appclj directly.cljclj? (using cider)clj:builds {:dev {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
:dev1 {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
:dev2 {:target :browser
:output-dir "public/js"
:asset-path "/js"
:devtools {:autoload true
:http-root "public"
:http-port 3000}}
interesting if i have such config, and run shadow-cljs watch dev I'll see this
shadow-cljs - HTTP server available at [2020-04-28 09:43:53.975 - WARNING] TCP Port 3000 in use. shadow-cljs - HTTP server available at [2020-04-28 09:43:54.004 - WARNING] TCP Port 3000 in use. [2020-04-28 09:43:54.009 - WARNING] TCP Port 3001 in use. shadow-cljs - HTTP server available at
(deftest my-test
(run-test-sync
(is (= 1 2)) ;; etc.
)
And it seems like a good idea to create a macro which would replicate this like so:
(deftest-sync my-test (is (= 1 2)) )And I have tried this:
(defmacro deftest-sync [name test] `(deftest ~name ~(run-test-sync ~test)) )But on doing in the shadow repl:
(macroexpand '(deftest-sync some-test (is (= 1 1))))I simply get the result:
(deftest-sync some-test (is (= 1 1)))But I seem to get the correct result in a clojure repl. Why would this be?
:dev-http {3000 "public"} once at the top level:http-root stuff in :devtools needed:autoload true is also the default so you can skip the entire :devtools entries:dev. each build already has dev/release notion built-in, shadow-cljs release dev is just weird 😛:advanced but I'd be happy to add a route that just delegates to a re-frisk ring handler when called?:maven {:local-repo "maven"} in shadow-cljs.edn top level. assuming you aren't using deps/project.clj or courseshadow-cljs.edn to manage dependencies:aot false to turn that offshadow-cljs classpath? compute that elsewhere?java -cp <that-classpath> clojure.main -m shadow.cljs.devtools.cli release app yourself if you want 😛lein deps once to get everything and then disconnect my network and lein repl or whatever it works?:jvm-opts or so configured since they won't be taken into accountrunning: npm install --save --save-exact
package.json doesn't contain all the packages that were required by cljs deps via deps.cljsNPM dependency "react" has installed version "16.9.0" "16.13.0" was required by jar:file:/home/yenda/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs` then
npm installrunning: npm install --save --save-exact shadow-cljs.edn?package.json "dependencies" or "devDependencies"[2020-04-28T12:32:47.944Z] [:android] Compiling ...
[2020-04-28T12:33:34.658Z] ------ ERROR -------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] File: /build/status-react-source-jsbundle/src/status_im/utils/multihash.cljs:53:1
[2020-04-28T12:33:34.658Z] --------------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] 50 | ;; - `hex-digest` is a string holding the hex-encoded algorithm output.
[2020-04-28T12:33:34.658Z] 51 | ;;
[2020-04-28T12:33:34.658Z] 52 | ;; Multihash values also support metadata.
[2020-04-28T12:33:34.658Z] 53 | (deftype Multihash [code hex-digest _meta]
[2020-04-28T12:33:34.658Z] -------^------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] Error in phase :compilation
[2020-04-28T12:33:34.658Z] Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
[2020-04-28T12:33:34.658Z] {:warning :infer-warning, :line 53, :column 1, :msg "Cannot infer target type in expression (. (. Multihash -prototype) --equiv)"}
[2020-04-28T12:33:34.658Z] ExceptionInfo: Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
:warnings-as-errors or so?(ns myapp.environment (:require [myapp.config :refer [env]])) (defmacro myapp-url [] (:myapp-url env))Then I require this in an events.cljs file like
[myapp.environment :refer-macros [myapp-url]]I get the error in shadow
The required namespace "myapp.environment" is not available, it was required by "myapp/events.cljs". "myapp/environment.clj" was found on the classpath. Should this be a .cljs file?when using it like so:
(http/get (str (myapp-url) "/somepath"))How do I fix this?
(defmacro defelem [name element]
`(defcard ~name
(ct.react/react-card
(r/as-element
[~element]
)
)
)
)
and the dependencies are ct.react and r. Should the dependencies be required in the clj or the cljs files? I tried both but neither worked.(defelem cart-card cart) -------^------------------------------------------------------------------------ Use of undeclared Var vendo.workspaces.cards/react-card --------------------------------------------------------------------------------
ct.react and r I believe this must be available at the file you are using it. Or you should require it in the macro.
Or use the full namespace like reagent.core/as-element .(ns myapp.workspaces.cards)
(defmacro defelem [name element]
`(nubank.workspaces.core/defcard ~name
(nubank.workspaces.card-types.react/react-card
(reagent.core/as-element
[~element]
)
)
)
)
In myapp.events (cljs) where I use this defelem macro
(ns myapp.workspaces.cards (:require [nubank.workspaces.core] [nubank.workspaces.card-types.react] [reagent.core] [myapp.cart :refer [cart]] )) (defelem cart-card cart)But I get:
(defelem cart-card cart) --------^----------------------------------------------------------------------- Can't take value of macro myapp.workspaces.cards/defelemWhy would this be?
(ns myapp.workspaces.cards
(:require-macros [myapp.workspaces.cards :refer (defelem)])
(:require
[nubank.workspaces.core]
[nubank.workspaces.card-types.react]
[reagent.core]
[myapp.cart :refer [cart]]
)):require-macros in its ns-form^:dev/after-load, and I’d like to call all of them via command line. Similar to CSS file watcher — when CSS changes, reload the app in the browser<script> tag?src/dev directorytouch path/to/your/sources/some/ns.cljs.js files should load without issue?(ns app.main
(:require [reagent.core :as r]
["@fluentui/react" :refer [Button PrimaryButton Stack]]
["@uifabric/utilities/" :as fu]
["@uifabric/styling/" :as fs]))
import * as stylesImport from './Calendar.scss';
/* tslint:disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".root_d7ec3e0f{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:none;box-shadow:none;margin:0;padding:0}.root_d7ec3e0f *{overflow:visible}.root_d7ec3e0f *::-moz-focus-inner{border:0}.root_d7ec3e0f *{outline:transparent}.root_d7ec3e0f *{position:relative}.ms-Fabric--isFocusVisible .root_d7ec3e0f *:focus:after{content:'';position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;border:1px solid " }, { "theme": "neutralSecondary", ...var stylesImport = require("./Calendar.scss"); this is the issueoffice-ui-fabric-react npm packageexport * from 'office-ui-fabric-react/lib/Calendar';and
office-ui-fabric-react package is in node_modules directory@fluentui/reactCalendarDay.js is the bad one, not sure if there are othersrequire("./Calendar.scss.js") but I guess they had to rely on that little bit of extra magic 😛.scss") with .scss.js") 😛shadow-cljs node-repl (require 'your.test-ns) (your.test-ns/the-test-you-want)cljs.test for that:prepl {:app 5557}} and when conjure tries to connect, I get a Stream Closed: http://java.io.IOException_frame.db.app_db.state and see my re-frame db) in my re-frame-10x tool. I know using shadow-cljs with this library required some extra configs so I followed the sample for conduit project as closely as I could:
https://github.com/jacekschae/conduit-re-frame-10x-demo/blob/master/shadow-cljs.edn
However, for their shadow-cljs.edn, this is their :modules setup:
:modules {:main {:entries [devtools.preload
day8.re-frame.trace.preload
conduit.core]}}
but my shadow-cljs.edn looks like this:
{:deps true
:builds {:app {:target :browser
:output-dir "public/out"
:asset-path "/out"
:modules {:main {:init-fn alpha-journal.core/main}}
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true
"re_frame.trace.trace_enabled_QMARK_" true
"_frame.tracing.trace_enabled_QMARK_" true}
:optimizations :whitespace}
:devtools {:http-root "public"
:http-port 8020
:after-load alpha-journal.core/main
:preloads [devtools.preload
day8.re-frame-10x.preload]}}}}
How can I setup my preloads while using my :init-fn? Is this possible?:init-fn? how is that related?[devtools.preload day8.re-frame.trace.preload]because I omitted using
:entries for :init-fn . I’m not sure if that is the reason for my dashboard not picking up on my app-db or something else:init-fn is effectively the same as you specifying :entries [alpha-journal.core] it makes no difference as far as re-frame-10x is concerned?:init-fn might be problematic in my case, the example case has the vector:
:entries [devtools.preload day8.re-frame.trace.preload conduit.core]but my case I only include my run function
:init-fn: alpha-journal.core/main so I don’t explicitly call for any preloads except in the devtools (which is only when it hot reloads?). This could be completely unrelated to my problem, but it was the one that seemed most potentially problematic since I figure I wasn’t loading the preloads. My then question was how can I load preloads while using :init-fn rather than :entries.
Back on your comment saying that the conduit app is a release example. Does that mean I don’t need the :compiler-options and :preloads in :devtools if I were to create a minimum working example?
According to this doc, it seems like shadow-cljs doesn’t require any extra config? Is that true? https://github.com/day8/re-frame-10x/blob/master/docs/Advanced-Setup.md
Thanks for all the help @thheller! I will ask the re-frame channel if this has nothing to do with my shadow-cljs settings:preloads is a way to add entries for development only:entries are literally what you just postedrf/dispatch in your :init-fn:init-fn try switching it to dispatch-sync instead\(ns alpha-journal.core
(:require
[reagent.core :as r]
[reagent.dom :as dom]
[re-frame.core :as rf]
[alpha-journal.events]
[alpha-journal.views :refer [app]]))
(defn render
[]
(dom/render [app]
(js/document.getElementById "app")))
(defn main
[]
(rf/dispatch-sync [:initialize])
(render))dispatch instead, maybe it was the reverse(defn main
[]
(js/setTimeout
(fn []
(rf/dispatch-sync [:initialize])
(render))
100))setTimeout didn’t work. I’m just curious if the hot reloads are running something that my first load isn’t:main but instead have :modules with a :init-fn:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"goog.DEBUG" true
"re_frame.trace.trace_enabled_QMARK_" true
"_frame.tracing.trace_enabled_QMARK_" true}
:optimizations :whitespace}
Thanks for explaining this all to a beginner like me 🙇(deftest login-test
(day8.re-frame.test/run-test-async
(testing "login test"
(async done
(go
(let [_ (<p! (js/Promise. (see/landing!)))
]
(prn "done")
)
)
(done)
)
)
)
)
And running this test just hangs. What do you think is causing this?
Oh yeah, I'm also getting this error on evaluating just the js/Promise part, but have no clue what it means:
TypeError: Promise resolver #<cmp> is not a function
TypeError: Promise resolver #<cmp> is not a function
at new Promise (<anonymous>)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:2)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at eval ()
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
(done) function when your async code finished. Here is the good section if you use core.async https://github.com/wilkerlucio/wsscode-async#javascript-async-tests<p!will wait for promise to be resolved or rejected before continuing
TypeError: Promise resolver #<cmp> is not a function
at new Promise (<anonymous>)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:118)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:7:3)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at eval ()(-> (js/Promise. (see/landing!)
(.then (fn [res] <some print>))
(.catch (fn [err] <some other print>)))(deftest test-async
(async done
(go
(is (= (<! (see/landing!) nil))
(done))))(deftest test-async
(async done
(let [callback #(done)]
(see/landing! callback))(deftest test-async
(async done
(let [_ (<p! (js/Promise. (fn [resolve reject] (see/landing! resolve reject))) ]
(done))(deftest test-async
(async done
(go
(<! (see/landing!))
(<! (interact/click-login-btn))
(done))))
(deftest test-async
(let [result (waitFor (+ 1 2)) ]
(async done
(go
(is (= 3 (<p! result)))
(prn "done")
(done)
)
)
))
waitFor is a react-testing-library function that returns a promise.
But this gives me the following error:
ERROR in (test-async) (Error:NaN:NaN)
expected: (= 3 (<p! result))
actual: #error {:message "Promise error", :data {:error :promise-error}, :cause #object[TypeError TypeError: Cannot read property 'current' of undefined]}
"done"
2.8.110 adds some options to the :node-test target outputnode out/tests.js --list to see tests it knowsnode out/tests.js --test=some.ns/foonode out/tests --test=some.nsnode out/tests.js --test=some.ns,other.ns--debug is not passed during app release?cljs.core.PersistentArrayMap expressions are not callable as a warning?check in general reports many false positives and non-issues--debug also turns on :pseudo-names which still renames everything but uses longer names that are less likely to clash with anything that the closure compiler would also use unless you had externs telling it not to:output-wrapper defaulting to true nowadays thats less of an issuejs->clj is also known to cause issues so if you use that with a lot of JS data that can be another causeUncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Transit$JSONUnmarshaller.reader.JSONUnmarshaller.unmarshal (reader.js:39)
at Transit$Reader.reader.Reader.read (reader.js:59)
at Object.cognitect$transit$read [as read] (transit.cljs:137)
at Object.shadow$cljs$bootstrap$browser$transit_read [as transit_read] (browser.cljs:23)
at .XhrIo.G__63340 (browser.cljs:33)
at goog.net.XhrIo.goog.events.EventTarget.fireListeners (eventtarget.js:285)
at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:383)
at goog.net.XhrIo.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
at .XhrIo.onReadyStateChangeHelper_ (xhrio.js:871)/bootstrap{:path "/wherever"} in the map you already pass in/bootstrap just config :path "/js/bootstrap" if thats the dir you are putting the files in currentlyException in thread "async-thread-macro-1" java.lang.OutOfMemoryError: Java heap space
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at clojure.lang.Reflector.getMethods(Reflector.java:498)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:436)
at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invokeStatic(fs_watch_jvm.clj:17)
at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invoke(fs_watch_jvm.clj:16)
at clojure.core$map$fn__5866.invoke(core.clj:2753)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.RT.seq(RT.java:535)
at clojure.core$seq__5402.invokeStatic(core.clj:137)
at clojure.core$apply.invokeStatic(core.clj:660)
at clojure.core$mapcat.invokeStatic(core.clj:2783)
at clojure.core$mapcat.doInvoke(core.clj:2783)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invokeStatic(fs_watch_jvm.clj:46)
at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invoke(fs_watch_jvm.clj:33)
at shadow.cljs.devtools.server.fs_watch_jvm$start$fn__7286.invoke(fs_watch_jvm.clj:77)
at clojure.core.async$thread_call$fn__3186.invoke(async.clj:484)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)(js/require …) work with shadow to require local .js files or can I only require them in the namespace?ns. node you can just use js/require:jvm-opts ["-Xmx2G"] (for max 2GB ram) in top level shadow-cljs.edn. need to configure via project.clj/deps.edn if you use those.node_modules or so in your classpath:jvm-opts ["-Xmx2G"] for 2gb right-Xmx1G[2020-05-01 10:47:31.625 - INFO] duplicate resource taoensso/timbre.cljs on classpath, using jar:file:/.m2/repository/com/taoensso/timbre/4.10.0/timbre-4.10.0.jar!/taoensso/timbre.cljs over jar:file:/.m2/repository/status-im/timbre/4.10.0-2-status/timbre-4.10.0-2-status.jar!/taoensso/timbre.clj [2020-05-01 10:47:31.640 - INFO] duplicate resource taoensso/timbre/appenders/core.cljs on classpath, using jar:file:/.m2/repository/com/taoensso/timbre/4.10.0/timbre-4.10.0.jar!/taoensso/timbre/appenders/core.cljs over jar:file:/.m2/repository/status-im/timbre/4.10.0-2-status/timbre-4.10.0-2-status.jar!/taoensso/timbre/appenders/core.cljsat least do not show this info, this duplication we only have in dev
:exclusions ?(require '[shadow.cljs.devtools.api :as api] '[shadow.cljs.devtools.server :as server]) (server/start!) (api/watch :app) (api/repl :app)We've recently made some build changes and bumped shadow's version, and I cannot get this to start any more. I get errors like
Syntax error (NoSuchFieldError) compiling at (shadow\cljs\devtools\api.clj:1:1) ES3 and Assert failed: (symbol? read-ns)
Any ideas on what I'm doing wrong?:depencies vector?(when env/*compiler*
(validate-consistency! @env/*compiler* i18n-call) ;; The new thing
(swap! env/*compiler* update-in [::ana/namespaces current-ns ::i18n-calls] vec-conj i18n-call))
That function:
(defn validate-consistency! [compiler i18n-call]
(let [other-i18n-calls (for [[_ ns-data] (::ana/namespaces compiler)
i18n-call (::i18n-calls ns-data)]
i18n-call)
conflict (some
(fn [other-i18n-call]
(get-conflict i18n-call other-i18n-call))
other-i18n-calls)]
(when conflict
(throw
(ex-info
(str
"Translation calls with the same arguments cannot have differing translations.\n"
(pr-str (:msg i18n-call))
"\nvs.\n"
(pr-str (:msg conflict)))
{:translation i18n-call
:conflicting-translation conflict})))))
cc @thheller::i18n-calls represent so I cannot comment on that(tr [:api-token/confirm-delete "Are you sure you want to delete this API token?"]):compile-finish and throw the error if it finds one:compiler-env key@env/*compiler* atom, so it has the ::ana/namespacesfoo.bar, I get a websocket error like: WebSocket network error: WebSocket connection failed because it violates HTTP Strict Transport Security.…/browserjs/document.location.host when trying to figure out what it should connect to:devtools {:use-document-host false} to use localhost instead:devtools-url to override the url completely https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support(ns config
(:require a))
(def values
{:a a/value})
and a/value relies on something in namespace b, then editing b will not update the value you’ve saved a reference to in your config namespace(def values
{:a #'a/value})
or, a function:
(defn values []
{:a a/value})def config {:a (a/values)} then it's only recomputed everytime the ns is reloaded, which is prob. exactly what you want.:devtools {:reload-strategy :full} in your build config to always reload all dependent namespaces but that can get a lot slowershadow-cljs - dependency update failed - Could not transfer artifact thheller:shadow-cljs:jar:aot:2.8.109 from/to clojars (): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Any ideas on how I can resolve this?brew install command on Mac 🙂.{:source-paths ["src"]
:dependencies [...]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:init-fn orgpad.client.core/init}}
:devtools {:after-load orgpad.client.core/mount-root
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :script}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}}}shadow-cljs watch client landingshadow-cljs server and start the builds from the ui (URL printed on startup, usually http://localhost:9630)TypeError: Cannot read property 'address_input_bar_suggestions_QMARK_' of undefined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:22)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at eval ()
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (: Cannot read property 'p__GT_c' of undefined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:98)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:7:3)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at eval ()
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
ERROR in () (TypeError:NaN:NaN)
expected: (some? (<p! (js/Promise.resolve (dom/mount-landing!))))
actual: #object[TypeError TypeError: Cannot read property 'p__GT_c' of undefined]
How do I fix this?:browser-test target which has rules to include all namespaces matching a regexpmissing cljs.user, repl not properly configured (must have analyzed cljs.user by now) (1/8 results) [30/121]
{}
ExceptionInfo: missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)--- a/src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ b/src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -772,8 +772,8 @@
;; compile immediately, autobuild is then checked later
(-> worker-state
(assoc :autobuild true)
- (build-configure)
- (build-compile)
+ #_(build-configure)
+ #_(build-compile)
))):node-test that won't work currently since it immediately exits after running the tests.scheduler.development.js:108 Uncaught TypeError: lastCallbackNode is not a function
at flushFirstCallback (scheduler.development.js:108)
at flushWork (scheduler.development.js:220)
at MessagePort.globalValue.port1.onmessage (scheduler.development.js:612)
in the console, and when I refresh the page, the app still seems to be in the older state. How do I fix this?(ns (:require [imported.but.never.used])) shadow just removes this namespace? I have a macro in it that should run some code on first namespace load and it doesn't seem to be ever triggered.impored.but.never.used I have a js/console.log at the top level, should it fire when I require it for the first time?metro might just be too eager in reading the file?metro not shadow, thanks, probably we shouldn't watch js changes because we don't use react native reloadbundling failed message definitely isn't from shadow-cljs yesThe required namespace "" is not available, it was required by "cljs/util.cljc". "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?For a bootstrap build. Is it possible to see where the
cljs.util namespace is being brought in somehow?clojure/java/io.cljs in your source path with just (ns )The required namespace ".File" is not available, it was required by "cljs/util.cljc".
:js-provider :shadow ). It's working, but I have to specify the entirety of the node standard library in :js-options :resolve to be already included, which doesn't seem to be the right way to go. Anything else I can do?:resolve configprocess.env in a Node script? (:-env js/process) is returning nil for me.ClojureScript 1.10.597 cljs.user=> (.-env js/process) #object[Object [object Object]]i think your interop is off. you want
.- not :-:-env is a keyword so invoking that is looking up in js/process for an entry at that keyword:-env is trying to look up something at that key, finding a non-associative object and returns nil..-env, thanks.secrets.edn, and then have a release version that uses (.-env js/process)?secrets.edn example: {:api-key "asdfasdf1234"} Then in release build {:api-key (.. js/process -env -API_KEY)}(merge (read-string (shadow.resource/inline "dev.edn")) (process-env-map)) behind a DEV closure-define. Release just uses (process-env-map).
This means the actual configuration mapping doesn’t change between dev and release, which should help with “Works on my machine” issues 😉Invalid Filename, got cljs/foo/bar.cljs but expected foo/bar.cljs (or .cljc) src - cljc - cljs -- foo --- bar.cljs (ns foo.bar) :source-paths ["src/cljc" "src/cljs"]Am I missing something? If not, is there a way to hide these particular warnings? They seem to just be warnings, hot reload works fine.
node_modules/react:js-package-dirs ["build1"] etc(:require ["react-foobar" :as react]) or whatever will of course work but overriding :resolve for react will effect everything in the build:node-script target is there a way to ask shadow-cljs to run it in the background when i do npx shadow-cljs watch server?2.8.110 that includes the updated CLJS release 1.10.758 that should fix the self-host issue you ran intoshadow.cljs.devtools.api/repl and I enter any input I'm getting
ExceptionInfo: missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)Does that look familar at all?
:repl-init-ns option from my :devtools map in shadow-cljs.edn(apply js/ga args)
apply checks to see if .-cljs$lang$applyTo exists on the f passed in, which gets munged to like f.d, which actually exists on the ga object 😕js->clj as well stilluser.ns to kill browse-open. 😶
(reset! *open-url-script* "/usr/bin/false")
shadow-cljs - watching build :main [:main] Configuring build. [:main] Compiling ... ------ WARNING #1 - ----------------------------------------------------------- Resource: simplified-externs.js:2 name ShadowJS is not defined in the externs. -------------------------------------------------------------------------------- [...] ------ WARNING #5 - ----------------------------------------------------------- Resource: simplified-externs.js:6 name ShadowJS is not defined in the externs. -------------------------------------------------------------------------------- [:main] Build completed. (1060 files, 1057 compiled, 0 warnings, 52.05s)
externs directory, the warning disapears.:push-state/headers which I thought would take care of this, but I'm not quite sure what else to do or even how to debug exactly what is going on.
2. If I don't use the shadow-cljs dev http server, and just go directly to my app's server, everything is mostly OK except I see some weird messages in the console when it tries to reload cljs code, where I just see the line: "shadow-cljs: can't find fn" (I have the impression that this normally would have the fn name after it) ... shadow-cljs: can't find fn means that the server-side compile found a hook function (eg. :dev/after-load or config) but didn't find it at runtimefoo.bar.fn_nameinit ... I don't think I am using load ...:build-complete message:before-load [{:fn-sym nil, :fn-str ""} {:fn-sym nil, :fn-str "", :async true}]server/start! embedded in another CLJ process?clj , but I'm not manually managing it or starting servers or anything.thheller/shadow-cljs {:mvn/version "2.8.83"}:build-hooks or something else that may be touching the compiler state?deps.edn with a debugger attached------ WARNING #5 - ----------------------------------------------------------- Resource: simplified-externs.js:6 name ShadowJS is not defined in the externs. --------------------------------------------------------------------------------
externs/ directory the warning disapears).simplified-externs.js is generated by the externs/build.txt so yeah removing that removes the filecom.google.javascript/closure-compiler-unshaded v20200406v20191027 would be the version used in 2.8.93. it should still work.com.google.javascript/closure-compiler-unshaded {:mvn/version "v20191027"}{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "95e0edf7faedd5e0edf7faedb8f1f0e3f0fbe3b8f8f4fcfb"}, :content ("[email protected]")}ExecutionException: clojure.lang.ExceptionInfo: failed to publish!, offer! failed {:msg {:type :build-log, :build-id :test, :event {:type :flush-source, :resource-name "node_modules/@material-ui/icons/CalendarViewDayTwoTone.js", :timing :exit, :timing-id 1489, :depth 1, :stop 1588684288351, :duration 3, :shadow.build.log/level :info}}, :topic :shadow.cljs.model/build-log} @materiel-ui hasvar Connection = require('../lib/tedious').Connection; ?(ns app.core
(:require
["express" :as express]
["tedious" :as sql]))
(defn create-connection []
(sql/Connection. {}))
but no Connection foundnode and then require("tedious")express? ie. now a :target :browser build?error when calling lifecycle function app.core/start! TypeError: Cannot read property 'Connection' of undefinedrequire("tedious") or require("tedious").Connectionrequire("tedious")
{
connect: [Function: connect],
BulkLoad: [Getter],
Connection: [Getter],
Request: [Getter],
ConnectionError: [Getter],
RequestError: [Getter],
TYPES: [Getter],
ISOLATION_LEVEL: [Getter],
TDS_VERSION: [Getter],
library: { name: 'Tedious' }
}
> require("tedious").Connection
[Function: Connection]{:source-paths
["src"]
:dependencies
[]
:builds
{:app
{:main app.core/main
:target :node-script
:output-to "app.js"
:devtools
{:after-load app.core/start!
:before-load app.core/stop!}}}}{
"devDependencies": {
"shadow-cljs": "^2.8.110"
},
"dependencies": {
"express": "^4.17.1",
"tedious": "^8.3.0"
}
}shadow-cljs node-repl and then (require '["tedious" :as x]) and then (js/console.log x)cljs.user=>
Connection: [Getter],
Request: [Getter],
ConnectionError: [Getter],
RequestError: [Getter],
TYPES: [Getter],
ISOLATION_LEVEL: [Getter],
TDS_VERSION: [Getter],
library: { name: 'Tedious' }
}
nilnpx shadow-cljs watch appnode app.jsboot shadow/release.
No matching method sha1Hex found taking 1 args for class org.apache.commons.codec.digest.DigestUtilsThis would appear to be related to the hashing function added in shadow-cljs v2.8.102. Full error in attachment. Thank you.
:main module?{:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:closure-defines {goog.LOCALE "en"}
:source-map true}
:devtools {:preloads [devtools.preload com.fulcrologic.fulcro.inspect.websocket-preload]
:http-root "resources/public"
:http-port 8120
:browser-inject :main}
:modules {:shared {:entries []}
:main {:init-fn myapp.webapp.main/init
:depends-on #{:shared}}
:worker {:init-fn myapp.webapp.worker/init
:depends-on #{:shared}
:web-worker true}}}:preloads into the :main module. they can be specified per module.------ ERROR -------------------------------------------------------------------
File: jar:file:/Users/wilkerlucio/.m2/repository/com/wsscode/pathom/2.3.0-alpha6/pathom-2.3.0-alpha6.jar!/com/wsscode/pathom/trace.cljc:289:9
--------------------------------------------------------------------------------
286 | (let [trace* (or (::trace* env) (atom []))
287 | env' (assoc env ::trace* trace*)
288 | parser-trace (trace-enter env' {::event ::trace-plugin})]
289 | (let-chan [res (parser env' tx)]
---------------^----------------------------------------------------------------
Encountered error when macroexpanding clojure.core.async/go.
ClassCastException: class clojure.lang.Keyword cannot be cast to class clojure.lang.IObj (clojure.lang.Keyword and clojure.lang.IObj are in unnamed module of loader 'app')
I have another project in which the same code compiles fine, I have tried to mimic all the same deps between projects (core.async, shadow, cljs, clj), removed .shadow-cljs every time between builds, but for some reason its just not working, any ideas what I may be missing here?cljs.core.async to clojure.core.async in the com.wsscode.async-cljs.clj file, version 1.0.6 released with the fixgoog-definelein with-profiles +whatever run -m shadow.cljs.devtools.cli release app or sowatch runs in its own thread(in-ns 'shadow.cljs.devtools.server.worker.impl)(tap> build-state) somewhereshadow-cljs servershadow-cljs watch app because that will shutdown if you stop the watchshadow-cljs server and then separately shadow-cljs watch app is fineshadow-cljs server and a separate shadow-cljs watch app, you mean 2 processes??(tap> build-state) or is it like (tap> build-configure) ?:compiler-env key:cljs.analyzer/namespaces:defs:name for some reason2.8.110 or so[:cljs.analyzer/namespaces your.ns :defs the-hook-fn] basically(defn ^:export ^:dev/after-load init{:name your.ns/init}?required namespace react is not available. I've seen the note about using shadow-cljsjs and have added it to my shadow-cljs.edn dependencies map but that hasn't fixed the problem. What else do I need to do?[:workspaces] Build failure:
Module Entry "devtools.preload" was moved out of module ":main".
It was moved to ":shared" and used by #{:shared :main}.:workspaces {:target nubank.workspaces.shadow-cljs.target
:ns-regexp "-(test|cards)$"
:output-dir "resources/workspaces/js"
:asset-path "/js"
:compiler-options {:source-map true}
:modules {:shared {:entries []}
:main {:depends-on #{:shared}
:preloads [devtools.preload com.fulcrologic.fulcro.inspect.preload]}
:worker {:init-fn my-app/init
:depends-on #{:shared}
:web-worker true}}
:devtools {:http-resource-root "."
:http-root "resources/workspaces"
:http-port 8121
:browser-inject :main}}:main :entries so I can set preloads theredevtools.preload into the :main moduleinject-repl-client(defn resolve-cards-and-tests
[{::build/keys [mode config] :as state}]
(let [{:keys [ns-regexp] :or {ns-regexp "-(ws|test)$"}}
config
dynamically-resolved-namespaces
(find-namespaces-by-regexp state ns-regexp)]
(-> state
;; Add the mounter and all of the resolved cards/tests
(assoc-in [::modules/config :main :entries] (-> []
(into (get config :preloads []))
(into dynamically-resolved-namespaces)
(conj 'nubank.workspaces.shadow-cljs.mount)))
(cond->
(and (= :dev mode) (:worker-info state))
(update-in [::modules/config :main] browser/inject-repl-client state config)
(= :dev mode)
(-> (update-in [::modules/config :main] browser/inject-preloads state config)
(update-in [::modules/config :main] browser/inject-devtools-console state config)))
(modules/analyze))))cond-> part seems to be problem:shared will be loaded twice, that will include devtools.preload and whatever that does:browser-inject logic anymore[:app] Compiling ... is printedCompiling ... is from the build-start event, that happens before anything else?(when (= :dev (:shadow.build/mode build-state))
(fs-watch/start {}
(file-seq (io/file pages-directory))
["cljs" "cljc" "clj" "js"]
gen-routes-fn))make dev boots up shadow and the watcher:devtools are for lmaoshadow-cljs .edn if I depend on Reagent I have to use npm install to install it’s dependencies, but they are mentioned in Reagent’s package.json. Same for npm packages that have dependencies in package.json, for some reason I have to add them manually. Is there a way to retrieve transitive dependencies automatically?load JS kickmanager/domain/start/start_screen.cljs load JS kickmanager/domain/main/main_frame.cljs callThis is the start function
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [PaperProvider {:theme custom-theme}
[main-frame-with-socket]])))
Hope someone can give me a hint on what to investigate. Thx and regards.package.json though so you just might be on a very old reagent version that doesn't declare its JS deps properly?[reagent "1.0.0-alpha1"]npm install
npm install (without any packages) to install the dependencies listed in package.json?nmp install zenroom && npm install would work?npm installpackage.jsonnpm install zenroom since that will just install zenroom but not the restnpm installnpm init -ynpm init -y && npm install zenroom i do not have the transitive dependenciesnpm install shadow-cljs watch apprunning: yarn add The required namespace "shadow.js" is not available, it was required by "node_modules/react/index.js"I don't have this anywhere in my code nor do I have any clue why react is requiring it. I can get the app to compile by installing the npm package shadow.js (whatever that is, plus a dependency rxjs) and it will compile successfully, but then when loading the compiled javascript I get the error
uncaught ReferenceError: shadow is not definedAppreciate any hints or help.
shadow.js is a helper namespace for npm JS interop. it comes with shadow-cljs. should be basically impossible that it doesn't exist?uncaught ReferenceError: shadow is not defined is the effect of the file missing in the first place#?(:clj (slurp (io/resource "my-web/test.txt")) :cljs (resource/inline "my-web/test.txt"))Is there a way to replace it with a single macro so this is easier to use? Not sure how to distinguish between Shadow-cljs and Clojure running the macro?
resource/inline should work from clojure too although that would mean you'd have shadow-cljs as a runtime dependency so probably not recommended for CLJ<script>function f { ... }</script>
how can I call it from my Clojurescript call? I tried js/f, but I get that it is undefined.[:div.button-filled #?(:clj {:onclick "f();"}
:cljs {:on-click #(js/f)})
"Odeslat"]:on-click js/fjs/f is just nil at the time it reaches that point<script>function f() ...<script> MUST come before <script src="js/foo.js"> (your compiled CLJS output)js/goog.global.eval it instead, can skip the script tag(js/goog.global.eval the-code)?:advanced CLJS build is basically the same size of jquery so thats no argument 😛:resolve in :js-options that would always be used in the node repl(shadow/node-repl {:config-merge [{:js-options {:resolve ...}}]})shadow-cljs.edn then I take it?:build-defaults or :target-defaults (not documented anywhere though):build-defaults {:js-options {:resolve ...}}:target-defaults {:node-script {:js-options ...}} would only apply to :node-script buildsbuild-defaults would do well.:resolve once its thereshadow-cljs server running in another process, shadow-cljs watch :test will not autorun tests?:build-defaults bit to?build-defaults can I overwrite it on my app config?:builds?:node-script build and go 🙂;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:builds
{:backend
{:target :node-script
:modules
{:main {:init-fn acme.backend.core}
:output-to "main.js"}}}}
Here's what I'm trying:modules does not apply to :node-script. just plain :main.No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
(let [test 4] (case test constants/command-state-request-transaction true false))user=> (def ^:const y 1) #'user/y user=> (case 1 y true false) false user=> (case 'y y true false) true
^:const for anything. Maybe this is intentional. Maybe it actually works in CLJ and I'm just doing something wrong. the clojure docs clearly state that the test contants are not evaluated:const impl in CLJS is a bug:compiler-options {:source-map false} not already turn off the source maps?(macroexpand '(db-event :foo [foo bar] [:foo foo :bar bar])) (do :foo (clojure.core/fn [db__49764__auto__ [foo bar]] (clojure.core/apply clojure.core/assoc db__49764__auto__ [:foo foo :bar bar])))But in the shadow repl, this gives:
(macroexpand '(db-event :foo [foo bar] (assoc db :foo foo :bar bar))) => (db-event :foo [foo bar] (assoc db :foo foo :bar bar))
:bundle affects shadow-cljsshadow-cljs - config: D:\Dev\spill\spill_cljs\shadow-cljs.edn cli version: 2.8.51 node: v10.16.0 shadow-cljs - socket connect failed, server process dead? shadow-cljs - HTTP server available at [2020-05-09 04:04:29.520 - WARNING] TCP Port 8080 in use. shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.51 running at shadow-cljs - nREPL server started on port 4023
:devtools {:http-port 8080} for two builds?#error {:message "Could not eval (+ 1 1)", :data {:tag :cljs/analysis-error}, :cause #error {:message nil, :data {:clojure.error/source nil, :clojure.error/line nil, :clojure.error/column nil, :clojure.error/phase :compilation}, :cause #error {:message "Cannot read property 'findInternedVar' of null", :data {:tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}}2.9.0 and am now getting the following error:
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1). ES3 Full report at: /var/folders/rc/lsvprbcs66q69q5ywxrg10xm0000gn/T/clojure-5971753772166324101.ednthe linked log provides the following:
{:clojure.main/message
"Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).\nES3\n",
:clojure.main/triage
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "api.clj",
:clojure.error/path "shadow/cljs/devtools/api.clj",
:clojure.error/class java.lang.NoSuchFieldError,
:clojure.error/cause "ES3"},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message
"Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).",
:data
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "shadow/cljs/devtools/api.clj"},
:at [clojure.lang.Compiler load "Compiler.java" 7648]}
{:type java.lang.NoSuchFieldError,
:message "ES3",
:at [cljs.closure__init load nil 133]}],
:trace
[[cljs.closure__init load nil 133]
[cljs.closure__init <clinit> nil -1]
[java.lang.Class forName0 "Class.java" -2]
[java.lang.Class forName "Class.java" 348]
[clojure.lang.RT classForName "RT.java" 2211]
[clojure.lang.RT classForName "RT.java" 2220]
[clojure.lang.RT loadClassForName "RT.java" 2239]
[clojure.lang.RT load "RT.java" 449]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 2088]
[cljs.repl$loading__5569__auto____6381 invoke "repl.cljc" 9]
[cljs.repl__init load nil 9]
[cljs.repl__init <clinit> nil -1]
[java.lang.Class forName0 "Class.java" -2]
[java.lang.Class forName "Class.java" 348]
[clojure.lang.RT classForName "RT.java" 2211]
[clojure.lang.RT classForName "RT.java" 2220]
[clojure.lang.RT loadClassForName "RT.java" 2239]
[clojure.lang.RT load "RT.java" 449]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 3894]
[shadow.cljs.devtools.api$eval1540$loading__6721__auto____1541
invoke
"api.clj"
1]
[shadow.cljs.devtools.api$eval1540 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval1540 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[shadow.cljs.devtools.cli$eval138$loading__6721__auto____139
invoke
"cli.clj"
1]
[shadow.cljs.devtools.cli$eval138 invokeStatic "cli.clj" 1]
[shadow.cljs.devtools.cli$eval138 invoke "cli.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause "ES3",
:phase :compile-syntax-check}}*shadow-cljs - Stale Client! You are not using the latest compilation output!*2.9.0 needs cljs 1.10.758,watch you have running. commonly that happens if you configure a different :output-dir or :modules without updating the references in your HTML to actually use those files.2.9.0 you can also turn of source maps for react native via :compiler-options {:source-map false}:modules {:main {...}} produces main.js in :output-dirThe required JS dependency "p5" is not available, it was required by "cljsjs/p5.cljs".
I close the repl, npm install p5, it tells me that it adds + and I can see the folder in /node_modules/ , but when I lein dev it fires back up and eventually tells me that it is still missing p5. What else should I be doing to fix this?lein new re-frame and added retit and now quillein dev does so I can't help much. make sure you are in the correct directory and so on. also make sure lein dev isn't resetting your node_modules or solein-shadow ...lein-shadow plugin that comes packaged with it I will look into setting the project back up to just use shadow and see if I can avoid this all together.lein-shadow sort of starts out without a package.json and if you run npm install p5 in a directory without a package.json then all bets are off where it actually installs thingsnpm init -y~/project/node_modules/, if I have a finder window watching the node_modules I see the p5 folder get culled out.
I tried adding "p5": "1.0.0" to the existing package.json and also watch that get replaced when I lein dev, which is defined as ["with-profile" "dev" "do" ["shadow" "watch" "app"]] in alases and {:dependencies [[binaryage/devtools "1.0.0"]] :source-paths ["dev"]} in profileslein-shadow completelynpm install whatevernpm install some-package without having to know the version:npm-deps {"p5" "1.0.0"} to your project.clj:npm-deps key with :npm-deps [[p5 "1.0.0"]] and it still culls out my p5 library. same with :npm-deps {"p5" "1.0.0"errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/request-compose/compose.js", :js-requires [], :js-errors [{:line 140, :column 3, :message "primary expression expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.jsnode_modules no, on the classpath that should already workjs-options:
:js-options
{:resolve {"terrain" {:target :file
:file "resources/public/js/terrain.js"}failed to convert sources… Not sure if there’s something I need to do to get it working?(shadow/watch :test) => :already-watching
:resolve with :target :file is not supposed to reload and never will. mostly because it shouldn't be used in the first placesrc and am requiring it with:
["/rm/terrain" :as terrain] ["/rm/language" :as language]
export function foo or is it commonjs exports.foo = function ...export before functions that I wanted in language.js, eg:
export function makeRandomLanguage export function makeWordand basically all the functions in
terrain.js.language.js:
export function makeRandomLanguage() {
console.log("TEST");
var lang = makeBasicLanguage();
lang.noortho = false;
Then calling this in terrain-cljs.core-test:
(.makeWord language (.makeRandomLanguage language) "city")
2.9.1, hot-reloading the JS should work fine again assuming they have proper import/export[goog.string :refer [format]] at my require namespaces, in dev it worked fine i can use (format) but it dont find the google lib when i compile a release bundle(str % " " %) instead of formatgoog.string.format is a separate namespace from goog.string so to use it properly you must require it separately[goog.string.format] [goog.string :refer (format)]
send (form) to REPL#'census.utils.core/update-map
nil$ shadow-cljs browser-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn shadow-cljs - connected to server cljs.user=> (defn foo "docstring" [a] a) #'cljs.user/foo cljs.user=> (foo 1) 1
λ shadow-cljs node-repl
shadow-cljs - config: C:\Users\logan\Projects\census\census-geojson\shadow-cljs.edn cli version: 2.8.59 node: v10.16.2
shadow-cljs - connected to server
census.utils.core=> (defn foo "docstring" [a] a)
nil
census.utils.core=> (foo 1)
TypeError: Cannot read property 'call' of undefined
at cljsEval (<eval>:1:31)
at global.SHADOW_NODE_EVAL ([stdin]:90:10)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:24:1)
at C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:49:13
at Object.ret [as repl_call] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:104:11)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:47:1)
at shadow$cljs$devtools$client$node$process_message (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:118:5)
at C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:183:9
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:171:7)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:184:7)
census.utils.core=>> (defn foo [a] a) #'census.utils.core/foo > (foo 1) 1 census.utils.core=>
pom.xml file with cursive:lein true or something in shadow-cljs.edn?:lein true{:source-paths ["src"]
:dependencies [[org.clojure/core.async "1.0.567"]
[cljs-ajax "0.8.0"]
[funcool/cuerdas "2.2.0"]
[clojusc/defun "0.4.0"]
[frankiesardo/linked "1.3.0"]
;[jamesmacaulay/cljs-promises "0.1.0"] ; FIXME: When batching cartography files: uncomment and `shadow-cljs pom`
;[cider/cider-nrepl "0.21.0"]
[net.cgrand/xforms "0.19.2"]]
:nrepl {:port 3333}
:builds {:lib {:target :node-library
:output-dir "public/census"
:output-to "public/census/census.js"
:compiler-options {:optimizations :advanced}
:exports-var census.core/census}
:geo {:target :node-library
:output-dir "public/geo"
:output-to "public/geo/batch_convert.js"
:compiler-options {:optimizations :simple}
:exports-var configs.geojson.core/batch_convert}}}[org.clojure/core.async "1.1.587"] but also upgrade shadow-cljs to 2.9.0npm i -D wsgoog.module instead of goog.provides, if that makes a differencelilactown.harmony and evaluating e.g. lilactown.harmony/ref would say "cannot find namespace lilactown"harmony and that symbol is just undefinedgoog.module and tried to just treat it as a commonjs module (since goog.module also uses exports.foo = ...) and importing it like ["../harmony.js" :as harmony]node-repl, does work in browser-replgoog.module needs to call goog.module.declaryLegacyNamespace() to be usable (or whatever that was called):foreign-libs configSyntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1). ES3Have this error after upgrading to 2.9.1 from 2.8.90 Clojurescript version is 1.10.597
1.10.758clj-run so the shadow-clj version is set in depsdeps.edn it is in charge of dependencies. there is nothing shadow-cljs can do to ensure you get the correct versions:watch-dirFactual/geo to cljs the last few weeks — any comments you have about potential ways to integrate census-geojson would be appreciated! I made a (still very quiet!) #gis channel if you want to discuss there!goog.module and declareLegacyNamespace, it does require successfullyReferenceError: $jscomp is not defined(send ,,,)Branch.prototype.flushNext = function() {
var $jscomp$destructuring$var0 = $jscomp.makeIterator(this.unrealizedThunks);$jscomp. thought I got them all but guess not.ts or did you write it by hand?var module = module || { id: 'src/index.ts' };
goog.require('_.tslib');goog.module.declareLegacyNamespace();if (false) {?@implements {IRef} means?deps.edn or project.clj in simple projects like this that make no use of any other particular feature of those will make shadow-cljs start about 50% slower?shadow-cljs.edn seems to become rather rare?thheller/shadow-cljs$aot but I'd generally advise staying away from using that in deps/lein projectsshadow-cljs pom and load the generated pom.xml in cursivedeps.edn around for external usage but use shadow-cljs.edn for dependency resolution in-projectnode-repl, then override it to self for the browser build (where it should work);; Default all builds to resolving amplitude-js to the mock file.
;; This way node-repl doesn't break when amplitude-js tries to use `window`.
;;
:build-defaults
{:js-options {:resolve {"amplitude-js" {:target :file
:file "src/js/amplitude-mock.js"}}}}
;; On browser targets, resolve amplitude-js properly to the npm package instead.
:target-defaults
{:browser
{:js-options {:resolve {"amplitude-js" {:target :npm
:require "amplitude-js"}}}}}[:app] Build failure:
can't resolve to self
{:require "amplitude-js", :other "amplitude-js"}
ExceptionInfo: can't resolve to self"src/js/amplitude-mock.js" to the npm targetamplitude-js -> src/js/amplitude-mock.js resolve on the node-repl config because that config doesn't exist:node-repl is just a :node-script build so you can set it as a default for that?(:require ["../../../amplitude-mock" :as amplitude], that refers to a js file in the source paths, should it be possible to use {:js-options {:resolve ... to resolve it to a npm package instead of the js file?:resolve and hacks like it really should never ever be used. abstract it properly and you don't have to 😛:compiler-options {:output-feature-set :es6}let [thunk, ...rest] destructure you doError: Namespace "demo.js_class" already declared. can't hot-reload goog.module files ....goog.provide that was dead?:node-script build that loads the ns from the beginning they would be there:advanced remove them if not needed:node-script , :browser and :react-native targets?class doesn’t cause any polyfill problems tooStale client! message. Checked that index.html is requiring the right javascript file (no changes were made to index.html or shadow-cljs.edn and not sure how to continue troubleshooting. Any help would be greatly appreciated!project.clj. Anytime I run lein dev something is running npm install --save --save-exact which is deleting all my deps I added in package.json How can I install an npm dependency without it getting deleted?lein-shadow is my recommendationmain.js . if i change the code it live-reloads it successfully. i narrowed the problem down to a single dependency, which if i eliminate it, this problem goes away. has anybody ever seen anything like this and have any suggestions?zxingwrap.js:
module.exports = {
"lib": window["RTCPeerConnection"] ? require("@zxing/library") : null,
};
when i do this and then require ["zxingwrap" :as zx] i can then use zx/lib.InstanceName and it works great on both platforms. Very curious. Any ideas as to why this works I would love to hear them!@zxing/library - https://github.com/zxing-js/librarywindow.onerror but got nothing.:compiler-options {:imul-js-fix true} in your build configMath.imul. thought nobody was using version that was affected by that anymorefailed to load devcards.system.js ReferenceError: React is not defined. Is there something obvious I’m missing? Thanks in advance!cljsjs.react(:require [cljsjs.react] [devcards.core :as dc] ...) or socljsjs.react.domSyntax error (NoSuchFieldException) compiling . at (shadow/build/closure.clj:68:5).
getRegisteredGroupsorg.clojure/clojurescript {:mvn/version "1.10.758"} thheller/shadow-cljs {:mvn/version "2.9.2"}clj -Stree (with the aliases you need)[com.google.javascript/closure-compiler-unshaded "v20200504"]?com.google.javascript/closure-compiler-unshaded v20180805com.fulcrologic/fulcro 3.2.3
cljsjs/react-dom 16.13.0-0
com.cognitect/transit-cljs 0.8.256
com.cognitect/transit-js 0.8.846
org.clojure/clojurescript 1.10.597
org.clojure/google-closure-library 0.0-20170809-b9c14c6b
org.clojure/google-closure-library-third-party 0.0-20170809-b9c14c6b
org.mozilla/rhino 1.7R5
com.google.javascript/closure-compiler-unshaded v20180805com.google.javascript/closure-compiler-unshaded v20200504{:deps {:aliases [:dev]}:dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.758"}
thheller/shadow-cljs {:mvn/version "2.9.2"}
clj -A:dev -Stree does give you all the correct versions?Cannot assign to read only property 'exports' of object '#<Object>'
at Module.<anonymous> (main.1d63ab3fd8c0aad6bcda.bundle.js:5638)
at Module../out/cljs_env.js (main.1d63ab3fd8c0aad6bcda.bundle.js:5639)
at __webpack_require__ (runtime~main.1d63ab3fd8c0aad6bcda.bundle.js:849)
run into this when using :npm-module with webpack before?:npm-module already emits commonjs, don't need babel?clojurescript / closure-compiler versions? Just looking at the github readme I don’t see anything obviously there that prompts me to dig in and work it out. I only really clocked it when you told me when I was having problems =)…goog.math.Long at runtimecljs.core + google closure librarytake! is not defined./.shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core/async/impl/ioc_helpers.cljs:52 (defn take! [state blk ^not-native c] ^ TypeError: c.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 is not a function
take! somewhere with something that is not a channel?^not-native hint makes the compiler use the "direct" call to the take! protocol impl instead of going through the dispatch method^not-native is a compiler optimization. it gains a bit of performance but loses a better error message in the process 😉$ shadow-cljs server
shadow-cljs - config: /mnt/c/Users/thheller/code/tmp/error-test/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------
This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.
You are using shadow-cljs version: 2.9.3
The important dependencies are:
org.clojure/clojure "1.10.1"
org.clojure/clojurescript "1.10.758"
com.google.javascript/closure-compiler-unshaded "v20200504"
Please verify that you are loading these versions.
You can find all required dependencies here:
Please refer to the Guide for more information:
-----------------------------------------------------
The error encountered was:
Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).
at clojure.lang.Compiler.load(Compiler.java:7647)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:463) ...#?(:shadow/cljs) ever a thing / How can I do the equivalent of https://clojurescript.org/guides/javascript-modules in a portable (shadow & non-shadow) way?goog.provide should be fully supported for all cases:foreign-libs meaning actual foreign-libs though, so files that aren't processed just prepended:build-id as part of the config anyways(shadow/release :some-id) will load the build config for :some-id from shadow-cljs.edn and call release* with itrelease* yourself if you want toodeps.edn or user-config ~/.shadow-cljs/config.edn ? I’m trying to override dependency specified in project’s deps.edn with shadow user config, but it doesn’t have any effectclj directly without going through shadow-cljs?{:dependencies
[[cider/cider-nrepl "0.25.0-SNAPSHOT"]]}
to .shadow-cljs/config.edn assuming it would override cider-nrepl dep from deps.edn , but it’s not~/.clojure/deps.edn and enable that alias insteadeval situtation is like for deno so don't know about hot-reload or REPL but creating output that is consumable by it is trivial^:const - what did you mean by “doesn’t do what everyone thinks it does” ?:compiler-options {:output-feature-set :es6}:none builds. maybe I should do that too?:browser-test is currently rather limited and doesn't work great for automated testing env. :node-test generally works better if you can live without the DOM/browser APIs{
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"shadow-cljs": "^2.9.3"
}
}
and this is my deps.edn
{:paths ["src/main" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
com.fulcrologic/fulcro {:mvn/version "3.0.10"}}
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.742"}
thheller/shadow-cljs {:mvn/version "2.8.107"}
binaryage/devtools {:mvn/version "0.9.10"}}}}}
this is my shadow-cljs.edn too
{:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn app.client/init
:entries [app.client]}}
:devtools {:after-load app.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload]}}}}
it's giving the message
Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/cli__init.class, shadow/cljs/cli.clj or shadow/cljs/cli.cljc on classpath.
thheller/shadow-cljs {:mvn/version "2.8.107"} but "shadow-cljs": "^2.9.3"node app/app.js - i dont see any WebSocket connected message - the scripts just runs main
{:deps true
:builds
{:app
{:target :node-script
:main
:output-to "app/app.js"}}}
please advice how I fix it?
thanks:node-script target prints anything anymore. if you don't get any errors it should just work? just call shadow-cljs cljs-repl app to get the REPL?shadow-cljs watch app is already running of course(a/chan) (where a is clojure.async)
i see this:
TypeError: Cannot read property 'call' of undefined
at cljsEval (<eval>:1:30)
at global.SHADOW_NODE_EVAL ([stdin]:105:10)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/kirill.salykin/.../.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
is this me doing something wrong?$ shadow-cljs node-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn shadow-cljs - connected to server cljs.user=> (require '[clojure.core.async :as a]) nil cljs.user=> (a/chan) #object[cljs.core.async.impl.channels.ManyToManyChannel] cljs.user=>
./node_modules/.bin/shadow-cljs build :lambda shadow-cljs - config: /<project-path>/shadow-cljs.edn shadow-cljs - running: lein run -m shadow.cljs.cli --npm build :lambda OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. Can't find 'shadow.cljs.cli' as .class or .clj for lein run: please check the spelling. Syntax error (FileNotFoundException) compiling at (/private/var/folders/xl/rkkw077j4xxf827wn82mcp_c0000gn/T/form-init598900596536044588.clj:1:124). Could not locate shadow/cljs/cli__init.class, shadow/cljs/cli.clj or shadow/cljs/cli.cljc on classpath.
running: lein run -m shadow.cljs.cli --npm build :lambda, I’ve not gotten around to installing shadow-cljs as global, so I was surprised that calling the npm installed one then triggered lein to run it as if it was global. Unless there’s some other stuff going on that I’m not aware of :)…shadow.cljs.cli which the above it trying to call2.9.3 it started breakingshadow-check tool to detect common errorsUncaught (in promise) Module not provided: ./assets/search.js I can’t tell if that’s something I can reroute via js-options (hasn’t worked thus far)(ns deli.utils.icon-hacks
(:require ["@elastic/eui/lib/components/icon/assets/search" :as Search]
[oops.core :refer [oset!]]))
(set! (.. js/window -EuiIconDict) #js {"search" Search})node_modules
_defineProperty(_assertThisInitialized(_this), "loadIconComponent", function (iconType) {
Promise.resolve().then(function () {
console.log("got here: ", iconType)
return window.EuiIconDict[iconType];
}).then(function (_ref)npm-modules that are meant to be included in frontend webpack build to be consumed by a react app written in JS. i have them both building with shadow-cljs compile lib and they’re both npm linked into my frontend project. unfortunately, i get an error on load that makes a ton of sense: Uncaught Error: Namespace "goog.math.Long" already declared. because both packages are including the closure compiler and declaring that same module. is there a way to essentially declare the closure compiler as an extern so that it’s assumed that it will be available in the environment? or is there another solution to this i’m not thinking of? thanks 🙂import() into a require import or requirenpx shadow-cljs run shadow.cljs.build-report app report.html give me this error: No such var: shadow.cljs.devtools.cli/from-remote.:deps truesrc/my-app # app code goes in here test/my-app # tests go in here deps.edn shadow-cljs.ednAnd my shadow config:
{:source-paths ["src" "test"]
:deps true
:builds {:app ...
:test {:test-dir "resources/public/test"
:target :browser-test
:ns-regexp "-test$"
:devtools {:http-root "resources/public/test"
:http-port 3002}}}}
This works fine for running CLJ tests via clojure -A:dev -m kaocha.runner, but I've never gotten this setup to work with Shadow/CLJS. watch doesn't seem to detect that the test files are even there. I see in the Testing section of the Shadow docs that it's "common" to keep files in src/main and src/test, but is that a requirement?:deps true then you configure :paths in deps.edn only:source-paths in shadow-cljs.edn has no effect at all. you should get a big warning for that on startup, unless your version is too old for that.deps.edn is the one that counts, the npm package is only for command-line stuff which doesn't really do much(require '[clojure.data :as data]) (data/diff [1 2 3] [4 5 6]) => nil => [[1 2 3] [4 5 6] nil]Using code in editor sent to shadow repl:
(require '[clojure.data :as data])
------ REPL Error while processing ---------------------------------------------
(require '[clojure.data :as data])
no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
{:id [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
shadow.build.data/get-source-by-id (data.clj:171)
shadow.build.data/get-source-by-id (data.clj:168)
shadow.build.compiler/remove-dead-js-deps/remove-fn--13854/fn--13855 (compiler.clj:1164)
clojure.core/complement/fn--5669 (core.clj:1441)
clojure.core/filter/fn--5893 (core.clj:2817)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
clojure.core/chunk-next (core.clj:708)
clojure.core.protocols/fn--8154 (protocols.clj:137)
clojure.core.protocols/fn--8154 (protocols.clj:124)
clojure.core.protocols/fn--8114/G--8109--8123 (protocols.clj:19)
clojure.core.protocols/seq-reduce (protocols.clj:31)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
clojure.core/reduce (core.clj:6828)
clojure.core/into (core.clj:6895)
clojure.core/into (core.clj:6887)
shadow.build.compiler/remove-dead-js-deps/remove-fn--13854 (compiler.clj:1166)
clojure.core/update (core.clj:6196)
clojure.core/update (core.clj:6188)
shadow.build.compiler/remove-dead-js-deps/fn--13859/fn--13860 (compiler.clj:1172)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
clojure.core/reduce (core.clj:6828)
clojure.core/into (core.clj:6895)
clojure.core/into (core.clj:6887)
shadow.build.compiler/remove-dead-js-deps/fn--13859 (compiler.clj:1173)
clojure.core/update (core.clj:6196)
clojure.core/update (core.clj:6188)
shadow.build.compiler/remove-dead-js-deps (compiler.clj:1170)
shadow.build.compiler/remove-dead-js-deps (compiler.clj:1159)
shadow.build.compiler/compile-all (compiler.clj:1422)
shadow.build.compiler/compile-all (compiler.clj:1269)
shadow.build.api/compile-sources (api.clj:258)
shadow.build.api/compile-sources (api.clj:250)
shadow.build.api/compile-sources (api.clj:262)
shadow.build.api/compile-sources (api.clj:250)
shadow.cljs.repl/repl-require (repl.clj:218)
shadow.cljs.repl/repl-require (repl.clj:187)
shadow.cljs.repl/process-read-result (repl.clj:522)
shadow.cljs.repl/process-read-result (repl.clj:502)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:879)
shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:833)
shadow.cljs.devtools.server.worker.impl/eval16051/fn--16052 (impl.clj:914)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580/fn--15588 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--15579 (util.clj:257)
java.lang.Thread.run (Thread.java:830)
(data/diff [1 2 3] [4 5 6])
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: :1:2
No such namespace: data, could not locate data.cljs, data.cljc, or JavaScript source providing "data"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
Resource: :1:2
Use of undeclared Var data/diff
--------------------------------------------------------------------------------
ReferenceError: data is not defined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:1)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
at eval ()
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
at shadow$cljs$devtools$client$browser$handle_message ()
at eval ()
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()(require '[clojure.data :as data]) => nil 1 => 1 (data/diff [1 2 3] [4 5 6]) => [[1 2 3] [4 5 6] nil]
require would need.shadow-cljs (with npm dependencies) and use it from another shadow-cljs app, I can work out how does the app consume the npm dependencies of the library?
There was stuff in the docs about deps.cljs but I could not get that to work and I am not sure if that is what I need?deps.cljs on the classpath containing {:npm-deps {"name" "version"}} . Reagent has an example: https://github.com/reagent-project/reagent/blob/master/src/deps.cljsnpm install --save --save-exact ...:build-complete :build-failure :build-startin
:devtools
:warnings are nested in :sources which is a sequence of mapsorg.clojure/test.check ?Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never requiredclojure.test.check.generatorstest.check and didn’t pay attention - thanks!node-library that’s not referenced by an extern(def stock-data (delay {... instead of (def stock-data {...)@data/stock-data in the init:advanced to remove the data entirelyrelease does and pass it into dev in development too:preloads and and have that initilialize itdelay you maybe can just leave things as they are:advanced should be able to remove the example datavar testScores = [
{ id: 1, score: 86, gradeLetter: "B" },
{ id: 2, score: 93, gradeLetter: "A" },
{ id: 3, score: 78, gradeLetter: "C" }
];
I have this js arrayexport let testScores = { ... };(:require ["./the-file.js" :as x]) x/testScores.m2 directory into a container..shadow-cljs/builds:maven {:local-repo "maven"} in either shadow-cljs.edn or ~/.shadow-cljs/config.ednclass AccessController extends EventEmitter {
static async create (db, options) {}
static get type () {
throw new Error('\'static get type ()\' needs to be defined in the inheriting class')
}
get type () { return this.constructor.type }
async canAppend (entry, identityProvider) {}
}
class OtherController extends AccessController {
static get type () { return 'othertype' }
async canAppend(entry, identityProvider) {
return true
}
}
static is a property of the object itself and th prototype properties (methods) can be overridden by setting the -.prototype.get is, also since AccessController extends EventEmitter what to do with the static properties of EventEmitter, do I just add them to the object literal?(defn create-controller []
(let [type "othertype"
ac-obj #js {:create (fn [db options]
(js/Promise.resolve true))
:type type}]
(set! (.-prototype ac-obj) (.-prototype AccessController))
(set! (.. CustomAccessController -prototype -type)
(fn [] type))
(set! (.. CustomAccessController -prototype -canAppend)
(fn [entry identity-provider]
(js/Promise.resolve true)))
ac-obj))ImportModuleError. I’ve specifically been trying to use the pg npm module if that helps =)…node-library and run it?[:> Thing]) I’m I’m returning the string dom representationcider-eval-* . I know there's a lot of tools between running that emacs command and shadow-cljs, so maybe this isn't the right place to ask.
But I've tracked it down to the nrepl responding with :repl-type of clj
in its response map which then gets sent to cider-set-repl-type.
I haven't been able to track how :repl-type gets set in the response. Does it have anything to do with shadow-cljs?
I'm running npx shadow-cljs server, version 2.8.107 and cider-nrepl 0.25.0-alpha1. After launching npx shadow-cljs server I'm connecting on the default port of 9000 and then running (shadow/repl :main). Everything else works fine. I'm just not able to evaluate stuff from a buffer. The buffer is connected. I've verified that looking at sesman. I put a debug-on-entry on cider-set-repl-type and I see it change from cljs-pending type to clj type on the first attempt at eval. And if I manually set the type back to cljs with (cider-set-repl-type 'cljs, then on the next eval it tries to set it back to clj.cljs and then eval something that is 100% cljs specific like (js/alert "hi") does it still kick it back to `clj?clj. It was in a project I was in earlier. I have to run out in 5 minutes so I'll see if I can repro when I get back.npm test ? how do you setup the files with it? is there an example ?cljs.spec.alpha and you’re good to goclojure.spec.alpha is a code library for adding assertions to your code. it gets included in your bundle by defaultcider-connect-sibling-cljs to use my unique :app alias ? I have my dir-locals.el on this project with the basic settings:
((nil . ((cider-default-cljs-repl . shadow)
(cider-shadow-cljs-default-options . "app"))))- characters in namespaces when referencing namespaced keywords (i.e. when using spec)my-ns becomes my_ns.cljs , but otherwise is referenced everywhere as e.g. (my-ns/my-fn …):my-ns/mykey doesn’t work, it has to be :my_ns/mykeynode-test target - it works fine in the REPL/.shadow-cljs/builds/test/dev/out/cljs-runtime/cljs/spec/alpha.cljs:71
(throw (js/Error. (str "Unable to resolve spec: " k)))):lambda.my-spec/myspec
:_spec/specns form?::lambda?:my_ns/keyword whereas the test runner expected :my-ns/keyword. I was simultaneously running:
shadow-cljs watch :test shadow-cljs watch :repl node dist/node/repl.js
(s/gen :lambda.leads-spec/lead)will only work if you also require
[lambda.leads-spec :as ls]
:print-fn :none with :target :browser result in my not seeing println messages in the browser console? I’ve tried setting this locally is dev mode and there doesn’t seem to be any effect. Somewhat ironically, I was only checking it disabled printing in dev mode so that I can be sure that I’ve got the correct setting to use in my release build. I’m now wondering if it is overridden in dev when the shadow-cljs websocket is in use. Anyway, I’d like to disable printing in prod / release builds… so does anybody know if this option should still work, because it’s not mentioned in the current documentation, but I can see it in the source code?shadow-cljs release <build>and do a hard refresh of the page you’re developing in
(set-print-fn! (fn [x])) in your :init-fn:module-hash-name with a :node-script target ? I couldn’t get it to work but was just wondering if this is possibleclojure.spec.gen.alpha up and running in a CLJS project with shadow?
I’ve followed https://clojure.org/guides/spec#_generators and added org.clojure/test.check to our dependencies, but when I invoke (gen/generate (s/gen int?)) in the repl I get something like a deref error. (`[clojure.spec.gen.alpha :as gen]` & [cljs.spec.alpha :as s])clojure.test.check.generatorsclojure.test.check.generators did the trick:dev-http servers NEVER redirect. that functionality does not exist. unless of course you use a custom handler that does that. the built-ins don'tshadow-cljs pom and importing the pom.xml as a project https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive:dev/after-load https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reloadwith-redefs in shadow-cljs test builds?foo_test.foo is not a functiondeps.edn
{:src ["paths"]
:deps {org.clojure/clojurescript {:mvn/version "1.10.758"}
reagent {:mvn/version "1.0.0-alpha2"}}
:aliases {:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.8"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
and my shadow-cljs.edn
{:deps true
:dev-http {8080 "target/"}
:builds {:app {:target :browser
:output-dir "target/"
:asset-path "."
:modules {:main {:entries app.core}}
:devtools {:after-load app.core/main}}}}
when I call clj -A:shadow-cljs compile app I get the following exception.
Execution error (IllegalArgumentException) at shadow.build.js-support/eval11018$loading (js_support.clj:1). No matching field found: getRegisteredGroups for class com.google.javascript.jscomp.DiagnosticGroupsIf anybody can spot what I am doing wrong, I would greatly appreciate it.
no output for id: [:shadow.build.classpath/resource "goog/base.js"] Is that still a deps and/or versioning problem?:entries should be [app.core]. dunno why the spec allows a lone symbol there.clj is fine but a lot slower 😛:exclusions
[com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party];; shadow-cljs configuration
{:source-paths ["src"]
:dev-http {8081 "public"}
:nrepl {:port 55555}
:dependencies [[reagent "1.0.0-alpha2"]]
:builds {:app { :target :browser
:output-dir "public/scripts/"
:modules {:core
{:init-fn com.ghufran.core/run }}
:compiler-options {:source-map true
:source-map-detail-level :all
:source-map-include-sources-content true
}}}}
and this is the error I’m getting in the browser console (chrome) on first loading the page:
DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0and this is the error in the firefox console:
Source map error: Error: request failed with status 404 Resource URL: Source Map URL: com.ghufran.core.js.mapI’m actually getting around 30 such errors, one for each file in
/cljs-runtime/ whose source map the browser can’t find
It looks like the browser is expecting the source map to be in /js/cljs-runtime/ when it should be /scripts/cljs-runtime/ based on the shadow-cljs.edn file, if I’ve understood that correctly. I’ve confirmed that com.ghufran.core.js.map is in fact in /scripts/cljs-runtime/ Any idea what might be going on? Is there some other config I need to tweak?:compiler-options, you are just relying on the default :asset-path "/js" which is incorrect in your case.{:source-paths ["src"]
:dev-http {8081 "public"}
:nrepl {:port 55555}
:dependencies [[reagent "1.0.0-alpha2"]]
:builds {:app {:target :browser
:output-dir "public/scripts"
:asset-path "/scripts"
:modules {:core {:init-fn com.ghufran.core/run}}
}}}{:require {#{app.ui} [[hoplon.core :as h]]}}
something like that in shadow-cljs.edn would be great as a build option:devtools {:preloads [day8.re-frame-10x.preload
shadow.remote.runtime.cljs.browser
devtools.preload]}shadow.user> (shadow/watch :app) [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (1202 files, 4 compiled, 7 warnings, 13.32s) shadow.user> (shadow/repl :app) To quit, type: :cljs/quit [:selected :app] cljs.user> (tap> 123) truehowever, I see no output in the inspect tab of the shadow UI
cljs.user prompt at the bottom to do the tap> ?cljs.user prompt eithershadow-cljs browser-repl and then (require 'shadow.remote.runtime.cljs.browser)ns macro. Best place would be in ClojureScript, but that will never happen, unfortunately:refers, though::card/card::card is one of my ui libs(ns (:require-shadow :exclude [some.unwanted.ns])) (:require [[the.usual :as whatever]])
.nrepl.edn or ~/.nrepl/nrepl.edn. But it's not picking up the changes. I feel like I'm missing something here. I'm using :react-native as target.:nrepl part of the settings on shadow-cljs.edn and move the :dependencies to deps.edn . But if somebody thinks otherwise do let me know!.nrepl.edn should be picked up(shadow/nrepl-select :app) and that's how you specify which build for each repl:^const for constants that will not change in a live-reload context, so that they can be used with case, like (case x my-const ...)?^:const had issues in a couple releases. should be fixed in 2.9.8. also don't use ^:const 😛case is exactly the problem. it works differently in clojure.Requested module does not have an export "EventDispatcher". --- js/lul/OrbitControls.js:10and many like it. the js-file looks like this:
import {
EventDispatcher,
MOUSE,
Quaternion,
Spherical,
TOUCH,
Vector2,
Vector3
} from "three";
when looking at your example: https://github.com/shadow-cljs/examples/blob/master/local-js/src/demo/foo.js
it seems like you are doing the same thing. so can't really figure out what I'm doing wrongimport * as THREE from "three" should do it.import THREE from "three"require/`module.exports` is commonjs? and that's what shadow-cljs prefers?import * -part. but if I did the require(...)-way it works. :xtap> returned its argument so that you could put it in the middle of thread macrosdoto is universally useful for things like that but yes I feel this pain toodototap>, not something shadow-cljs can change(let [a (f)
b (f' a)
_ (tap> b)
c (f'' b)]
c)
?> ?-> ?->> that captures the source location as wellrelease builds" stuff yet[shadow.debug :refer (?> ?-> ?->>)] in their requires(shadow.debug/locals) which dumps all the locals at that location as a taptap>. no clue how this would look when done properly.The required namespace "enqus.views" is not available, it was required by "enqus/main.cljs" with a file tree like this:
src/cljs/enqus/main.cljs src/cljs/enqus/views/views.cljsWhere
views.cljs starts off with (ns enqus.views?shadow-cljs.edn includes :source-paths ["src/cljc" "src/cljs"]enqus.views.views in that case?(:require ..) vectors in the ns declaration seemed to lead to errors - can you take a look when you get a chance and let me know of any errors / omissions? Thanks!(ns (:require [devcards.core :as dc]) (:require-macros [devcards.core :refer [defcard]]))
(ns
(:require
[devcards.core :as dc :refer [defcard]]))[thheller/shadow-cljsjs "0.0.21"]. just need to install marked.shadow-cljsjs has always been a dependency of shadow-cljs and you never need to require it directly. you never did so I don't know what made you think you need the require. would be curious to know what made you think that??> et. al. -- sounds interesting 🙂 I've played around a bit in this area with miracle.save, but I hadn't considered you could get line information. this is only possible in cljs, right? I haven't figured out a way to capture this in clojure:devtools {:repl-pprint true} if you want pprintlocalhost:3000 for :dev mode and for :release ?
Thanks--config-merge in general:as for a browser build, but resolves to nil in an :npm-module build.
Additionally, in an :npm-module build :default resolves the package correctly.
I'm using this js library https://www.npmjs.com/package/@date-io/date-fns/v/1.3.13
I noticed that their package.json (within node_modules/@date-io/date-fns) has this :
{"name": "@date-io/date-fns",
"version": "1.3.13",
"description": "Abstraction over common javascript date management libraries",
"main": "build/index.js",
"module": "build/index.esm.js",
I'm not sure if that module entry is what's messing things up.
at a plain node repl:
> require('@date-io/date-fns')
[Function: DateFnsUtils]
it doesn't come in as an object with default on it - which is the desired behavior and is what happens in the :browser build.
this is confirmed in a shadow browser-repl also:
(require '["@date-io/date-fns" :as d1]) cljs.user=> d1 #object[DateFnsUtils]anyway. I got things working by doing this:
(:require ;; for browser target ["@date-io/date-fns" :as date-fns] ;; for npm-module target ["@date-io/date-fns" :default date-fns2]) (def date-util-fn (or date-fns2 date-fns))I'm not sure what is causing the difference, but posting here in case someone knows or has run into this.
npm-module build: shadow.js.shim.module\$\$date_io\$date_fns.js
goog.provide("shadow.js.shim.module$$date_io$date_fns");
goog.provide("module$shadow_js_shim_module$$date_io$date_fns");
shadow.js.shim.module$$date_io$date_fns = require("@date-io/date-fns");
module$shadow_js_shim_module$$date_io$date_fns.default = shadow.js.shim.module$$date_io$date_fns;require("@date-io/date-fns");. it probably defaults to using the module entry whereas shadow-cljs and node default to using mainrequire:browser) I have some limited control which is why it defaults to main still since modules only really works if every package you use supports it:target :browser but be able to access NodeJS APIs like fs? My use case is the renderer process in an electron app:js-options {:js-provider :require}
Will this still bundle things up? Do I need to bundle things up in an electron app?
I'll research this, but if anyone knows, holler!:require will not bundle anything no.:js-options {:keep-as-require #{"foo" "bar"}} which wouldn't bundle those if you mean thatfs to be from the encompassing runtime, it would keep it as require:js-options {:keep-native-requires true}:compiler-options {:optimizations :simple}
but I also want to investigate further to learn more and mby help others.
I have a fulcro app with shadow-cljs and I used Formidable’s Victory for a simple bar chart. I colored the bar fills with a function
(fn [data]
(let [integer-value (.. data -datum -rpn)]
(cond
(> integer-value first-threshold)) "#c43a31"
(> integer-value second-threshold) "#ffa500"
:else "#00ff00")))
While I was developing the colouring worked, but after deploying a noticed it was all "#00ff00" . The bug seemed to appear randomly on my local environment, but eventually I noticed that it happens always after
shadow-cljs release mainAnd after changing code (and automatically compiling with simple) it started working. With simple optimizations I got it working after deploying too. Am I breaking some obvious rule, or is this something I should investigate more and try to fix?
:infer-externs :auto https://shadow-cljs.github.io/docs/UsersGuide.html#externs
that will likely give you a warning about the (data -datum -rpn). so you ^js data whereever that is coming from and that should fix it.:exclusions works on shadow? I'm trying to use a custom version of test.check that I built (on my group name), but because there is some dep trying to load the original test.check they are conflicting, I tried put :exclusions [org.clojure/test.check] in every dep a I have, but that didn't worked (I'm using :dependencies from shadow itself in this project), is there a way around it?[some-dep "version" :exclusions [foo/bar]?1.0.0 now has generative features on a different ns, pathom 2.3.0-alpha9 bumps EQL, that should fix iteqn-query-language.specs to :preloads if wanted. you can get rid of the goog-define that way. right now I doubt that most people are aware of the INCLUDE_SPECS define?:include-specs true or so and it auto includes foo.bar-specs in development if foo.bar is part of the build*-specs during devpathom includes edn-query-language.core. with the flag shadow-cljs would detect edn-query-language.core-specs and also include that automatically in dev:advanced even if never used:advancedindex.js for debug builds, instead going for document.write('<script...>') like vanilla cljs tooling?:browser there is an option to emit multiple files. for react-native there is not.IllegalArgumentException: No matching field found: exist for class .File
clojure.lang.Reflector.getInstanceField (Reflector.java:397)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
shadow.cljs.devtools.server.npm-deps/install-deps (npm_deps.clj:160)
shadow.cljs.devtools.server.npm-deps/install-deps (npm_deps.clj:131)
shadow.cljs.devtools.server.npm-deps/main (npm_deps.clj:242)
shadow.cljs.devtools.server.npm-deps/main (npm_deps.clj:228)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:141)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)2.9.10[macchiato.server :as http], I get the following error on startup:
SHADOW import error C:\Shared\orgpad\.shadow-cljs\builds\preview\dev\out\cljs-runtime\shadow.js.shim.module$xregexp.js
Error: Cannot find module 'xregexp'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at C:\Shared\orgpad\.shadow-cljs\builds\preview\dev\out\cljs-runtime\shadow.js.shim.module$xregexp.js:3:33
at global.SHADOW_IMPORT (C:\Shared\orgpad\preview\preview.js:64:44)
at C:\Shared\orgpad\preview\preview.js:2329:1
at Object.<anonymous> (C:\Shared\orgpad\preview\preview.js:2342:3)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)npm install xregexp?(def routes
["/" {"" {:get #'home}
"message" {:post #'message}}])#(home %) might be better? assuming it just gets one arg 😉shadow-cljs watch on a build without injecting nREPL related things into the output? I’m using the :node-script target and have a coworker who doesn’t use a REPL (I know, I’ve tried to convince him), but would still like to have the auto-compile functionality of the watch whenever the file is changed.node my_script.js and then connect my REPL. In his case tho, he’d like to run the script manually upon every change, and have it exit normally.:devtools {:enabled false} in the build. then it won't connect and just exitshadow-cljs.local.edn or so which could override shadow-cljs.edn config stuffshadow-cljs watch the-script --config-merge "{:devtools {:enabled false}}" also works though:script-calvin and :script-eric hahashadow-cljs release $test-build failsshadow-cljs release for the build and then run the tests normally?shadow-cljs package?npm install shadow-cljs in the project?--- cljs_test_display/core.cljs:411 illegal initialization of @define variable cljs_test_display.core.root_node_id
:browser-test?:advancedset! goog-define constantscljs-test-display repo. should be an easy fix. I can do that later toocider-jack-in to this project:
> Error building classpath. Manifest type not detected when finding deps for metosin/pohjavirta in coordinate #:local{:root "/System/Volumes/Data/home/arne/github/pohjavirta"}a164d8ba32f48a632a3f285f41a52f93d7bd024d ? thanks!:browser-test I guess. first time this has come up. 🙂(-> (puppeteer/launch)
(.then (fn [browser]
(-> (.newPage browser)
(.then (fn [page]
(.goto page url #js{:waitUntil "networkidle2"})
(.screenshot page #js {:path "screenshot.png"})
(.close page)))))))(node:5068) ExperimentalWarning: The fs.promises API is experimental
(node:5068) UnhandledPromiseRejectionWarning: Error: Could not find browser revision 756035. Run "npm install" or "yarn install" to download a browser binary.
at ChromeLauncher.launch (C:\Shared\orgpad\node_modules\puppeteer\lib\Launcher.js:59:23)
(node:5068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('', {waitUntil: 'networkidle2'});
await page.pdf({path: 'hn.pdf', format: 'A4'});
await browser.close();
})();(-> (.newPage @browser/browser)
(.then (fn [page]
(log/info "Openning page" url "...")
(-> (.goto page url #js{:waitUntil "networkidle2"})
(.then #(.screenshot page #js {:path "screenshot.png"}))
(.then #(do (log/info "Screenshot of " id "with token" token "generated.")
(.close page)))))))
How would you do flattening?.then always returns another promise.then(-> (puppeteer/launch)
(.then (fn [browser]
(.newPage browser)))
(.then (fn [page]
(.goto page url #js{:waitUntil "networkidle2"})
page))
(.then (fn [page]
(.screenshot page #js {:path "screenshot.png"})
page))
(.then (fn [page]
(.close page))))
shared project used between our different cljs apps in a monorepo, and so we're adding the source-path from here like ../shared/src/client and then getting a lot of these warnings as well
[2020-05-27 12:32:24.902 - INFO] filename violation for ns shcl.core.c.dropzone, got: client/shcl/core/c/dropzone.cljs expected: shcl/core/c/dropzone.cljs (or .cljc)These didn't seem to affect anything with the release build though.
../shared/src as a classpath/source-path?"src/server" "src/client" "src/shared" "../shared/src/app" "../shared/src/server" "../shared/src/client" "../shared/src/shared"
src/client and it doesn't have any issues with that.client/shcl/core/c/dropzone.cljs exists on the classpath. try ( "client/shcl/core/c/dropzone.cljs") from a clojure REPL. shadow-cljs clj-repl or so#object[.URL 0x5a069486 "jar:file:/Users/alex.porter/.m2/repository/fullcontact/redboat.shared/latest/redboat.shared-latest.jar!/client/shcl/core/c/dropzone.cljs"]
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
shadow.cljs.devtools.cli/do-clj-run (cli.clj:112)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:67)
shadow.cljs.devtools.cli/blocking-action (cli.clj:128)
shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
shadow.cljs.devtools.cli/main (cli.clj:179)
shadow.cljs.devtools.cli/main (cli.clj:134)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:221)
shadow.cljs.devtools.cli/-main (cli.clj:219)
clojure.lang.Var.invoke (Var.java:399)
user/eval152 (form-init209812503692384868.clj:1)
user/eval152 (form-init209812503692384868.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7167)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.Compiler.loadFile (Compiler.java:7574)
clojure.main/load-script (main.clj:475)
clojure.main/init-opt (main.clj:477)
clojure.main/init-opt (main.clj:477)
clojure.main/initialize (main.clj:508)
clojure.main/null-opt (main.clj:542)
clojure.main/null-opt (main.clj:539)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
NullPointerException:
com.google.debugging.sourcemap.SourceMapObjectParser.parse (SourceMapObjectParser.java:44)
com.google.debugging.sourcemap.SourceMapConsumerV3.parse (SourceMapConsumerV3.java:68)
com.google.javascript.jscomp.SourceMapInput.getSourceMap (SourceMapInput.java:58)
com.google.javascript.jscomp.Compiler.addSourceMapSourceFiles (Compiler.java:2828)
com.google.javascript.jscomp.Compiler.initBasedOnOptions (Compiler.java:553)
com.google.javascript.jscomp.Compiler.initModules (Compiler.java:533)
com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:729)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/compile-js-modules (closure.clj:1008)
shadow.build.closure/compile-js-modules (closure.clj:997)
shadow.build.closure/optimize/fn--3682 (closure.clj:1195)
shadow.build.closure/optimize (closure.clj:1181)
shadow.build.closure/optimize (closure.clj:1172)
shadow.build.api/optimize (api.clj:267)
shadow.build.api/optimize (api.clj:261)
shadow.build/optimize (build.clj:419)
shadow.build/optimize (build.clj:411)
shadow.cljs.build-report/generate/body-fn--8571--auto----9378 (build_report.clj:219)
shadow.cljs.build-report/generate (build_report.clj:195)
shadow.cljs.build-report/generate (build_report.clj:190)
shadow.cljs.build-report/-main (build_report.clj:261)
shadow.cljs.build-report/-main (build_report.clj:260)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/do-clj-run/body-fn--8571--auto----9150 (cli.clj:110)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:109)
shadow.cljs.devtools.cli/do-clj-run (cli.clj:67)
shadow.cljs.devtools.cli/blocking-action (cli.clj:128)
shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
shadow.cljs.devtools.cli/main (cli.clj:179)
shadow.cljs.devtools.cli/main (cli.clj:134)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:221)
shadow.cljs.devtools.cli/-main (cli.clj:219)
clojure.lang.Var.invoke (Var.java:399)
user/eval152 (form-init209812503692384868.clj:1)
user/eval152 (form-init209812503692384868.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7167)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.Compiler.loadFile (Compiler.java:7574)
clojure.main/load-script (main.clj:475)
clojure.main/init-opt (main.clj:477)
clojure.main/init-opt (main.clj:477)
clojure.main/initialize (main.clj:508)
clojure.main/null-opt (main.clj:542)
clojure.main/null-opt (main.clj:539)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40):browser build? build-report currently has issues with other targets?:shadow-cljs config in my project.clj
{:nrepl {:port 8777}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn plcl.main/init
:preloads [devtools.preload
day8.re-frame-10x.preload]}}
:dev {:compiler-options {:closure-defines
{goog.DEBUG true
re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release {:compiler-options
{:infer-externs :auto
:optimizations :advanced}
:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
:devtools {:http-root "resources/public"
:http-port 9222}}}}release also fail?--config-merge to pass command line arguments to the shadow-cljs.edn file. My question is, how do I then use that argument in my application? Thanks in advance for your help<script>_API_KEY = "foo";</script> or so:init-fn via js/MY_API_KEY<body data-api-key="foo"> and load it from thereclosure-defines and set that via --config-mergesed or sodeps.edn{:deps
{time-lib {:local/root "/path/to/time-lib"}}}deps.edn and configure shadow-cljs to use it. see the user-guidevideo.js
The JS docs for video.js (https://docs.videojs.com/tutorial-react.html) for use in react says:
import videojs from 'video.js'and use it like this:
this.player = videojs(this.videoNode, this.props ...)I do a require in my cljs file:
(:require ["video.js" :as vjs])and I’ve tried
(:require ["video.js" :default videojs])But in the first case
vjs/videojs is undefined as is videojs in the second case.
Am I doing something stupid, or is something amiss like having the . in the package name is screwing things up?video.js into my work directory and require it as ["./video.js" :as vjs] and ["./video.js" :default videojs] and its behaving the same so I don’t think it’s because of the period. Its something with video.js is setup? They use videojs both as the. top namespace and as the function that effectively instantiates the instance. I don’t know it that is particularly weird for JS or not… They mention it in their docs on videojs :
> The `videojs()` function doubles as the main function for users to create a https://docs.videojs.com/Player.html instance as well as the main library namespace. - https://docs.videojs.com/module-videojs-videojs.html<script src=""></script> in my index.html and remove the requires for video.js and refer to it as js/videojs it works….(:require ["video.js" :as videojs]) and videojs directly, not the vjs/videojs alias you tried before.:as being just an alias for alias/fooshadow-cljs target from my project. It used to work, but now it errors and I am not sure what changed. Maybe you can help me out figuring out what is wrong:
shadow-cljs - starting via "clojure" [:dev] Compiling ... Execution error (AssertionError) at shadow.build.data/add-source (data.clj:214). Assert failed: (rc/valid-resource? rc) Full report at: /tmp/clojure-1306074555799542362.edn
deps.edn?shadow-cljs? 2.9.10shadow-cljs clj-repl and then(in-ns 'shadow.build.data)
(defn add-source [state {:keys [resource-id resource-name] :as rc}]
(when-not (rc/valid-resource? rc)
(throw (ex-info "invalid resource" {:rc rc})))
(-> state
(update :sources assoc resource-id rc)
(add-provides rc)
(cond->
resource-name
(update :name->id assoc resource-name resource-id)
)))(shadow.cljs.devtools.api/compile :dev)shadow.build.data=> (shadow.cljs.devtools.api/compile :dev)
[:dev] Compiling ...
invalid resource
{:rc {:cache-key ["5b0a111dc988bc0136ede52338f0c7cd98f61a45"], :ns-info {:rename-macros nil, :renames {}, :meta {:file "repl.cljs", :line 1, :column 5, :end-line 1, :end-column 9}, :use-macros nil, :excludes #{}, :name repl, :imports nil, :requires {cljs-bean.core cljs-bean.core, cljs.pprint cljs.pprint, pprint cljs.pprint, promesa.core promesa.core, p promesa.core, cljs.core cljs.core, goog goog}, :seen #{:require}, :uses {->clj cljs-bean.core}, :require-macros {cljs.core cljs.core}, :cljc false, :flags {:require #{}}, :js-deps {}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}, :ns repl, :output-name "repl.js", :file #object[java.io.File 0x32a1aabf "/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :resource-id [:shadow.build.classpath/resource "repl.cljs"], :resource-name "repl.cljs", :type :cljs, :last-modified -3600000, :requires #{cljs-bean.core promesa.core cljs.core goog cljs.pprint}, :macro-requires #{cljs.core}, :url #object[java.net.URL 0x6b7f46f6 "file:/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :provides #{repl}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}}
ExceptionInfo: invalid resource
shadow.build.data/add-source (NO_SOURCE_FILE:14)
shadow.build.data/add-source (NO_SOURCE_FILE:12)
shadow.build.data/maybe-add-source (data.clj:267)
shadow.build.data/maybe-add-source (data.clj:259)
shadow.build.resolve/resolve-symbol-require (resolve.clj:550)
shadow.build.resolve/resolve-symbol-require (resolve.clj:510)
shadow.build.resolve/resolve-require (resolve.clj:561)
shadow.build.resolve/resolve-require (resolve.clj:557)
shadow.build.resolve/resolve-entry (resolve.clj:571)
shadow.build.resolve/resolve-entry (resolve.clj:570)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6827)
clojure.core/reduce (core.clj:6810)
shadow.cljs.util/reduce-> (util.clj:47)
shadow.cljs.util/reduce-> (util.clj:46)
shadow.build.resolve/resolve-entries (resolve.clj:582)
shadow.build.resolve/resolve-entries (resolve.clj:573)
shadow.build.modules/resolve-module/fn--14145 (modules.clj:265)
shadow.build.modules/resolve-module (modules.clj:261)
shadow.build.modules/resolve-module (modules.clj:251)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6827)
clojure.core/reduce (core.clj:6810)
shadow.build.modules/resolve-modules (modules.clj:271)
shadow.build.modules/resolve-modules (modules.clj:270)
shadow.build.modules/analyze (modules.clj:325)
shadow.build.modules/analyze (modules.clj:316)
shadow.build/resolve (build.clj:395)
shadow.build/resolve (build.clj:389)
shadow.build/compile (build.clj:403)
shadow.build/compile (build.clj:397)
shadow.cljs.devtools.api/compile* (api.clj:315)
shadow.cljs.devtools.api/compile* (api.clj:311)
shadow.cljs.devtools.api/compile!/body-fn--17311--auto----17398 (api.clj:324)
shadow.cljs.devtools.api/compile! (api.clj:322)
shadow.cljs.devtools.api/compile! (api.clj:319)
shadow.cljs.devtools.api/compile (api.clj:331)
shadow.cljs.devtools.api/compile (api.clj:326)
shadow.cljs.devtools.api/compile (api.clj:328)
shadow.cljs.devtools.api/compile (api.clj:326)
shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7132)
clojure.core/eval (core.clj:3214)
clojure.core/eval (core.clj:3210)
shadow.cljs.devtools.server.socket-repl/repl/fn--17818 (socket_repl.clj:63)
clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
clojure.main/repl/read-eval-print--9086 (main.clj:437)
clojure.main/repl/fn--9095 (main.clj:458)
clojure.main/repl (main.clj:458)
clojure.main/repl (main.clj:368)
shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:30)
shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:28)
shadow.cljs.devtools.server/from-cli (server.clj:678)
shadow.cljs.devtools.server/from-cli (server.clj:589)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23)
shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
-3600000 - failed: nat-int? in: [:last-modified] at: [:last-modified] spec: :shadow.build.resource/last-modified
:errorstat /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs or so?File: /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs Size: 596 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode: 9570063 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/diogovasconcelos) Gid: ( 1001/diogovasconcelos) Access: 2020-05-28 10:43:16.172569415 +0200 Modify: 1970-01-01 00:00:00.000000000 +0100 Change: 2020-05-20 14:58:43.953551480 +0200 Birth: 2020-02-21 10:50:27.964589751 +0100
Modify: 1970-01-01 00:00:00.000000000 +0100?touch the file to get an updated timestamp?:last-modified -3600000npx shadow-cljs but starting from cider?(ns user
(:require
[shadow.cljs.devtools.api :as shadow.api]
[shadow.cljs.devtools.server :as shadow.server]))
(defn -main
{:shadow/requires-server true}
[& _]
(shadow.server/start!)
(shadow.api/watch :my-project))(shadow.api/rep :my-project).nrepl.edn or so I think. ask in #cider about how to configure middleware[:ddplugin] Configuring build.
[:ddplugin] Compiling ...
[:ddplugin] Build failure:
no output for id: [:shadow.build.classpath/resource "goog/base.js"]
{:resource-id [:shadow.build.classpath/resource "goog/base.js"]}
ExceptionInfo: no output for id: [:shadow.build.classpath/resource "goog/base.js"]
shadow.build.data/get-output! (data.clj:196)
shadow.build.data/get-output! (data.clj:192)
shadow.build/enhance-warnings (build.clj:26)
shadow.build/enhance-warnings (build.clj:22)
shadow.build/extract-build-info/fn--53837 (build.clj:97)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
clojure.core/reduce (core.clj:6828)
clojure.core/into (core.clj:6895)
clojure.core/into (core.clj:6887)
shadow.build/extract-build-info (build.clj:99)
shadow.build/extract-build-info (build.clj:69)
shadow.build/update-build-info-after-compile (build.clj:107)
shadow.build/update-build-info-after-compile (build.clj:105)
shadow.build/compile (build.clj:407)
shadow.build/compile (build.clj:397)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:327)
shadow.cljs.devtools.server.worker.impl/eval55641/fn--55643 (impl.clj:779)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248/fn--55256 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--55247 (util.clj:257)
java.lang.Thread.run (Thread.java:830)shadow-cljs watch ddplugin and fails immediately?The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored.can´t I use dependency anymore?
:node-script target, is it possible to have shadow inline all require(...) calls in order to produce a single, standalone output file? I have the following in my cljs file:
(:require ["@cucumber/gherkin" :as gherkin]
["@cucumber/messages" :refer [IdGenerator]]
)
Which is leading to ...; var x=require("@cucumber/messages"); ... calls in the compiled output. Wondering if there is any way to “inline” those. I’ve tried setting {:js-provider :shadow} but then I run into:
The required JS dependency "stream" is not available, it was required by "node_modules/@cucumber/gherkin/dist/src/stream/GherkinStreams.js".So I’m not sure that this provider is compatible with node…
:aliases
{:cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
thheller/shadow-cljs {:mvn/version "2.9.10"}
reagent {:mvn/version "1.0.0-alpha2"}}}
when I now start shadow-cljs I get an error Use of undeclared Var reagent.core/render-component . How can I import reagent into my project? ( and yes i have absolutly no idea what I"m doing :D )Use of undeclared Var reagent.core/render-component 2 | (:require [reagent.core :as reagent])) 3 | 4 | (defn load-app [] 5 | (reagent/render-component 6 | [:h1 "hallo"] 7 | (. js/document (getElementById "app")))) 8 | 9 | (defn ^:export init
render not render-component(reagent/render -^--------------------------------------------------------------------- Use of undeclared Var reagent.core/render
reagent.core exists just finereagent.dom/render insteadreagent.corealpha things should probably be avoided as a beginner 😛index.js:404 Uncaught TypeError: Cannot read property 'prototype' of undefined
at Object.$jscomp.generator.createGenerator (generator_engine] :879)
at Object.levels (index.js:755)
at Object.above (index.js:380)
at Object.void (index.js:2233)
at eval (index.js:2092)
at HTMLUnknownElement.callCallback (react-dom.development.js:189)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:238)
at invokeGuardedCallback (react-dom.development.js:293)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:307)
at executeDispatch (react-dom.development.js:390)
I've been only able to find this issue thus far: https://github.com/google/closure-compiler/issues/2910 which might be or not be similar.
The component renders but when I try to edit anything, the error above happens.WebRTCAdaptor: λ[mediaConstraints audioConstraint stream]
jsƒ WebRTCAdaptor(initialValues)
I can then instantiate the main object with a (new js/WebRTCAdapter jsparams) and all is well, until it is :advanced compiled and all the names get munged.
I could go thru all the function and property calls and use cljs-oops to ensure they don’t get munged, but it seems like I should be able to figure out how to import /require the js file and shadow-cljs should take care of things (I hope that assumption is correct!)
Then I find out I don’t know how to deal with the object that get’s imported/ required. It’s not coming in as a function or an object with a constructor.
If I try to :require it like ["./antmedia/webrtc_adaptor.js" :as WebRTCAdaptor] I get the object but, its just an js object:
WebRTCAdaptor:
{}
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
And I can’t do a new (new WebRTCAdaptor jsparams)
Uncaught TypeError: module$visx$dashboard$antmedia$webrtc_adaptor is not a constructor
or execute it as a function (WebRTCAdaptor jsparams)
Uncaught TypeError: module$visx$dashboard$antmedia$webrtc_adaptor is not a function
So I come back to the fount of knowledge to humbly ask for guidance.
Is there a nice clean way to do this with shadow-cljs or should I just apply some cljs-oops elbow grease to the <script> imported js?cljs-oops from your mind as an option. NEVER use it. turn on :infer-extern :auto and let the compiler tell you about things it needs externs for. you can just stick a regular CLJS syntax, no need for a library.:advanced because of that. externs aren't enough to fix that, so it just might not be compatible.undefined is that you didn't pass a value that was expected correctly.:compiler-options {:output-feature-set :es6}:es5 so the closure compiler will trying to transpile it downexport WebRTCAdaptor it would work?export { WebRTCAdaptor } at the bottom yes:refer (WebRTCAdaptor) in CLJSexports.WebRTCAdaptor = WebRTCAdaptor; at the bottom instead of the exports:advanced and instead uses the same style as node_modules code:advanced issues that might be worth trying:watch-ext ? I'm trying to make shadow reload my static html file changes but can't figure out where to put that config key.
Ref: https://github.com/thheller/shadow-cljs/blob/7428c212b246f2ce179b2da39678f5d32931b772/src/main/shadow/cljs/devtools/server/worker.clj#L262-L264
I tried: https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading
{...
{:builds
{:app {...
:devtools {:watch-exts #{"css" "html"}}}}}
... but not luck. Btw, this is not documented afaict.(.createServer (node/require "http") http-handler)When running in advance, I get this:
function mo(a,b,c){var d=null!=b&&(b.h&64||r===b.P)?J.b(dh,b):b,e=E.b(d,oj);b=E.b(d,Si);var f=E.b(d,Zh);if(x(Wk.a(f)))return null;try{var g=e.j?e.j():e.call(null);hf.c(c,sd,a);var k=g}catch(l){throw b=l,Error([["could not start [",C.a(a),"] due to"].join("")," ",C.a(b)].join(""));}c=k;d=null!=d&&(d.h&64||r===d.P)?J.b(dh,d):d;d=E.b(d,wm);gf(d,c);hf.H(ko,W,a,new v(null,1,[Si,b],null));return hf.H(jo,xf,new X(null,2,5,Y,[a,Zh],null),new mh(null,new v(null,1,[Wk,null],null),null))}
^
Error: could not start [#'orgpad.screenshot.core/server] due to TypeError: (intermediate value)(intermediate value)(intermediate value).rd is not a function
at mo (C:\Shared\orgpad\screenshot\screenshot.js:443:204)
at Function.so.l (C:\Shared\orgpad\screenshot\screenshot.js:449:21)
at so (C:\Shared\orgpad\screenshot\screenshot.js:447:276)
at Function.<anonymous> (C:\Shared\orgpad\screenshot\screenshot.js:556:154)
at Function.J.b (C:\Shared\orgpad\screenshot\screenshot.js:169:112)
at C:\Shared\orgpad\screenshot\screenshot.js:556:119
at Object.<anonymous> (C:\Shared\orgpad\screenshot\screenshot.js:557:3)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
When switching to :simple compilation, everything works fine.watch my node-library project, it's printing the following on terminal:
[:dev] Configuring build. [:dev] Compiling ... [:dev] Build completed. (213 files, 212 compiled, 0 warnings, 33.38s) [:dev] Compiling ... [:dev] Build completed. (213 files, 0 compiled, 0 warnings, 0.07s) [:dev] Compiling ... [:dev] Build completed. (213 files, 58 compiled, 0 warnings, 1.21s) [:dev] Compiling ... [:dev] Build completed. (213 files, 92 compiled, 0 warnings, 7.22s) [:dev] Compiling ... [:dev] Build failure: The required namespace "shadow.umd-helper" is not available.
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}:advanced(.createServer (node/require "http") http-handler) this I mean ...(:require ["http" :as http]) in the ns and then (http/createServer ...) but that might have issue with regular cljscreateServer in your project:simple then use itThe required namespace "shadow.umd-helper" is not available. happening?:log {:level :debug} in shadow-cljs.edn that will give you a little more log outputsource-files.:level :debug I saw:
[2020-05-30 18:44:37.353 - FINE] :shadow.cljs.devtools.server.reload-classpath/classpath-js-update - {:dir #object[java.io.File 0xbbe1be95 "/home/mauricio/.atom/packages/chlorine/lib"], :name "js/cljs-runtime/sci.impl.max_or_throw.js", :ext "js", :file #object[java.io.File 0xa45ec655 "/home/mauricio/.atom/packages/chlorine/lib/js/cljs-runtime/sci.impl.max_or_throw.js"], :event :mod}
And that gave me clues on what's wrong :+1:cljs-runtime folders.lein new re-frame demo +less +10x +re-frisk +calva +kondo +test +handler and everything from Calva worked great but in order to get "less watch/auto" behaviour I need to run lein less auto (BTW shadow-cljs correctly picks up the changes) is there an example of hooking in lein-less ?
For a dodgy hack ...
(defn hook
{:shadow.build/stage :configure}
[build-state & args]
(future (shell/sh "lein" "less" "auto"))
build-state)lein less in a hook is not a good idea. :configure is called whenever your build config changes while watch is running so you can end up with multiple watches. I recommend using some other tool to run multiple processes for you. eg. https://github.com/strongloop/node-foremanshadow-cljs run dynadoc.core with maybe some args?deps.cljs :npm-deps (of those libraries)shadow watch app . Do you know of an example something like that? I guess the trickiness is making sure tools run at the correct part of the lifecycleless in any shape so I can't make recommendations on which tools to useshadow-cljs 's area of concern:dev-http {3000 "public"} which serves the public folder under port 3000public/css/foo.css however you like:watch-dir, see https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloadingnode-sassnode-sass -w src/sass/main.scss public/css/main.cssnode-sass "running in the background" or in conjunction with shadow ?nf startnf is simpler and does enough for melein less auto step, if I can work it out I would create a PR to make it easier for other beginners.lein-shadow setupvue ui thing is greatshadow-cljs for web project. I have macros, which in the meantime should read from . With shadow-cljs, how do I configure the resources path?:source-paths key (or src if you're using deps.edn)
https://shadow-cljs.github.io/docs/UsersGuide.html#source-paths:resource-paths:dev-http {8080 "target/"}
:builds {:app {:output-dir "target/"
:asset-path "."
:target :browser
:modules {:main {:init-fn }}
:devtools {:after-load !
:preloads [devtools.preload]}}
:devcards {:output-dir "devcards/"
:asset-path "."
:target :browser
:modules {:main {:init-fn devcards.main/init}}
:devtools {:after-load !
:preloads [devtools.preload]}}}:dev-http {8080 ["target/"]
8081 ["devcards/"]}✗ npx shadow-cljs browser-repl <...> cljs.user=> .1 ------ WARNING - :undeclared-var ----------------------------------------------- Resource: :1:1 Use of undeclared Var cljs.user/ -------------------------------------------------------------------------------- 0.1 cljs.user=>
(ns devcards.main
(:require-macros
[devcards.core :refer [defcard]])
(:require [reagent.core :as r]
[devcards.core :as dv]))
(def functional-compiler (r/create-compiler {:function-components true}))
(reagent.core/set-default-compiler! functional-compiler)
(defn hello-component []
[:div "hello-world"])
(defcard hello
(r/as-element [hello-component]))
(defn ^:export init [] (devcards.core/start-devcard-ui!))
(defn ^:export reload []
(println "Refreshing Devcards!"))main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefineddevcards.core is undefined for some reason./cljs-runtime/shadow.module.main.append.js:4 An error occurred when calling (devcards.main/init)
eval @ ./cljs-runtime/shadow.module.main.append.js:4
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2229
(anonymous) @ main.js:2411
main.js:2231 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:2231
(anonymous) @ main.js:2411
main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefined
at Object.devcards$main$init [as init] (main.cljs:18)
at eval (./cljs-runtime/shadow.module.main.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2229)
at main.js:2411devcards/core object or something like it[:devcards] Build failure:The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".
devcardsdevcards.main in the package that you overwrote:js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}}} to "correct" itedn file?shadow-cljs.edn in your build config yesshadow is not defined:output-to "target/ci.js" must match the
basePath: 'target',
// The file itself
files: ['ci.js'],--single-runBuild failure:
Failed to inspect file
...\node_modules\prettier\index.js
it was required from
...\codemirror.cljs
Errors encountered while trying to parse file
...\node_modules\prettier\index.js
{:line 1, :column 1, :message "The file could not be parsed as JavaScript."}
RuntimeException: Exception parsing ".../node_modules/prettier/index.js"
com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:155)IllegalArgumentException: Must call rewindTo before calling getSourcePosition for an earlier line (1298797 < 1300077) com.google.common.base.Preconditions.checkArgument (Preconditions.java:300) com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourcePosition (LineNumberScanner.java:46) com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourceRange (LineNumberScanner.java:58) com.google.javascript.jscomp.parsing.parser.Scanner.getTokenRange (Scanner.java:100)
js-beautify for now which appears to work OK. Not a critical feature.#copy :inclusion.home/inclusion-card-title ----------------^--------------------------------------------------------------- my_app/core.cljs [line 26, col 10] No reader function for tag copy.Does any one have faced this problem.
(cljs.reader/register-tag-parser! 'copy (fn [kw] (copy kw)))
(copy :inclusion.home/inclusion-card-title) directly instead of #copy :inclusion.home/inclusion-card-title.cljs.reader is for reader tags in data parsed by cljs.reader is is not for source code.(cljs.reader/read-string "#copy :foo") is totally fine and you have total control over thatnpm install && npx shadow-cljs watch :devcards:devcards true in your build config. that should be :compiler-options {:devcards true}(defn hello-component []
[:div "hello-world"])
(defcard hello
(dv/reagent hello-component)
{:inspect-data true
:frame true
:history true})(dv/reagent hello):preload authors (eg. re-frame-10x, fulcro-inspect)watch is running. talks directly to the shadow-cljs process precisely so it doesn't need any of the self-hosted things.2.10.0 and should be available in all builds automatically as long as watch is running. I'll document this a bit more soon.:dev build, but I can see 100kb+ of stuff for ghostwheel and its dependencies in my release build report.ghostwheel.core-stubs or so{:builds
{:app
{:target :browser
...
:release
{:build-options
{:ns-aliases
{ghostwheel.core ghostwheel.core-stubs}}}}}:override-deps in deps.edn. Unless, that is, a better and equally reliable approach comes up in the meantime.
Feel free to post in #ghostwheel if anything else comes up.shadow-cljs release app --pseudo-names while shadow-cljs server is running is what I typically do:advanced builds typically take too long to compile so with a watch you can end up queing another rebuild while the current one is runninglein new re-frame test
npm install --save react-chessground
(:require ["react-chessground" :as rcg :default Chessground])
[:> Chessground {}]
Chessground is undefined/nil and (.log js/console rcg) returns an empty object instead of a module.
Tested that the library is working with this example from readme.
https://github.com/ruilisi/react-chessground/tree/master/exampleapp.js:2231 An error occurred when loading benoni.components.chess_ground.js
env.evalLoad @ app.js:2231
app.js:2232 ReferenceError: $jscomp is not defined
at Object.shadow$provide.module$node_modules$chessground$util (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$util.js:1)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$chessground$board (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$board.js:8)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$chessground$api (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$api.js:1)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$chessground$chessground (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$chessground.js:1)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$react_chessground$chessground (:8280/js/compiled/cljs-runtime/module$node_modules$react_chessground$chessground.js:2)
at shadow.js.jsRequire (js.js:66)Uncaught Error: Assert failed: Invalid Hiccup form: [nil {}]$jscomp issues should be fix in more recent versions?2.9.3.
The reference error is happening only when this particular library is loaded.2.9.102.9.10. Still facing the same issue. (upgraded version - lein deps - lein run):compiler-options {:output-feature-set :es6}$jscomp issues should be fixed but I don't know enough about your setup to comment further:compiler-options {:output-feature-set :es6} the reference error disappeared. Able to use the library now.Thanks.shadow-cljs watch app in terminal, and I'm already connected to repl (under user namespace) using intellij cursive (see screenshot for the config).
When I run (shadow/repl :app) I'm getting this message No such var: shadow/repl
What am I missing here?(shadow.cljs.devtools.api/repl ...)shadow.user by default.{:deps {:aliases [:web]}
:builds
{:app {:target :browser
:output-dir "resources/public/app"
:asset-path "/"
:modules {:app {:init-fn limeray.web.core/init}}
:devtools {:http-port 9000
:http-root "resources/public/app"
:preloads [devtools.preload]}}}}
THis is the alias entry in deps.edn
:web {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.94"}
thheller/shadow-cljsjs {:mvn/version "0.0.21"}
tick {:mvn/version "0.4.17-alpha"}
org.clojure/clojurescript {:mvn/version "1.10.597"}
reagent {:mvn/version "0.9.1"}
metosin/reitit {:mvn/version "0.4.2"}
binaryage/devtools {:mvn/version "1.0.0"}
cljs-bean {:mvn/version "1.5.0"}
cljs-http {:mvn/version "0.1.46"}
devcards {:mvn/version "0.2.6"}}}
watch?use port file from nrepl file activated.nrepl-port which shadow-cljs doesn't create:nrepl {:port 12345} and connect to that port directly▶ readlink .nrepl-port webapp/.shadow-cljs/nrepl.port
.shadow-cljs/nrepl.port file directly so that gets a bit easier 🙂shadow-cljs for complex debug purposes, having customized Google Closure Compiler. I've built Google Closure Compiler's v20200504 with mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-shaded.xml and referenced it from project.clj , replacing v20200504 with 1.0-SNAPSHOT . When running ./build-cli.sh I'm having this error:
Compiling 17 source files to /home/andrey/Work/se/shadow-cljs/target/classes
warning: [options] bootstrap class path not set in conjunction with -source 8
/home/andrey/Work/se/shadow-cljs/src/main/com/google/javascript/jscomp/ShadowAccess.java:62: error: cannot find symbol
public static final DiagnosticType NON_GLOBAL_DEFINE_INIT_ERROR = ProcessDefines.NON_GLOBAL_DEFINE_INIT_ERROR;
^
symbol: variable NON_GLOBAL_DEFINE_INIT_ERROR
location: class ProcessDefines
Note: /home/andrey/Work/se/shadow-cljs/src/main/shadow/undertow/ShadowResourceHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
Compilation of Java sources(lein javac) failed.java-11-openjdk-amd64shadow-cljs/src/main/com/google/javascript/jscomp/ShadowAccess.java actually taken from GCC?ProcessDefines is from GCCSNAPSHOT one differs from the v20200504. Though I've built it off of v20200504 tag branchfailed to convert sources-> Shadow JS converting 1861 JS sources failed to convert sources
com.google.common.base.Preconditions.checkNotNullnull it would throw the infamous onegoog.inherits calls in there?class and the comments just aren't updated. can't really tell 😛2.10.0 which includes a pretty significant rewrite of everything REPL. ideally nothing changes from the user perspective but I might have missed stuff.tap> for everything by default, no need to manually enable it anymore./build-cli.sh enough?) and use the compiled/customized shadow-cljs (i.e. what to run instead of npx shadow-cljs compile myns )?lein install should be enough.CALL 2 [length: 30] [source_file: node_modules/turf-jsts/jsts.min.js]
:simple optimizations .. doesn't matter if its minified before or notshadow-cljs.edn and package.json as if i was starting from scratch.project.clj though that isn't really neccessaryMakefile generally so i just modified the one i already had working(ns app.core (:require ["dangerously-set-html-content" :default InnerHTML]))My component is:
(defn component []
(let [html-str "blabla"]
[:> InnerHTML {:html html-str}]))
I get this error in my JS console:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.Thank you in advance for your time!
(ns app.core (:require ["dangerously-set-html-content" :default InnerHTML]))My component is:
(defn component []
(let [html-str "blabla"]
[:> InnerHTML {:html html-str}]))
I get this error in my JS console:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.Thank you in advance for your time!
nil..ns declaration?
(ns app.core :require ["dangerously-set-html-content" :default InnerHTML])Should be:
(ns app.core (:require ["dangerously-set-html-content" :default InnerHTML]))Not sure if it would work without the parantheses
(ns app.core (:require ["dangerously-set-html-content" :as InnerHTML]))
50 | #::table ----------------------^--------------------------------------------------------- No namespace: compute.ui.components.table foundThe
compute.ui.components.table is required in the namespace this error is in. Is there a known issue with namespace map syntax?139 | #::calendar{:value selected-date
-------------------------^------------------------------------------------------
No namespace: compute.ui.components.calendar foundnpx shadow-cljs realease app . But how do I pack the node_modules?:browser build you only need the files in the :output-dir:browser . If I did something like <link rel="stylesheet" href="node_modules/suneditor/dist/css/suneditor.min.css"> , copy it to the css asset?cljs-runtime dir is from dev builds (ie. watch). it is not produced or required by release builds.:modules config. if you only have :modules {:app ...} then yes:modules {:app {:entries [app.core]}}app.js ?app.js in your :output-dir:require on [cljs.core.async.impl.ioc-macros :as ioc] which isn't in andare. Was wondering now if you'd consider removing it or gutting it of the internal async stuff. I've removed it locally and have had no problems running my regular shadow workflows, for what that's worth. Andare's implementation is probably not ideal but seems like the best way to accomplish getting core.async on self-hosted cljs for now. You might have a better sense if anyone is using that go! macro though.:require on [cljs.core.async.impl.ioc-macros :as ioc] which isn't in andare. Was wondering now if you'd consider removing it or gutting it of the internal async stuff. I've removed it locally and have had no problems running my regular shadow workflows, for what that's worth. Andare's implementation is probably not ideal but seems like the best way to accomplish getting core.async on self-hosted cljs for now. You might have a better sense if anyone is using that go! macro though.[thheller/shadow-client "1.3.3"]function aa() {
var a = {}, b = null;
a.a = 1,
b.a = 2,
Object.defineProperties(a, b);
}
Latest master of GCC produces the same error (just double-checked that)sth = Object.defineProperties(Bi, Vi); it would passBi object just got an update with Object.defineProperties by adding some Vi properties to it. But the object isn't used anymore so it wants to optimize that extra work (calling Object.defineProperties) awayBi (or a in my case) won't be used anymore{:foreign-libs
[{:file "devcards/js_libs/highlight.pack.js"
:provides ["devcards-syntax-highlighter"]
:global-exports {devcards-syntax-highlighter DevcardsSyntaxHighlighter}}
{:file "devcards/js_libs/marked.min.js"
:provides ["devcards-marked"]
:global-exports {devcards-marked DevcardsMarked}}]
:externs ["devcards/js_libs/highlight.ext.js"
"devcards/js_libs/marked.ext.js"]
:npm-deps {"create-react-class" "15.6.3"
"react" "16.13.1"
"react-dom" "16.13.1"}}dev-http server does not startup on an arch linux box. Has anyone seen this before and what do you recommend to tracking down the issue?:dev-http(include-css "/css/site.css") tried tinkering with :watch-dir "resources/public/" and :watch-dir "resources/public/css" / restarting shadow .etc. What else should I try ?re-frame-template?re-frame-template?:node-libray (and to an extent :node-script): https://github.com/martinklepsch/shadow-src-map-issues
Did anyone else encounter unexpected results with source maps and these targets?npm install --save-dev shadow-cljsdidn’t add a package.json, will fix
$ node -r source-map-support/register -e 'var x = require("./functions/index"); x.throw()'
/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/index.js:253
556298533),Ve=new Tb(null,"more-marker","more-marker",-14717935);function qf(a){throw Error(["[",G.a(a),"] Fabricated example exception"].join(""));}var rf=["icebreaker","server","util_reduced","something_that_throws"],sf=aa;rf[0]in sf||"undefined"==typeof sf.execScript||sf.execScript("var "+rf[0]);for(var tf;rf.length&&(tf=rf.shift());)rf.length||void 0===qf?sf=sf[tf]&&sf[tf]!==Object.prototype[tf]?sf[tf]:sf[tf]={}:sf[tf]=qf;
^
Error: [api-endpoint-error] Fabricated example exception
at qf (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/cljs/core.cljs:10747:20)
at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/goog/base.js:169:3)
at [eval]:1:46
at Script.runInThisContext (vm.js:96:20)
at Object.runInThisContext (vm.js:303:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at evalScript (internal/bootstrap/node.js:582:27)
at startup (internal/bootstrap/node.js:267:9)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)-r source-map-support/registerError: [api-endpoint-error] Fabricated example exception
at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/icebreaker/server/util_reduced.cljs:4:30)
at [eval]:1:462.10.5index.transit.json and the bootstrap analysis files into js files, and then rewrite a selfhost load/`init` function based on the current shadow browser load mechanism? Or is there something obvious I'm missing<script src="x.js"> tag with the source being
var transit123 = ...and kinda have a "fake ajax" layer that way, but yeah maybe I should try the big file first to see how that works
<script type="my-transit" data-key="some-name">... transit contents here ...</script> (or <template>) tagsdata-key or so and parse the textscript tags have a non-js type the parser just skips over them. that should be pretty fast and you are talking about local access so no network concerns.{:foo "</script">"} transit encoded value in there since the HTML parser is just looking for </script> and doesn't to any kind of other parsingshadow-cljs watch app every time after saving to compile it. But the changes are getting rendered. What might be the issue here?shadow-cljs watch app again. Whereas in the files that are already present in the project, if I make any changes and save them, they directly get rendered.:require the namespace in any ns?shadow-cljs readyWARNING: The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility. is this error message is about what?:dependencies in shadow-cljs.end anymore?thheller/shadow-cljs dependency is being ignoredshadow.lazy to load the code dynamically on my SPA. In production I have static assets fronted by nginx and served by a CDN. After digging into it a little I can't figure out how a call to shadow.lazy/load translates into a web request, and I can't confirm whether or not it's still going to play well with my setup in production. Any pointers are greatly appreciated!$jscomp errors on 2.10.5, with :output-feature-set :es6 set. I'm able to work around it by setting :output-feature-set :es-next although that seems like a less-than-ideal workaround?
The $jscomp errors appear to be linking back (through sourcemaps) to places where my NPM depdendencies are using async or other later-than-ES6 features in their original (not distributed) source -- a specific example of this from my dependencies is react-hook-form .
On that hunch I switched to the :es-next feature set, but I assume this is some kind of issue with polyfills being used?
I'll try to reduce this example down at some point, but hopefully the tracing back to the use of async is at least somewhat informative!
Potentially relevant to https://github.com/thheller/shadow-cljs/issues/709 ?shadow-cljs info also has all the infoshadow-cljs watch app or whatever and paste the output. I'd be very surprised if it didn't print the info on startup 😛:asset-path + <module-id>.jsshadow.loader. you may set :module-loader-init false in your build config but then must call (shadow.loader/init "") before actually using the loader anywhere (eg. first thing in :init-fn)shadow.loader. you may set :module-loader-init false in your build config but then must call (shadow.loader/init "") before actually using the loader anywhere (eg. first thing in :init-fn):asset-path also controls all of this:asset-path "" will end up loading your modules from there. so :modules {:main ...} would be :asset-path to have different values for dev vs prod builds?:release {:asset-path ""}shadow.loader uses google module manager which in turn uses bulkloader which in turn uses Xhrio, so it should just come down to a web request for that asset. I'm probably just missing something obvious and now I've rambled for too long, but anyways that's where I was coming from.react-hook-form -- specifically when it uses any later-than-ES6 features like async functions.Wrong number of args passed to keyword: :ns-aliases :bundle to work I think. there isn't really any clear guidance on how that is supposed to work with foreign-libs in regular CLJS yet. not sure how that will turn out.main.js is served in my test app, and it appears to be the same one that is built for dev app… as moving it causes it to 404:devtools-url doesn't show any difference either, so I'm creating a route in the embedding service, as a workaround for development. Does shadow also want a ticket for this?:devtools {:loader-mode :script} in your build config to go back to regular script tags or fetch:devtools-url only really controls the websocket connection. it doesn't have anything to do with how the code is loaded into the page initiallydeno? My hard disk is fulled withdeno would just give you deno_modules or whatever the name for the directory it uses isdenonode_module shared:asset-path "/" config XD
So when embedding {:tag :script, :attrs {:src "<http://shadow.host/base.js>"}, :content ("</code> into a page from <code>embedding.host</code>\n• eval loader basically works, but can't find its source maps: <code>DevTools failed to load SourceMap: Could not load content for <http://embedding.host/cljs-runtime/goog.debug.error.js.map>: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE</code>\n• script loader tries to load code from the embedding host, but source maps presumably would work, if that was fixed (and maybe the asset-path issue): <code>GET <http://embedding.host//cljs-runtime/goog.debug.error.js> net::ERR_ABORTED 404 (Not Found)</code>\nI understand, that this may not be a supported use case, yet, so am working around it with adding proxy routes, but if you'd want to support this for shadow, I'd be happy to help with that as well, <span class=\"username\">@thheller</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:14:24.227500Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591802064.227500\" rel=\"nofollow\">15:06:24</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>or am I just missing a config setting? XD</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:28:46.228500Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591802926.228500\" rel=\"nofollow\">15:06:46</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>oh .. I think I might be able to do this with just <code>:proxy-url</code> ... brb, trying</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:36:57.228800Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803417.228800\" rel=\"nofollow\">15:06:57</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>you are missing the correct <code>:asset-path</code> basically <span class=\"emoji\">😛</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:10.229100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803430.229100\" rel=\"nofollow\">15:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>blame the name on CLJS. you can put the entire url in there</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:10.229100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803430.229100\" rel=\"nofollow\">15:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>blame the name on CLJS. you can put the entire url in there</p></p></span></div><div class=\"message thread-msg\" id=\"inst-2020-06-10T18:41:52.230000Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803712.230000\" rel=\"nofollow\">15:06:52</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>oh, I didn't know that, thanks!</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:57.229900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803477.229900\" rel=\"nofollow\">15:06:57</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>why are you serving the files from a different host though? its just static files, whyt not just serve them from the regular host?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:44:48.231400Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803888.231400\" rel=\"nofollow\">15:06:48</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>to do with our current deployment structure and an in-progress refactoring, where we use shadow modules in a legacy application</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:50:40.234300Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591804240.234300\" rel=\"nofollow\">15:06:40</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>but OTOH, legacy has just the loader stubs, which don't change that often and there hardly a case for not including these advanced-compiled, even during development, so your idea is probably still the better one ... I'll go with that.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T20:54:53.238200Z\"><a class=\"message_profile-pic\" href=\"/team/U083D6HK9\" style=\"background-image: url(https://avatars.slack-edge.com/2019-07-17/697988944069_29e7fb533f304a8bc61a_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U083D6HK9\">kenny</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591811693.238200\" rel=\"nofollow\">17:06:53</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>Is there some documentation that enumerates all of the keywords and their definitions available in shadow-cljs.edn?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T21:13:13.239200Z\"><a class=\"message_profile-pic\" href=\"/team/U083D6HK9\" style=\"background-image: url(https://avatars.slack-edge.com/2019-07-17/697988944069_29e7fb533f304a8bc61a_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U083D6HK9\">kenny</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591812793.239200\" rel=\"nofollow\">18:06:13</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>If an <code>index.html</code> exists in the shadow http server root paths and <code>:push-state/index</code> is set to <code>other-index.html</code>, shadow will still serve <code>index.html</code> by default, not <code>other-index.html</code>. Is this the desired behavior?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T22:35:33.239900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591817733.239900\" rel=\"nofollow\">19:06:33</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><span class=\"username\">@kenny</span> I guess that could be considered a bug. index.html always is picked first since it is picked way before the push-state handler is ever called.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T23:52:55.242100Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822375.242100\" rel=\"nofollow\">20:06:55</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>Not sure if this is already know/reported, but I'm trying out shadow-cljs 2.10.5. I have a cljs browser repl open, when I eval an aliased ns I get Invalid keyword error:\n<pre class=\"highlight\"><code>; in ns form: (:require [com.fulcrologic.fulcro.application :as app])\n (-> app1 ::app/runtime-atom)\n\n(-> app1 ::app/runtime-atom)\ndummy.cljs [line 1, col 28] Invalid keyword: ::app/runtime-atom.</code></pre>\nTried using 2.9.8 and there is no issue there</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T23:59:40.242300Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822780.242300\" rel=\"nofollow\">20:06:40</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>this is from a cljs file</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:01:24.242700Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822884.242700\" rel=\"nofollow\">21:06:24</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>which ns are you in? try <code>::foo</code> to see if its the one you expect?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:14:01.243200Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823641.243200\" rel=\"nofollow\">21:06:01</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><pre class=\"highlight\"><code>(println ::foo)\n (println (keys (app/fulcro-app)))\n (println ::app/hi)\n\n;; repl window:\n(println ::foo)\n:app.devcards-play/foo\n=> nil\n(println (keys (app/fulcro-app)))\n(:com.fulcrologic.fulcro.application/id :com.fulcrologic.fulcro.application/state-atom :com.fulcrologic.fulcro.application/config :com.fulcrologic.fulcro.application/algorithms :com.fulcrologic.fulcro.application/runtime-atom)\n=> nil\n(println ::app/hi)\ndummy.cljs [line 1, col 18] Invalid keyword: ::app/hi.</code></pre></p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:15:20.243400Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823720.243400\" rel=\"nofollow\">21:06:20</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>weird</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:15:58.243900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823758.243900\" rel=\"nofollow\">21:06:58</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>can you try again with <code>shadow-cljs cljs-repl app</code> (or whatever your build id is)</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:16:08.244100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823768.244100\" rel=\"nofollow\">21:06:08</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>I assume this is over nrepl?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:16:15.244300Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823775.244300\" rel=\"nofollow\">21:06:15</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>yep</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:17:06.244600Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823826.244600\" rel=\"nofollow\">21:06:06</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>ah nvm. got it reproduced.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:17:10.244800Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823830.244800\" rel=\"nofollow\">21:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>ah kk</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:23:05.245000Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824185.245000\" rel=\"nofollow\">21:06:05</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>fixed in master</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:23:20.245200Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824200.245200\" rel=\"nofollow\">21:06:20</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>probably won't make a release today though</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:27:47.245600Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824467.245600\" rel=\"nofollow\">21:06:47</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>awesome, thanks - no worries I am working around it</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:48:07.246500Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591825687.246500\" rel=\"nofollow\">21:06:07</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><span class=\"username\">@danvingo</span> released <code>2.10.6</code> with the fix. too tired to work on the other thing anyways <span class=\"emoji\">😛</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:58:26.246700Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591826306.246700\" rel=\"nofollow\">21:06:26</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>lol thank ya</p></p></span></div></div></div></div></body></html>")}(ns ui.components.picker.core
(:require ["@material-ui/pickers" :refer [TimePicker DatePicker MuiPickersUtilsProvider]]
["@date-io/moment" :as MomentUtils]
[ui.utils.core :as utils]
[reagent.core :as reagent]))
(def component-styles {})
(def component-props {:inputVariant "outlined" :fullWidth true})
(defn date-picker-real [props & children]
(let [all-props (-> component-props (merge props))]
(utils/->component DatePicker all-props
:styles component-styles
:children children)))
;; Call this datepicker from the UI; really it's just wrapping the actual DatePicker component with the MuiPickersUtilsProvider, which is necessary to get this all to work.
(defn date-picker [props & children]
[:> MuiPickersUtilsProvider {:utils (reagent/as-element MomentUtils)} [date-picker-real props children]])
This works well if I compile to a browser target. But when I compile to npm module, I get error messages like the following:
VM53713 react_devtools_backend.js:6 Warning: Failed prop type: Invalid prop `utils` of type `object` supplied to `MuiPickersUtilsProvider`, expected `function`.
[. . .]
Uncaught TypeError: Utils is not a constructor
at eval (useUtils-cfb96ac9.js?2ccd:11)
at mountMemo (react-dom.development.js?61bb:15442)
at Object.useMemo (react-dom.development.js?61bb:15738)
at useMemo (react.development.js?72d0:1521)
at MuiPickersUtilsProvider (useUtils-cfb96ac9.js?2ccd:10)
at renderWithHooks (react-dom.development.js?61bb:14803)
at mountIndeterminateComponent (react-dom.development.js?61bb:17482)
at beginWork (react-dom.development.js?61bb:18596)
at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:237)
Seems strange the behavior would change depending on compilation method, so wondering if I might be missing something?MomentUtils is in the npm build?(js/console.log (reagent/as-element MomentUtils)) ?as-element… what is MomentUtils? we need to know{:utils (reagent/as-element MomentUtils)} isn't correct and that it expects an actual class/function there. so maybe just {:utils MomentUtils}Module {__esModule: true, Symbol(Symbol.toStringTag): "Module", default: ƒ}
default: ƒ MomentUtils(_a)
arguments: (...)
caller: (...)
length: 1
name: "MomentUtils"
prototype:
addDays: ƒ (date, count)
date: ƒ (value)
endOfDay: ƒ (date)
endOfMonth: ƒ (date)
format: ƒ (date, formatString)
formatNumber: ƒ (numberToFormat)
getCalendarHeaderText: ƒ (date)
getDatePickerHeaderText: ƒ (date)
getDateTimePickerHeaderText: ƒ (date)
getDayText: ƒ (date)
getDiff: ƒ (date, comparing)
getHourText: ƒ (date, ampm)
getHours: ƒ (date)
getMeridiemText: ƒ (ampm)
getMinuteText: ƒ (date)
getMinutes: ƒ (date)
getMonth: ƒ (date)
getMonthArray: ƒ (date)
getMonthText: ƒ (date)
getNextMonth: ƒ (date)
getPreviousMonth: ƒ (date)
getSecondText: ƒ (date)
getSeconds: ƒ (date)
getWeekArray: ƒ (date)
getWeekdays: ƒ ()
getYear: ƒ (date)
getYearRange: ƒ (start, end)
getYearText: ƒ (date)
isAfter: ƒ (date, value)
isAfterDay: ƒ (date, value)
isAfterYear: ƒ (date, value)
isBefore: ƒ (date, value)
isBeforeDay: ƒ (date, value)
isBeforeYear: ƒ (date, value)
isEqual: ƒ (value, comparing)
isNull: ƒ (date)
isSameDay: ƒ (date, comparing)
isSameHour: ƒ (date, comparing)
isSameMonth: ƒ (date, comparing)
isSameYear: ƒ (date, comparing)
isValid: ƒ (value)
mergeDateAndTime: ƒ (date, time)
parse: ƒ (value, format)
setHours: ƒ (date, count)
setMinutes: ƒ (date, count)
setMonth: ƒ (date, count)
setSeconds: ƒ (date, count)
setYear: ƒ (date, year)
startOfDay: ƒ (date)
startOfMonth: ƒ (date)
constructor: ƒ MomentUtils(_a)
__proto__: Object
__proto__: ƒ ()
property: ƒ (prop, desc)
apply: ƒ apply()
arguments: (...)
bind: ƒ bind()
call: ƒ call()
caller: (...)
constructor: ƒ Function()
length: 0
name: ""
toString: ƒ toString()
Symbol(Symbol.hasInstance): ƒ [Symbol.hasInstance]()
get arguments: ƒ ()
set arguments: ƒ ()
get caller: ƒ ()
set caller: ƒ ()
__proto__: Object
[[FunctionLocation]]: <unknown>
[[Scopes]]: Scopes[0]
[[FunctionLocation]]: index.esm.js?d37f:4
[[Scopes]]: Scopes[4]
Symbol(Symbol.toStringTag): "Module"
__esModule: true
__proto__: Object"default" key in that object__esModule. that is es module rewritten by babel to commonjs["@date-io/moment" :default MomentUtils]:default and see if it gets me anywhere. I didn't write the code in question, but a JS example would be something to the effect of:
import MomentUtils from '@date-io/moment';
import DateFnsUtils from '@date-io/date-fns';
import LuxonUtils from '@date-io/luxon';
import { MuiPickersUtilsProvider } from 'material-ui-pickers';
function App() {
return (
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<Root />
</MuiPickersUtilsProvider>
);
}
render(<App />, document.querySelector('#app'));(reagent/as-element MomentUtils) in lieu of just MomentUtils , so hence the choice of as-element:default worked, with no need for as-element. Interesting quirk. Thanks for the help!as-element would be equivalent to <MomentUtils /> in JScider-jack-in-clj and cider-jack-in-cljs separately?*Messages* buffer it will say the one command being used to start a jvm15-loom is my "default" JDK)JAVA_HOME=~/install/loom clj -m your.loom-stuff?nix right? 😉"nashorn" to "JavaScript". that should be all there is to it.ScriptManager but not convinced that I'm doing it right yetgo macro anymore. just async/virtual-thread or whatever 🙂let-flow which could disect a body of code and automatically parallelize paths(parallelize
(let [a (foo)
b (bar)
c (+ foo bar)]
(println "Hello")
c))(foo) (bar) and (println) in parallel, and then rejoins on cgo macro. just blocking ops everywhere. already using mostly async/thread in shadow-cljs and its sooo much better than go(map f coll) to imperative manipulation, I want ways to operate over queues (eg. stream/map) - but to not have to consider whether something inside those transformations is "blocking" is 😍make-engine* and get-jvm-major-version can be removed)package.json but are declared in a deps.cljs in some library you use:npm-deps {:install false} in the top level of shadow-cljs.edn. then it won't even do that.:npm-deps in deps.cljs at all ... but also have no better ideas 😛:npm-deps behavior is reaaally old. it always worked like that. the only thing I added recently is the ability to turn it off.:npm-deps has nothing to do with the :npm-deps in CLJS:npm-deps:on-jsload option in your config:on-jsload in your config. you maybe never noticed it when your template generated it 😛:fs-watch {:watcher :polling} in shadow-cljs.edn will enable the polling watchFeb 26, 2018 been a while 😛lein. works well for me, does everything I need.mount/start for some reason picks up on the states defined in that background namespace and tries to start them when starting the content script. Is there a way to determine why it is being added?:require controlling all of this but no there is easy visualization or so for thisshadow.module.bg-shared.append.js, ampie.content_script.content.js (my content script ns) and shadow.module.content-script.append.js, that background script is referenced in neither of them.:chrome/single-file and that entry disappeared from the content_scripts.:modules and sharing as much code as possible:ssl {}
• Adding:
:ssl {}
:http {:port 9630 :host "discovery.local"}
• Adding:
:ssl {}
:http {:port 9630 :ssl-port 19630 :host "discovery.local"}
In all cases the basic page works but the websocket doesn’t
Here is the error from the debugger:
🠶 shadow-cljs: websocket error Event bubbles: false cancelBubble: false cancelable: false composed: false currentTarget: null defaultPrevented: false eventPhase: 0 isTrusted: true returnValue: true srcElement: WebSocket URL: "" binaryType: "blob" bufferedAmount: 0 extensions: "" onclose: null onerror: null onmessage: null onopen: null protocol: "" readyState: 3 url: "" WebSocket Prototype target: WebSocket URL: "" binaryType: "blob" bufferedAmount: 0 extensions: "" onclose: null onerror: null onmessage: null onopen: null protocol: "" readyState: 3 url: "" WebSocket Prototype timeStamp: 1101 type: "error" Event Prototype [Error] WebSocket network error: The operation couldn't be completed. (OSStatus error -9807.) 🠶 shadow-cljs: WebSocket disconnected!
The shadow-cljs Websocket was disconnected more frequently. About two~three weeks ago (last time I upgraded) I could leave the watch process and my node process running while putting my computer to sleep and then keep working on my CLJS, but currently it seems that this is not working anymore...react-native log-android. is for the server sending websocket messages to give a 101 Switching Protocols message, so whatever process accepts that connection is where to look. I don't think checking on-device logs will get you what you wantreact-native run-android. Well, the error message also says It was trying to connect to: . I checked with --verbose when running shadow and I see the line Using IP: 192.168.0.62.WebSocket disconnected!Error: addEventListener and attachEvent are unavailable.react-native log-android[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.onJSBundleLoadedFromServer()
[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.recreateReactContextInBackground()
│ ReactInstanceManager.runCreateReactContextOnNewThread()
└ ReactInstanceManager.tearDownReactContext()
[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() start
└ CatalystInstanceImpl.destroyV1() start
[15:32:23] I | ReactNative ▶︎ [GESTURE HANDLER] Tearing down gesture handler registered for root view com.facebook.react.ReactRootView{379a637 V.E...... ......ID 0,0-1440,2392}
[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.createReactContext()
└ Initializing React Xplat Bridge.
[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge before initializeBridge
[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() end
[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge after initializeBridge
[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.runJSBundle()
│ ReactInstanceManager.setupReactContext()
│ CatalystInstanceImpl.initialize()
└ ReactInstanceManager.attachRootViewToInstance()
[15:32:24] D | ReactNative ▶︎ ReactInstanceManager.createReactContextInBackground()
└ ReactInstanceManager.attachRootViewToInstance()
[15:32:25] E | ReactNativeJS ▶︎ Error: addEventListener and attachEvent are unavailable.
[15:32:25] I | ReactNativeJS ▶︎ Running "NewApp" with {"rootTag":61}
[15:32:25] E | ReactNativeJS ▶︎ Invariant Violation: "NewPibe" has not been registered. This can happen if:
│ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
└ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
[15:32:25] I | ReactNativeJS ▶︎ #4 ready!Invariant Violation: "NewPibe" has not been registered. This can happen if:
│ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
└ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.[15:32:25] I | ReactNativeJS ▶︎ #4 ready!Error: addEventListener and attachEvent are unavailable. no clue about this one but the other one above looks like you are maybe calling registerComponent with the wrong name or not at all?[:main] Build failure:
babel failed?
{:file "/home/arne/clj-projects/xterm-sci/node_modules/local-echo/lib/HistoryController.js"}
ExceptionInfo: babel failed?
is there an easy way to see the output from babel?node on its PATH. In the shell I use nvm but emacs doesn't see that.nrepl-server buffer"the-dep":"github:foo/bar" in your package.json dependencies(ns demo.esm.a
(:require
["" :refer (copy)]))(ns demo.esm.a (:require ["" :as x]))
shadow-cljs release I’m seeing the following warnings:
npm package "util" expected version "I did a bit of searching and found this github issue: https://github.com/thheller/shadow-cljs/issues/547 with the quote: > It is quite intentional that it does not follow standard node resolve rules since I will never allow having multiple versions of the same dependency in one build (which happens regularly in webpack builds with nested node_modules dirs). I understand the rationale, but I’m not clear on how I would go about resolving conflicts like the one above, which seem like they’d be rather common. I could use
:js-package-dirs to force the search path to include the newer version of uuid for example, but then the warnings would just swap to another conflict saying that uuid was too new.:js-package-dirs option in this specific circumstance.:js-package-dirs is not what I need. In my specific circumstance i have a big monolith project. I can split the monolith in a way that would avoid these conflicts altogether. :advanced so I don't really care about turning cljs.core into a shareable ESM "library"defrecord maybe but not to mapsdefrecord? and why would tuples be more akin to small vectors?#{a: 1, b: 2} === #{a: 1, b: 2}Map in Set thoughMap and Set , but you can’t do the reverse!:dependencies or :source-paths requires restarting["/graphql/subscriptions" :as subscriptions]
It has an assignment like:
export const onCreateBag =
subscription OnCreateBag {
...
Works fine in dev, but on release (:advanced) the onCreateBag gets munged to $onCreateBag$: and we can’t really use it as a key. This only became a problem from shadow-cljs 2.9.6 onward. (Same code works in 2.9.6 but not on any version after that including 2.10.9)
Is there an easy way to tell shadow not to munge that?
The only other thing unusual is the graphql/subscripitions.js is being required from a Clj dependency of another library as a git dependency in deps.ednsubscription OnCreateBag {?shadow-cljs release whatever locally constantly.shadow-cljs server seperately and keep it running.snowpack was one of the triggers for this. Is there some usable relationship between cljs/shadow-cljs and snowpack for doing cljs development?[shadow.esm :refer (dynamic-import)]:exploding_head:
:browser-test option before, I'm just exploring other option to see which one works well for me.deps: true, and my deps file includes a library via :local/root "../lib-name", does shadow handle the installing of that libraries package.json file? I’m trying to figure out how to package and deploy that library for consumption, and unsure if I need to npm install and bundle it. Sorry if the question is super basicdeps.cljs with {:npm-deps {"foo" "version"}} in one of its :paths. those will be installed.src for example?(ns demo.esm.a (:require ["" :as x]))How is that? And about dependencies?
:modules {:shared
{:entries []}
:main
{:init-fn app.client/init
:depends-on #{:shared}}
:worker
{:init-fn app.worker/init
:depends-on #{:shared}
:web-worker :true}}
:devtools {:after-load app.client/refresh
:browser-inject :main
:preloads [com.fulcrologic.fulcro.inspect.preload]}}
I'm trying to test out web workers. I'm getting an error with the above because the preload expects to have access to document. Is there a way to preload at the module-level rather than the build-level? I also tried splitting the web worker module into a completely separate build, but that resulted in an error about goog.debug.Error (for example) already being declared. Perhaps the answer is still multiple builds, but there's something else I need to do to limit the output of the web-worker build? Or wrap the preload in something that checks its environment?:preloads to the :main module. they can be specified per moduleshadow-cljs and server with pedestal serving the index.html ? Is shadow detect server and let it serve index or do I have to use index just for shadow and other index for app? Do you have any reference to using both in the same project?.js files via your pedestal server directly. They are just static files.| jar | re_frame/loggers.cljc | -717.0 B | -0.17 % | 2.9 KB | 2.2 KB |Negative size, heh.
breadcrumbs.ts:117 shadow-cljs - failed to load 367
(anonymous) @ bundle.min.js:2
13:03:33.676 js.js:75 Uncaught TypeError: $jscomp.initSymbol is not a function
at Object.shadow$provide.<computed> (index.js:178)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at index.js:2
at append.js:2
I remember reading about something related to $jscomp in one of the releases, so I figured this might be a known (familiar?) issue. Last version of shadow-cljs I built against was 2.8.90I'm happy to provide an interim solution to make the transition easier if someone has a good idea how to do so. Wondering if there any other examples or more docs explaining this transition? I have a few JS libs I'm including in my compiled JS and I'm not using NPM for anything. Would love to give shadow-cljs a try!{:file "resources/foreign-libs/hammer.min.js"
:provides ["hammerjs"]}
then requiring it [hammerjs] in a file and (js/Hammer. (.getElementById js/document "selected-photo") nil)module.exports or so?npm install --save hammerjs and (:require ["hammerjs" :as hammer]) and using (hammer. (.getElementById ....))(:require ["/foreign-libs/hammer.min.js" :as hammer]) and use hammer not js/Hammerresources folder) and include it in your buildnpm install --save blueimp-canvas-to-bloband importing
["toBlob" :as to-blob]
but getting The required JS dependency "toBlob" is not available, it was required by "common/file_upload.cljs".
calling it with either (.toBlob canvas ... or (to-blob/toBlob canvas ...)blueimp-canvas-to-blob is the package name(:require ["blueimp-canvas-to-blob" :as to-blob])(setq cider-enhanced-cljs-completion-p nil):devtools {:watch-dir "resources/public/css"
:watch-path "/static"}
this is in my build but doesn't seem to do anything when css is changed, no headsup display notification either:watch-dir "resources/public" :watch-path "/static"resources/public/css/site/app.css exists and is the file served when you load [Error] Error: ["unrecognized request format: " nil] (anonymous function) (re_frame.router.js:6) (anonymous function) (re_frame.router.js:359) (anonymous function) (re_frame.router.js:425:110) (anonymous function) (re_frame.router.js:552) (anonymous function) (re_frame.router.js:291) (anonymous function) (re_frame.router.js:383) (anonymous function) (re_frame.router.js:425:110) G__67540 (re_frame.router.js:336) (anonymous function) (goog.async.nexttick.js:98)
ToolkitProvider and CSVExport but I’m not sure how to get ExportCSVButton out of CSVExport.
["react-bootstrap-table2-toolkit" _:refer_ (CSVExport) _:default_ ToolkitProvider](.-ExportCSVButton CSVExport)Connecting to remote nREPL server... Clojure 1.10.1 (shadow/repl :pos-bare) To quit, type: :cljs/quit => [:selected :pos-bare] 1 The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.In the build section I see the connected runtimes keep getting droped and new ones are created. The logs are also consistent
#17 ready! #18 ready! #19 ready! #21 ready!Any idea what would cause the connected runtimes to keep getting dropped like that? Also this same code works on my friend's laptop so seems like something specific to my setup.
(js/setInterval #(async/go
(let [response (async/<! (http/get ""))]
(log/spy :warn response)))
1000)--verbose option i see the ip address is correct and in react-native log-android I don's see anything informative about why the runtime is getting dropped. Just the following
[20:23:16] I | ReactNativeJS ▶︎ #8 ready! [20:23:39] I | ReactNativeJS ▶︎ #9 ready! [20:24:05] I | ReactNativeJS ▶︎ #10 ready! [20:24:28] I | ReactNativeJS ▶︎ #11 ready! [20:24:52] I | ReactNativeJS ▶︎ #12 ready!https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native
:log {:level :debug} in shadow-cljs.edn but that will likely just confirm that it is indeed kicking because of ping timeoutCompilerOptions object, I could call setRemoveDeadCode(true) on it when using optimizations :none:optmizations :none literally means "do not call the closure compiler at all"filter out the unneeded goog modules in the flush step.:node-library?require that has no support for folders.:node-library and shadow-cljs release while shadow-cljs server is running:npm-module works toocompile might work for that one but you'll be approaching the size limits pretty fast:node-library (or was it node script? don't remember), in dev and release modes. But in this game you'll need to react on the fly to things happening in the world, and it is very useful to see the un-minified code. You'll often react to some event in game by patching the deployed code, then later bringing those changes back into your codebase.:release / advanced optimizations makes that all but impossible.:simple with :pretty-print:simple with just cljs.core is about 1mb. not sure how much code the game code ends up being but that might be fine?:target :esm would be by far the best option for this .. shame they don't support it 😛devtools_page in the manifest needs to point to an .html page, so I generate an ESM module and then manually include it in that .html page?:browser build thoughre-frisk to my :dev build, but not in my :prod build?closure-defines option), but it Just Works™ if I "force compile" the build once in the shadow UI.{:type "default"} exception?(goog-define type "default") is returning "default" - malli will throw an exception; then I "force compile", type is no longer "default" but "custom" and malli continues without errors:closure-defines {malli.registry/type "custom"}:preloads.:require it manually?goog: prefix currently only works for ES6 file. require("goog:cljs.core") does not work.
There's no way to call cljs from js then when ESM isn't available?:npm-module or :node-library["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]] Its working fine. The file is being imported and all the functionality is there.
The issue is that, In dev mode, if I make changes to that JS file, shadow-cljs doesn’t seem to notice and doesn’t do a rebuild.
Is that expected behavior? Or am I doing something wrong?
I also tried putting it in a parallel directory as per https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js (and modified the :require statement to match) and it again worked correctly if I restarted shadnow-cljs watch but shadow-cljs still did not rebuild when I changed something in the js file.tap> feature documented? (require '[shadow.cljs.devtools.server :as server]) (server/start!) (tap> :hello)
:log {:level :debug}
my runtime keeps disconnecting from shadow and I see this log
[2020-06-20 15:59:27.446 - FINE] :shadow.remote.relay.local/client-disconnect - {:client-id 52, :client-info {:since #inst "2020-06-20T22:59:07.397-00:00", :proc-id "d6e4f00e-4f36-442d-a752-0894a052b5f0", :connection-info {:remote true, :websocket true}, :user-agent "Chrome 537.36 [Linux armv8l]", :type :runtime, :lang :cljs, :build-id :back-office, :host :browser, :dom true}}
but looking at the remote chrome devtools network tab i see a sente websocket connection to my server remains robust but but the shadow connection keeps dieing, any ideas why?["^ ","~:op","~:welcome","~:client-id",47] ["^ ","~:op","~:hello","~:client-info",["^ ","~:host","~:browser","~:user-agent","Chrome 537.36 [Linux armv8l]","~:dom",true,"~:type","~:runtime","~:lang","~:cljs","~:build-id","~:back-office","~:proc-id","d6e4f00e-4f36-442d-a752-0894a052b5f0"]] ["^ ","~:op","~:request-notify","~:notify-op","~:shadow.cljs.devtools.client.env/worker-notify","~:query",["~:eq","~:shadow.cljs.model/worker-for","~:back-office"]] ["^ ","~:op","~:request-supported-ops","~:from",3] ["^ ","~:op","~:supported-ops","~:ops",["~#set",["~:ping","~:shadow.cljs.devtools.client.env/worker-notify","~:tap-unsubscribe","~:obj-forget","~:cljs-asset-update","~:cljs-build-start","~:runtime-print-unsub","~:obj-describe","~:cljs-build-complete","~:cljs-eval","~:tap-subscribe","~:request-tap-history","~:obj-request","~:cljs-build-failure","~:obj-forget-all","~:js-eval","~:shadow.cljs.devtools.client.shared/runtime-print-disconnect","~:runtime-print-sub","~:cljs-runtime-init","~:cljs-build-configure","~:access-denied"]],"~:to",3] 539 ["^ ","~:op","~:tap-subscribe","~:summary",true,"~:history",true,"~:from",3] ["^ ","~:op","~:tap-subscribed","~:history",[],"~:to",3]
:ping and the client is supposed to respond with a :pong
https://github.com/thheller/shadow-cljs/blob/5a32abb215c81c26268967ed4439303bb348e5d0/src/main/shadow/cljs/ui/worker/relay_ws.cljs#L90
but in these messages the client is never sending the :pong, nor do I see any error messages in the logs2.10.12resources folder?shadow-cljs -A:dev watch app,
nor the webpage itself show any indication that a rebuild happens. The JS file
is not in resources (other than the compiled output).
I wasn’t quite sure what was meant in the guide (https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js)
by:
> The files must not be physically located in the same directory. The lookup for the file appears on the classpath instead. This is unlike node which expects relative requires to always resolve to physical files.
So I tried all the permutations I could think of and none of them would trigger
shadow-cljs watch to rebuild. Updating any CLJS file did as normal.
Here is what I tried:
1. With the JS file in the same source tree (but not directory) as the cljs file requiring the JS file:
deps.edn :path ["src"]
(ns visx.dashboard.antmedia (:require ["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))or
(ns visx.dashboard.antmedia (:require ["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))with the file layout:
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
|__ webrtc_adapter.js
2. Or when the JS file is a different directory tree under src:
(ns visx.dashboard.antmedia (:require ["/js/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
└── dashboard
└── antmedia
|__ webrtc-adapter.js
3. Or when the JS is in a different tree but matching class path with updated :path:
deps.edn: :path ["src/js" "src/cljs"]
(ns visx.dashboard.antmedia (:require ["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))or
(ns visx.dashboard.antmedia (:require ["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
[__ cljs
└── visx
└── dashboard
└── antmedia.cljs
|__ antmedia
└── js
|__ visx
└── dashboard
└── antmedia
|__ webrtc-adapter.jsshadow-cljs watch <your-build> --verbosetouch src/whever/the/file/is.jsclj works as expected). I did an npm install in my project and ran clj once so all dependencies are present. Then I tried to run npx shadow-cljs, but only get the error that the system can't find the path. What could that be?npx shadow-cljs watch app suddenly doesn't recompile or reload my code when I save my soruces. I'm not sure what have changed. it might have been cosmic radiation.
On the other hand, changes to shadow-cljs.edn are being watched correctly.
Any idea how to debug this?npx shadow-cljs works fine outside of the project directory.------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var my.ns/f1
(ns my.ns) always just declares that ns. you need to (require 'my.ns) (in-ns 'my.ns) if you want to load and switch? that has always been that way though.(ns my.ns) always just declares that ns. you need to (require 'my.ns) (in-ns 'my.ns) if you want to load and switch? that has always been that way though.// project/lib.js (ns project.lib) (defn f1 [])So this ns has a
f1 var. But if I eval the ns form again, and try to catch f1 , it would throw the error I pasted above.shadow-cljs node-repl or browser-repl and post everyh single step you do to get to the error// project/lib.js (ns project.lib) (defn f1 []) (comment (f1) )1. I open the project, and cider-jack-in 2. I can call
(f1) in the comment form, which returns nil
3. I put the emacs cursor in the end of the ns form, and cider-eval that form (e.g. I often do that to add new imports to current ns)
4. now if i try to call (f1) again, it throws that errorshadow-cljs node-repl or shadow-cljs browser-repl. no editor or other configuration. otherwise I will not investigate this further.$ yarn shadow-cljs node-repl cljs.user=> (ns foo.bar) nil foo.bar=> (defn f1 [] (println "foo.bar/f1 called!")) #'foo.bar/f1 foo.bar=> (f1) foo.bar/f1 called! nil foo.bar=> (ns foo.bar) nil foo.bar=> (f1) ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var foo.bar/f1 -------------------------------------------------------------------------------- foo.bar=> (require 'foo.bar) nil foo.bar=> (f1) ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var foo.bar/f1 --------------------------------------------------------------------------------
npx shadow-cljs again, and it installed and ran. I suspect it is a problem that I had shadow-cljs in my package.json file?)(function(exports) {
"use strict";
console.log("loading map");
function initMap() {
exports.map = new google.maps.Map(document.getElementById("map"), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 8
});
}
exports.initMap = initMap;
})((this.window = this.window || {}));
export function initMap() {
exports.map = new google.maps.Map(document.getElementById("map"), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 8
});
}
["./google_maps.js" :refer (initMap)]
exports.map =returnThe required JS dependency "./google_maps.js" is not available, it was required by
(def load-map (with-meta identity
{:component-did-mount
initMap}))
[load-map [:div {:id "map"}]]
gives:
initMap is not a functioninitMap function(when something (nil 10))It should point to the second line, right? But it is pointing to the first one...
------ ERROR ------------------------------------------------------------------- File: /home/mauricio/.atom/packages/chlorine/repl-tooling/src/repl_tooling/repl_client/shadow_ws.cljs:195:1 -------------------------------------------------------------------------------- 192 | 193 | 194 | 195 | (when-not true -------^------------------------------------------------------------------------ Error in phase :compilation Can't call nil at line 196 repl_tooling/repl_client/shadow_ws.cljs -------------------------------------------------------------------------------- 196 | (nil 10)) 197 | 198 | ; (lol/bar 10) 199 | ; (-> msg :build-status :report println) --------------------------------------------------------------------------------
(when something ::wrong-ns/keyword)
function my_function(...) {...} for CLJS functions marked with ^:export (or somehow marked in any other way)?
Specifically this kind of construct is needed. var my_function = ... and _function = ... will not work.:node-test target?:export
(defn foobar
{:export "someName"}
[]
(js/console.log "called me!"))someName in the global scope, but, it still compiles foobar to function c() {} (i.e; the function definition, which apps script needs, is not the original name of the function).var onOpen = function() { ... }; would be invalid in apps-script?(js* "function onOpen() { your.ns.actual_on_open() };") but don't tell anyone I said that(defn on-open {:export "onOpen"} [] ...)?:node-test and async go blocks. they work exactly as they do in all other targets:modules has nothing to do with how you organize your project. it only splits the output into several files but still requires compiling everything together.:modules is about the produced output. so thats what you do to get "dynamically loaded modules" from.js files together on one page then that is not supported{:deps-aliases [:cider]} in my .shadow-cljs/config.edn file and I now get the error nREPL middleware: shadow.cljs.devtools.cli has no namespace error Command failed with exit code 2. when running shadow-cljs watch myapp, any idea how to resolve this?:dependencies style works:node-test target? I can't figure out how to connect to the right repl. It's erroring with no js runtime available.shadow-cljs node-repl if you want a generic node replcljs.user> prompt, but typing anything in it prints No available JS runtime. I selected my app using the :node-script targetclj runtime, no cljs runtimesnode-repl and then I get a functioning cljs.user> repl.(do (require "foo" :as foo) (defn something [] (foo/bar))) won't workjs/module$node_modules$strrequire is only available at dev time; it won’t work when you do a release build even if it’s static AFAIKresolve resolves the symbol to when you do (:require ["library" :as foo]) - turns out it's a string concat of node_modules + other stuffinit-fn?init-fn: my-project.core/init inside my build def and it failed saying it couldn’t find the namespace, but when i renamed everything to just myproject it worked just finemy_project but the ns can use my-projectshadow.test.node/main(nodejs/enable-util-print!) (enable-console-print!)though
(ts/instrument) is a side-effecting macro which needs to be called AFTER everything has been compiled(st/instrument) call in maincljs_eval function is really nice! how do you do the lookup between a var in the form and which function to call / value etc?watch worker process on the server.(defmacro invoke-unary
[client method req auth]
`(p/create
(fn [resolve# reject#]
(let [result# (~method ~client
~req
(cljs.core/clj->js {"authorization" ~auth})
(fn [err# resp#]
(if err#
(reject# err#)
(resolve# (datafy (.getMessage ^js resp#))))))]
(.on result# "status" (fn [status#]
(let [s# (datafy ^js status#)]
(when-not (zero? (:code s#))
(reject# s#)))))))))core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {"code" 16, "details" "invalid auth token", "metadata" #js {:cache-control "private, no-cache", :connection "keep-alive", :content-length "0", :content-type "application/grpc-web-text+proto", :date "Wed, 24 Jun 2020 12:09:43 GMT", :grpc-message "invalid auth token", :grpc-status "16", :server "istio-envoy", :x-envoy-upstream-service-time "1"}}TypeError: Z.og is undefined
.on being renamedmethod stuff? how do you use invoke-unary?^js result# might be enough(defn get-providers [auth]
(let [req (pb/ProvidersGetRequest.)]
(.setHeader req (utils/make-header))
(invoke-unary (connect) .getProviders req auth))).getProviders also needs a hint^js .getProviders might not workshadow-cljs release app --pseudo-names. that will give a better idea of what Z.og isdiff --git a/src/cljs/mcp_admin_ui/grpc/macros.clj b/src/cljs/mcp_admin_ui/grpc/macros.clj
index 344cc97..0f6d050 100644
--- a/src/cljs/mcp_admin_ui/grpc/macros.clj
+++ b/src/cljs/mcp_admin_ui/grpc/macros.clj
@@ -6,14 +6,14 @@
[client method req auth]
`(p/create
(fn [resolve# reject#]
- (let [result# (~method ~client
- ~req
- (cljs.core/clj->js {"authorization" ~auth})
- (fn [err# resp#]
- (if err#
- (reject# err#)
- (resolve# (datafy (.getMessage resp#))))))]
- (.on result# "status" (fn [status#]
- (let [s# (datafy status#)]
- (when-not (zero? (:code s#))
- (reject# s#)))))))))
+ (let [result# (^js ~method ^js ~client
+ ~req
+ (cljs.core/clj->js {"authorization" ~auth})
+ (fn [err# resp#]
+ (if err#
+ (reject# err#)
+ (resolve# (datafy (.getMessage ^js resp#))))))]
+ (.on ^js result# "status" (fn [status#]
+ (let [s# (datafy ^js status#)]
+ (when-not (zero? (:code s#))
+ (reject# s#)))))))))^js ~method that won't do anything~method becomes (unquote method) so you have ^js (unquote method) which is not the place you need it in~(vary-meta method assoc :tag 'js) might work--pseudo-names first to actually figure out where the issue islein shadow release app --pseudo-names but nothing is jumping out at me to see if it did anythinglein shadow supports that argTypeError: Z.og is undefined this should be different. if its not then the arg was passed properly:shadow-cljs {:nrepl {:port 8777}
:dev-http {8280 {:root "resources/public"
:proxy-url ""}}
:builds {:app {:target :browser
:compiler-options {:infer-externs :auto}
:output-dir "resources/public/admin/js/compiled"
:asset-path "/admin/js/compiled"
:modules {:app {:init-fn mcp-admin-ui.core/init}}}
:rel {:target :browser
:compiler-options {:infer-externs :auto
:optimizations :advanced}
:output-dir "resources/public/admin/js/compiled"
:asset-path "/admin/js/compiled"
:modules {:app {:init-fn mcp-admin-ui.core/init}}}}}watch rel still results in a bunch of independent js, so I think im not quite doing what i expectedshadow-cljs server and leaving that running. then shadow-cljs release app is quicker. no clue about your docker setup or lein shadow though. I do not recommend lein shadow because it makes all of this harder.watch does not run optimizations at all ever so setting it does nothing. :rel is identical to :app basically as the default is :optimizations :advanced anywaysshadow-cljs server was the magic I neededUncaught TypeError: Cannot read property '$datafy$' of undefined
at Array.<anonymous> (app.js:33921)
at zb (app.js:2042)
at Ma.<anonymous> (app.js:2041)
at xa (app.js:2026)
at ra (app.js:2026)
at vb (app.js:2034)
at Ma.O (app.js:2062)
at Ma.K (app.js:2062)File: /Users/ghaskins/sandbox/git/mcp-admin-ui/src/cljs/mcp_admin_ui/grpc/account_service.cljs:14:5 -------------------------------------------------------------------------------- 11 | (defn get-providers [auth] 12 | (let [req (pb/ProvidersGetRequest.)] 13 | (.setHeader req (utils/make-header)) 14 | (invoke-unary (connect) .getProviders req auth))) -----------^-------------------------------------------------------------------- Use of undeclared Var clojure.datafy/datafy
status: {code: 16, details: "invalid auth token", metadata: {…}}
app.js:33922 Uncaught TypeError: Cannot read property '$datafy$' of undefined
at Array.<anonymous> (app.js:33922)
at zb (app.js:2042)
at Ma.<anonymous> (app.js:2041)
at xa (app.js:2026)
at ra (app.js:2026)
at vb (app.js:2034)
at Ma.O (app.js:2062)
at Ma.K (app.js:2062)(.on ^js result# "status" (fn [status#]
(js/console.log "status:" status#)
(let [s# (datafy status#)]
(when-not (zero? (:code s#))
(reject# s#))))).datafy somewhere? using datafy otherwise does not create a datafy property since its a protocol?(.on ^js result# "status" (fn [status#]
(let [s# (cljs.core/js->clj status# :keywordize-keys true)]
(when-not (zero? (:code s#))
(reject# s#)))))(:require [clojure.datafy :as d]) and (d/datafy)clojure.datafy vs cljs.datafy problem?clojure.datafy/datafy at compile time$datafy$ actually is.$datafy$ and figure out what that is 😛shadow-cljs release app --debug gives you pseudo-names + source maps which makes that easierclojure and datafy as externs?clojure.datafy in CLJS code?core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: [object Object]
[object Object]fetch-providers is but I assure you datafy works just fine in :advancedcore.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {:code 16, :details "invalid auth token", :metadata {:date "Wed, 24 Jun 2020 16:58:04 GMT", :server "istio-envoy", :grpc-status "16", :x-envoy-upstream-service-time "2", :cache-control "private, no-cache", :content-length "0", :grpc-message "invalid auth token", :content-type "application/grpc-web-text+proto", :connection "keep-alive"}}npm install --save jimp , and using :require ["jimp" :as jimp] . Not sure what to do, my Google searches have been dead ends.jimp asks for var Jimp *=* require('jimp'); and my import seems correct according to the user guide:
(:require ["jimp" :as jimp])
node_modules/jimp/browser/lib/jimp.js looks likenode_modules/jimp/browser/lib/jimp.js is big. I really don't know what I'm looking for here. Here's the file if you're curious.exports["default"] = void 0 for some reason["jimp/es/index.js" :as jimp]["jimp/es/index.js" :as jimp] worked! It compiles now.browser build is something specific to webpackget-classpath-entries and index-classpath from shadow.build.classpath . Furthermore I am using shadow.build.api to configure the build with the various api/with-* and seem to successfully compile-sources. But I don't see the output appear in the :output-dir I wonder what I'm missing for that to work.:target option has its own way of doing that:browser build and you just dynamically add a few :entries for your plugins?(shadow.cljs.devtools.api/compile* {:build-id :foo :target :browser :modules {:main {:entries [foo.bar-plugin] :init-fn {})(shadow.cljs.devtools.server/start!) needs to be running before that though:foo from a shadow-cljs.edn in project root right?(api/get-build-config :foo) and then update-in or whatever and pass that to compile*npm install conflicts and so on:modules to split everything:optimizations is also terribleshadow-cljs watch. my stuff doesn't 🙂{:classes {:allow :all 'js goog/global}} maybe[.. & args] for the calls to not error.(apply inc [1 2 3])shadow.cljs.bootstrap.browser/init for bootstrapped environments. Please ping me here or on GitHub if you need any further info or help as we have quite comprehensive tests. Thanks 🙂d: Highcharts.SVGRenderer.prototype.symbols.arc(g, m, this.center[2] / 2, 0, {
Typing Highcharts in the browser console also leads to a "ReferenceError: Highcharts is not defined". It would appear Highcharts is expecting the Highcharts object to be globally defined but it is likely not due to the advanced build. Any idea what the correct solution to this would be?(set! (.-Highcharts js/window) highcharts) which may fix the issue but that doesn't seem like the right solution."highcharts": "8.1.2" in package.json and in a :require like this ["highcharts" :as highcharts].Failed to inspect file /Users/tonykay/fulcrologic/ucv/node_modules/react-calendar/dist/Calendar.csswhich is coming from this statement in the
react-date-picker library require("react-calendar/dist/Calendar.css");:js-options {:ignore-asset-requires true} to get the old behavior back.css requiresrequire("./some.css") that actually is supposed to load a some.css.js file ... fun times ...:macros and ClojureScript includes them under both :defs and :macros. I don’t know if this is an intentional choice by Shadow CLJS, and I expect I can adapt, but thought I should letcha know. Here’s a repro of what I found: https://github.com/lread/repro-shadow-cljs-analyzer-macro-diffdefmacro in CLJS files. that is all.:defs and does not touch :macros and import-vars on macros works. I’ll experiment.cider-eval-defun-at-point after changing some code? My understanding is that shadow-cljs is just watching for changes to the saved file, and evaluating code in the CIDER REPL isn't so useful.cider-evalwhich default bindings
C-x C-every userful. I have complex fulcro components, which are react-components. With cider eval I can evaluate any part of bigger structures. Like in
(let [a (my-fun (+ c b))] do-stuff)I can put the cursor between the two closing parens of b)) and check whether (+ a b) is what I think it is. Or behind be to check just whether a is what I think it is. If c or b is not defined because they are arguments of the function I can have a comment in the file which binds values for debugging like so:
(comment (def a 4) )This is invaluable for me when chasing bugs. Of course I often just insert (str a) into the ui to do a sort of println debugging, too, but the ui often stops rendering when react gets bad data.
shadow-cljs server, shadow-cljs watch app, etc.MBP:rolo-client janell$ npx shadow-cljs release frontend --debug ------------------------------------------------------------------------------ shadow-cljs - config: /Users/ja/nos.lv/rolo/rolo-client/shadow-cljs.edn [:frontend] Compiling ... Warning: Nashorn engine is planned to be removed from a future JDK release ------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared ------------------------------------
:autoshadow.build.targets target namespace I'm using, currently it just sits in my codebase along with my app. Is there a way I can pull it out of the source tree, but still have it found on the classpath when shadow runs?react-markdown in reagent via shadow-cljs, but I get this error when I require it:
[:app] Build failure: The required JS dependency "path" is not available, it was required by "node_modules/vfile/core.js".
path is a node.js thing ...path-browserify polyfill, but I got a different error, which lead me to this :path-browserify and process is enough to resolve those issues.npm install -D shadow-cljs in your project:compiler-options will output a source map file.
:source-map true :source-map-include-sources-content true :source-map-detail-level :allAfter adding those keys, however, if I visit my production built app, I receive this warning in the console: "DevTools failed to load SourceMap: Could not parse content for http://localhost:3002/js/main.js.map: Unexpected token < in JSON at position 0". It's clearly trying to load sources maps and getting HTML back, thus the error. My question is if there is a way to output source maps and not have the console attempt to load the source maps. I'm guessing when those above keys are set, the outputted JS has some sort of indicator to tell the browser to attempt to load source maps. In a production build without the above keys set, I do not get the warning message printed in the console.
//# sourceMappingURL=main.js.mapAs the last line in the outputted JS. Is there a way to output source maps without this line included in the final JS?
sed -i '/sourceMappingURL/d' out/public/js/main.js . Seems like there should be a way to tell shadow to output source maps without the line in the released JS file though.:browser-test as the target), but when I run shadow-cljs watch test no http server is started. Is my config messed up?
{:target :browser-test
:test-dir "public/js/test"
:devtools {:http-port 8021
:http-root "public/js/test"
:http-handler shadow.http.push-state/handle
}}:compiler-options {:source-map-comment false} but I'm not sure its supported for all targets.:browser target.:dev-http. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-httpAmplifyAuthenticator component using ["@aws-amplify/ui-react" :refer (AmplifyAuthenticator)], I see the following in the shadow-cljs server console during the first build (which does go on to complete successfully):
[2020-06-27 12:53:18.268 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-b93ab635.js", :requires [{:line 1615, :column 73}]}
If I try to render an AmplifyAuthenticator component in my application I see the following in the console:
Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.If it helps: I think the new Amplify framework wraps Web Components and my suspicion is that I'm either doing something wrong in the way that I'm importing or compiling that's causing a polyfill to go missing, or doing something wrong in the way that I'm creating or passing children to the new version of the component. There are examples online using a prior version of the framework with CLJS and I was able to put together a minimal reproduction where the legacy
Authenticator component from aws-amplify-react renders and swapping it for AmplifyAuthenticator from @aws-amplify/ui-react fails.
https://github.com/casselc/amplify-reproducer
https://github.com/casselc/amplify-reproducer/compare/works-legacy-aws-amplify-react
Would appreciate any pointers in the right direction, thanks!:compiler-options {:output-feature-set :es6}:es6 it still doesn't render, but does give this error instead:
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
at eval (index-b93ab635.js:1334)
at Generator.next (<anonymous>)
at b (app.js:34)
bumping up to :es8 for generators gives:
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
at initializeComponent (index-b93ab635.js:1334)
Is this something where I need an extern? I've tried messing around with the various :infer-externs options without success.:es7 or :es8?:es7 gives the same as :es6, :es8 and :es-next both give
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
at initializeComponent (index-b93ab635.js:1334)
no other errors in the browser, and only the js-invalid-requires message in the shadow-cljs server output.:js-options {:resolve {"@aws-amplify/ui-react" { ... }} need to look like to pull in individual components? Not sure I understand what's going on well enough to translate the react globals example in the user guide.{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7d0e151c19120a501e11170e3d4f534c4d534c4e"}, :content ("[email protected]")} with:
{:deps {:aliases [:cljs]}
:builds {:browser {:target :browser ,,,}}}
and i cant seem to figure out why this is happening:
$ shadow-cljs watch browser
...
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
...
Caused by:
NoSuchFieldError ES3
is this looking familiar to anyone? i imagine i need to update piggieback or something like that, but i havent been able to crack it...com.google.javascript/closure-compiler-unshaded version to the same version in the shadow-cljs/deps.edn file eliminates that issue, but fails the build with:
[:browser] Build failure: RuntimeException: No such resource: js/es6/util/createtemplatetagfirstarg.js
org.clojure/clojurescript entry in the deps.edn (i.e. not setting the clojurescript version explicitly) fixed the rest of the issues. apologies for the noise. will leave in case others stumble:pseudo-names true in your compiler options for your buildshadow-cljs release app --debug:export you only need for things you are calling by name from the HTML or so. not required for anything else and never fixes any other naming issues.release app --debug and seeshadow-cljs release app --debug uses advanced optimizations. it sets :pretty-print and :pseudo-names to true to help you diagnose problems like theseshadow-cljs does not require lein but it is required in this case since I’m using lein to build the shadow-cljs project.
However i don't see lein being invoked.------ ERROR -------------------------------------------------------------------
File: /home/kenny/compute/monorepo/projects/ui/src/compute/ui/analytics/cloud_acct/view.cljs:44:12
--------------------------------------------------------------------------------
41 | (defn CloudAccountsTable
42 | [{:keys [:integration/type]}]
43 | [table/Table
44 | #::table{:table-class "is-fullwidth"
------------------^-------------------------------------------------------------
No namespace: compute.ui.components.table found
--------------------------------------------------------------------------------
The compute.ui.components.table namespace is required in the view file references in the above error. The error seems to magically disappear and reappear with no clear way to reproduce it. Previously Thomas thought this was due to a dependency conflict with the reader. Looking at the output from clj -Stree, I can see org.clojure/tools.reader 1.3.2 is coming directly from thheller/shadow-cljs 2.10.13. Has anyone else been hitting this? Workarounds? I have not been able to come up with something that will consistently fix the issue.#::table )The only solution I can think of is to not use that anymore. I would think shadow would be compatible with it though.table then race condition shouldn't really happen since that ensures the ns is compiled beforethe-ns but shadow-cljs also never uses thattools.namespace in CLJ?npx.npx shadow-cljs watch app devcards
compute.ui.components.table is a .cljs file not .cljc and no .clj counterpart.compute.ui.components.table namespace preventing it from being parsed?shadow-cljs and something like ring to provide shadow-cljs reload?hiccup to generate the html5?shadow-cljs communicate with browser to do hot-reload?app.js is that time both communicate?lein figwheel that does all the stuffs for ushelix and graphql in separated projects because I didn´t know how to join bothrequire something like CodeMirror is? When I'm using random JS packages, I'm often a bit confused by the require/import statement.(:require ["codemirror" :as cm])(:require ["CodeMirror" :as cm]) then cm itself seems to be a function?(cm. #js {:opts ...})cm/fromTextArea(.fromTextArea cm ...) is also ok:as just sets up an alias but in case of JS requires it may also be used as an object:as foo using foo directly where each def would be a property of that foo:default (I think?) ...cljsjs, and they require the clojure mode for CodeMirror like:
cljsjs.codemirror.mode.clojure
["CodeMirror/mode/clojure/clojure.js"](def dev-handler (-> #'routes wrap-reload push-state/handle)) - this is the dev-handler generated from the re-frame template - I got a prn to work upon the load of the handler namespaceproject.cljc and shadow's complaining that a clojure-only keyword doesn't exist even though it's only referenced inside a #?(:clj ...) reader conditional. the offending code:
(ns glam.models.project
(:require #?(:clj [glam.neo4j.project :as prj])
#?(:clj [glam.neo4j.core :refer [one rename-id]])
#?(:clj [com.wsscode.pathom.connect :as pc])))
#?(:clj
(pc/defresolver all-projects [{:keys [neo4j current-user]} _]
{::pc/output [:project/id]}
(prj/get-document-ids neo4j)))
the error:
X Compilation failed.
------ ERROR -------------------------------------------------------------------
File: [...]/glam/models/project.cljc:8:18
--------------------------------------------------------------------------------
5 |
6 | #?(:clj
7 | (pc/defresolver all-projects [{:keys [neo4j current-user]} _]
8 | {::pc/output [:project/id]}
------------------------^-------------------------------------------------------
glam/models/project.cljc [line 8, col 18] Invalid keyword: ::pc/output.
--------------------------------------------------------------------------------
9 | (prj/get-document-ids neo4j)))
10 |
11 | #?(:clj
12 | (pc/defresolver get-project [{:keys [neo4j]} {:project/keys [id]}]
--------------------------------------------------------------------------------:com.wsscode.pathom.connect/output the error of course goes away, but it'd be nice to avoid thatshadow-cljs.edn?pc alias needs to exist in CLJS as well. otherwise the code isn't readable. consider it a quirk in clojure and tools.reader since both have this issue. not something shadow-cljs can do anything about.:builds but no overall schemashadow-cljs.edn what’s the difference between
:dev-http {8000 "resources/public"}
and
:devtools {:http-root "resources/public"
:http-port 8000}
?:dev-http. use :dev-http. the :devtools http stuff is deprecated:repl-verbose true in devtools in my shadow-cljs config file, but that didn't seem to do anything. Does anyone know if this is possible in combination with shadow-cljs?devtools , probably in the first level of the edn, but I haven’t test it before
:repl-options {:repl-verbose true}
test_fixes.cljs and then a namespace name test_fixestest-fixesrequire at runtime?:advanced. :advanced is whole-program optimization so it removes everything that isn't used. as soon as one of your plugins would use something that was removed previously everything breaks.cljs.core is also not a great idea since they won't be compatible with each other. so can't pass a {:foo "bar"} map from one plugin to main or other plugin and expect that to workreact-color, but importing it from one of my namespaces gives me an error, which seems to be from:
failed to load module$node_modules$react_color$lib$components$common$index
Uncaught TypeError: Cannot redefine property: Alpha
Object.defineProperty(exports, 'Alpha', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Alpha).default;
}
});:target :bootstrap?shadow-cljs compile app works fine, but shadow-cljs release app seems not to export my init funciton.:init-fn in your build config^:export:modules {:main {:entries [someapp.core]}}
and
(defn ^:export init [] ...
init function is in someapp.coresomapp.core.init in JS?var shadow$provide = {};
(function(){
...
Aa("someapp.core.init",function(){var a=new U(null,1,5,W,[zD],null);
...
}).call(this);someapp.core.init with function(){var a...:init-fn instead? or when do you actually use it?index.hml : <body><script>someapp.core.init();</script></body>:init-fn like in the docs but doesn’t work either.main.js for it to exist somewhere?<html lang="en">
<head>
<meta charset='utf-8'>
<!-- ... -->
<script src="/js/compiled/main.js"></script>
</head>
<body>
<div id="app"></div>
<script>someapp.core.init();</script>
</body>
</html>
Can't find variable: someapp … but now I see that there is an error way before and that might cause the that the init-method will not be defined, right?Error: No protocol method Router.match-by-name defined for type null: shadow-cljs release app --debug will make that a bit easier(println "*** " (reitit.frontend.easy/href ::somethin)) on toplevel … bummer.(require '[ajax.core :refer [GET]]) => nil (GET "") => #object[ReferenceError ReferenceError: Can't find variable: ajax]
:target? anything in the console? etc?:dev
{:target :react-native
:init-fn client.core/init
:output-dir "app"
:compiler-options {:closure-defines
{"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:after-load steroid.rn.core/reload
:build-notify steroid.rn.core/build-notify
:preloads [re-frisk-remote.preload]}}(ns foo (:require ["react" :as react]))is now
(ns foo (:require [react :as react])) ??Because i'am getting this error in my repl (emacs/cider): << could not find string alias for "react" from foo >> and when i change to the no string version it works fine. But how now i require something like ["@material-ui/core" :as mui] ??? i cant have a no string version because of the the @ operator! I asking here in shadow-cljs channel because i think it start to happens after i upgraded shadow-cljs from npm to the last version 2.10.13.
npm install shadow-cljs into your project and use a package.json rather than having the project.clj manage dependencies. importing node modules into frontend code seems smoother than it was under lein + figwheel. i am a big fan of figwheel, but i have not used figwheel for a few months and things might have changed. shadow-cljs.edn is far more concise for the most common use-cases than project.clj.import "preact/debug"; would normally activate the debugging tools .
Using it as such did in fact add the debugging tools to window as the developer extensions expected but it seems it something is off because it could not hook into the rendering process.
(ns
(:require ["preact/debug"]
["preact" :as preact]))
2. Preact offers a React compatibility layer. Do you think it would be possible to "trick" shadow.markup.react into working with Preact?shadow.markup.react but yes you can trick everything into using preact by just rewriting the react requires https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npmpreact/debug to :preloads ["preact/debug"] so its only included in dev builds:modules / code-splitting and useful things for release builds like [build-reports](https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report):bundle then you'll install that regardlesscljs.user=> (ns site.core)
[2020-07-03 13:59:18.978 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(ns site.core)", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (ns site.core), :source "(ns site.core)", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:519)
shadow.cljs.repl/process-read-result (repl.clj:493)
shadow.cljs.repl/process-input (repl.clj:673)
shadow.cljs.repl/process-input (repl.clj:657)
shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
java.lang.Thread.run (Thread.java:748)
Caused by:
ExceptionInfo could not find string alias for "react" from site.core {:require-from-id site.core, :require "react"}
shadow.build.data/get-string-alias (data.clj:139)
shadow.build.data/get-string-alias (data.clj:135)
shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
clojure.core/fn--8437 (core.clj:6845)
clojure.core/fn--8437 (core.clj:6830)
clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
clojure.core/reduce-kv (core.clj:6856)
clojure.core/reduce-kv (core.clj:6847)
shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
shadow.cljs.repl/repl-ns (repl.clj:340)
------ REPL Error while processing ---------------------------------------------
(ns site.core)
could not find string alias for "react" from site.core
{:require-from-id site.core, :require "react"}
ExceptionInfo: could not find string alias for "react" from site.core
shadow.build.data/get-string-alias (data.clj:139)
shadow.build.data/get-string-alias (data.clj:135)
shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
clojure.core/fn--8437 (core.clj:6845)
clojure.core/fn--8437 (core.clj:6830)
clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
clojure.core/reduce-kv (core.clj:6856)
clojure.core/reduce-kv (core.clj:6847)
shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
shadow.cljs.repl/repl-ns (repl.clj:340)
shadow.cljs.repl/repl-ns (repl.clj:328)
shadow.cljs.repl/process-read-result (repl.clj:513)
shadow.cljs.repl/process-read-result (repl.clj:493)
shadow.cljs.repl/process-input (repl.clj:673)
shadow.cljs.repl/process-input (repl.clj:657)
shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
java.lang.Thread.run (Thread.java:748)
It compiles fine, the problem is in repl:sources is ignored when :deps is truthy)! ❤️shadow-cljs release app --verbose and seeing libs like Cache read: shadow/remote/runtime/cljs/env.cljs in the outputshadow.remote.runtime.cljs.browser in one of our devtools that was also being includeddev_1 | internal/modules/cjs/loader.js:1032
dev_1 | throw err;
dev_1 | ^
dev_1 |
dev_1 | Error: Cannot find module '/app/app/app.js'
dev_1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
dev_1 | at Function.Module._load (internal/modules/cjs/loader.js:898:27)
dev_1 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
dev_1 | at internal/main/run_main_module.js:17:47 {
dev_1 | code: 'MODULE_NOT_FOUND',
dev_1 | requireStack: []
dev_1 | }
Maybe you have any ideas what goes wrong?
thanks!
UPD: found the issue - related to docker setup#object[TypeError TypeError: Cannot read property 'call' of undefined], is there any special thing that needs to be done to call macros on node repl?:require and :require-macros, but same result(:require [com.wsscode.async.async-cljs :as wasync :refer [go go-promise <!p]])2.10.6 it works fine, I'm going to bisect the between version to find when it stopped[:ddregister] Configuring build.
[:ddregister] Compiling ...
[2020-07-06 11:38:17.464 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (.exists file)
shadow.build.cache/read-cache (cache.clj:33)
shadow.build.cache/read-cache (cache.clj:33)
shadow.build.closure/convert-sources-simple/fn--52392/fn--52394 (closure.clj:2097)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6827)
clojure.core/reduce (core.clj:6810)
shadow.build.closure/convert-sources-simple/fn--52392 (closure.clj:2089)
shadow.build.closure/convert-sources-simple (closure.clj:2087)
shadow.build.closure/convert-sources-simple (closure.clj:2009)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1164)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1157)
shadow.build.compiler/compile-all (compiler.clj:1409)shadow/node-repl from the server REPLimages under the root of my project. my output-dir for the target is app but can’t figure out how to reference the images if my app is running from the app:devcards true for dev. move that "up". also don't set :optimizations :none is never has any effect anywhere is already the forced default for dev:npm-module which is used by a larger webpack'ed application. AFAIK the only thing that's changed since last week is that I updated a bunch of packages on my machine (Debian Testing), mostly libraries. I tried downgrading Chromium, to no avail.shadow-cljs watch app give you?watch and in the browser console?[:npm] Compiling ... [:npm] Build completed. (321 files, 2 compiled, 0 warnings, 0.44s)In the browser, I get nothing from shadow. Just webpack doing its normal:
[HMR] bundle rebuilding ... Ignored an update to declined module ../path/to/my/yarn/linked/cljs/module.js
watch warns about: Nashorn engine, a too-new react version, and an illegal reflective access by mranderson048; but none of those are new:npm-module build?watch seems like a recipe for disasterbuild/targets/npm_module.clj:
(cond->
...
(and (= :dev mode) (:worker-info state))
(update config :devtools merge {:autoload false ;; doesn't work yet, use built-in for now
:use-document-host false}))
Before this was changed (in 2.8.56), autoload was mis-spelled, so didn't actually get disabled: https://github.com/thheller/shadow-cljs/commit/c75fa3376efdbc8405e5f978db1db5f748861c55
However, when autoload is not false'd here, hot reloading works in my environment, so I'm not sure what the comment is referring to as not working?:devtools {:autoload true} then?npm_module.clj renaming :autoload to :autoload* in the aforementioned code, hot reloading works without any setting in the edn file.master. will probably make a release later.server pid exists but server appears to be dead, proceeding without server, and then my build hangs when compiling. Is there an easy way to just reset everything and force a clean build?.shadow-cljs/builds. does it actually hang completely? does it max out cpu?.shadow-cljs/server.pid but that doesn't mean anythingshadow-cljs compile app --verbose might help~/d/c/lambda (licence-panel)> shadow-cljs compile local --verbose shadow-cljs - server pid exists but server appears to be dead, proceeding without server. shadow-cljs - config: /Users/colin/dev/cursive-site/lambda/shadow-cljs.edn cli version: 2.8.77 node: v12.1.0 [:local] Compiling ... -> build target: :node-script stage: :configure <- build target: :node-script stage: :configure (5 ms) -> Resolving Module: :main <- Resolving Module: :main (43 ms) -> build target: :node-script stage: :compile-prepare <- build target: :node-script stage: :compile-prepare (0 ms) -> Closure JS Cache read: 63 JS files <- Closure JS Cache read: 63 JS files (87 ms) -> Cache read: cljs/core.cljs <- Cache read: cljs/core.cljs (73 ms) -> Cache read: clojure/string.cljs -> Cache read: cljs/tools/reader/impl/inspect.cljs -> Cache read: applied_science/js_interop/impl.cljs <- Cache read: cljs/tools/reader/impl/inspect.cljs (34 ms) <- Cache read: applied_science/js_interop/impl.cljs (178 ms) <- Cache read: clojure/string.cljs (178 ms) -> Cache read: cljs/tools/reader/impl/utils.cljs -> Cache read: applied_science/js_interop.cljs <- Cache read: cljs/tools/reader/impl/utils.cljs (6 ms) -> Cache read: cljs/nodejs.cljs <- Cache read: applied_science/js_interop.cljs (9 ms) -> Cache read: lambda/credentials.cljs <- Cache read: cljs/nodejs.cljs (5 ms) -> Cache read: promesa/protocols.cljc -> Cache read: cljs/tools/reader/reader_types.cljs <- Cache read: lambda/credentials.cljs (6 ms) -> Cache read: promesa/util.cljc <- Cache read: promesa/protocols.cljc (7 ms) <- Cache read: cljs/tools/reader/reader_types.cljs (8 ms) <- Cache read: promesa/util.cljc (6 ms) -> Cache read: cljs/tools/reader/impl/errors.cljs -> Cache read: promesa/exec.cljc <- Cache read: promesa/exec.cljc (6 ms) -> Cache read: cljs_bean/from/cljs/core.cljs <- Cache read: cljs/tools/reader/impl/errors.cljs (8 ms) -> Cache read: promesa/impl.cljc -> Cache read: cljs/tools/reader/impl/commons.cljs <- Cache read: cljs_bean/from/cljs/core.cljs (6 ms) -> Cache read: cljs_bean/core.cljs <- Cache read: promesa/impl.cljc (6 ms) -> Cache read: lambda/licence.cljs <- Cache read: cljs/tools/reader/impl/commons.cljs (6 ms) -> Cache read: clojure/set.cljs -> Cache read: promesa/core.cljc <- Cache read: cljs_bean/core.cljs (7 ms) -> Cache read: lambda/dynamo/util.cljs <- Cache read: lambda/licence.cljs (6 ms) -> Cache read: clojure/walk.cljs -> Cache read: cljs/tools/reader.cljs <- Cache read: clojure/set.cljs (6 ms) <- Cache read: lambda/dynamo/util.cljs (7 ms) <- Cache read: promesa/core.cljc (459 ms) -> Cache read: lambda/util.cljs <- Cache read: cljs/tools/reader.cljs (466 ms) <- Cache read: clojure/walk.cljs (467 ms) <- Cache read: lambda/util.cljs (7 ms) -> Cache read: cljs/tools/reader/edn.cljs -> Cache read: lambda/dynamo/expr.cljs -> Cache read: lambda/dynamo/response.cljs -> Cache read: lambda/pricing.cljs <- Cache read: cljs/tools/reader/edn.cljs (10 ms) <- Cache read: lambda/dynamo/expr.cljs (9 ms) -> Cache read: cljs_time/internal/core.cljs <- Cache read: lambda/pricing.cljs (8 ms) <- Cache read: lambda/dynamo/response.cljs (10 ms) -> Cache read: cljs/reader.cljs -> Cache read: lambda/dynamo/request.cljs <- Cache read: cljs_time/internal/core.cljs (7 ms) -> Cache read: cljs_time/core.cljs <- Cache read: cljs_time/core.cljs (15 ms) <- Cache read: lambda/dynamo/request.cljs (21 ms) <- Cache read: cljs/reader.cljs (23 ms) -> Cache read: lambda/kms.cljs -> Cache read: lambda/email.cljs -> Cache read: lambda/dynamo.cljs -> Cache read: cljs_time/format.cljs <- Cache read: lambda/kms.cljs (7 ms) -> Cache read: clojure/edn.cljs <- Cache read: lambda/email.cljs (10 ms) <- Cache read: lambda/dynamo.cljs (10 ms) -> Cache read: hiccups/runtime.cljs -> Cache read: lambda/buy.cljs <- Cache read: clojure/edn.cljs (10 ms) <- Cache read: hiccups/runtime.cljs (8 ms) <- Cache read: cljs_time/format.cljs (15 ms) -> Cache read: lambda/webhook.cljs -> Cache read: lambda/renew.cljs -> Cache read: lambda/quote_email.cljs <- Cache read: lambda/buy.cljs (11 ms) -> Cache read: lambda/tables.cljs -> Compile CLJS: lambda/email_content.cljs -> Cache read: cljs_time/coerce.cljs <- Cache read: lambda/tables.cljs (13 ms) <- Cache read: lambda/renew.cljs (183 ms) <- Cache read: cljs_time/coerce.cljs (181 ms) <- Cache read: lambda/webhook.cljs (185 ms) <- Cache read: lambda/quote_email.cljs (184 ms) -> Cache read: lambda/quote.cljs <- Cache read: lambda/quote.cljs (13 ms)
quote.cljs hasn’t changed, I’d suspect email_content.cljs the most, but that seems to have compiled ok.-> Compile CLJS: lambda/email_content.cljs means it started doing something<- means it finisheddepstar results in a jar that's 34mb. Heh.pack.pack-alpha for that;; jar creation from juxt
:pack {:extra-deps {pack/pack.alpha {:git/url ""
:sha "d9023b24c3d589ba6ebc66c5a25c0826ed28ead5"}}
:main-opts ["-m" "mach.pack.alpha.skinny" "--no-libs" "--project-path" "api-cljs.jar"]}
:git/url and not use a jar at all.--no-libs do?pack is wrong for shadow-cljs.pack or anything deps.edn packaging related for that matter. I just use lein since it is by far the easiest and straightforward.jar -tvf your.jar whats in it.jar and look in it ... what does shadow-cljs expect to see, for just a normal cljs library? What directory layout?foo.bar.baz/file.cljs and if unpack the jar, I see directories foo/bar/baz/file.cljs ...foo.bar.baz/file.cljs is not valid so please don't add confusing examples.The required namespace "jett.hyperbase.client" is not available, it was required by "jett/hypercell/actions.cljs".
jett/hyberbase/clients.cljs in the jarjar -tvf. I don't care about the unpacked result.0 Wed Jul 08 18:49:46 CEST 2020 jett/hyperbase/
0 Wed Jul 08 18:49:46 CEST 2020 jett/
11489 Fri Jun 26 00:13:24 CEST 2020 jett/hyperbase/core.clj
484 Mon May 04 11:56:40 CEST 2020 jett/hyperbase/transit.clj
378 Mon May 18 19:47:00 CEST 2020 dev.clj
5419 Fri Jun 05 11:57:08 CEST 2020 jett/hyperbase/order_util.cljc
6375 Tue Jun 02 09:44:34 CEST 2020 jett/hyperbase/id_util.cljc
0 Wed Jul 08 18:49:46 CEST 2020 jett/gavel/
1612 Fri May 08 13:05:20 CEST 2020 jett/gavel/core.cljs
5526 Thu Jun 11 13:06:34 CEST 2020 jett/gavel/message_center.cljs
10888 Mon Jun 08 19:26:02 CEST 2020 jett/hyperbase/sample_application.cljs
549 Mon Apr 20 10:26:56 CEST 2020 jett/hyperbase/diff.cljs
403 Mon Jun 08 19:25:30 CEST 2020 jett/hyperbase/util.cljs
21608 Mon Jul 06 15:47:08 CEST 2020 jett/hyperbase/itom.cljs
16470 Fri Jun 26 14:36:42 CEST 2020 jett/hyperbase/client.cljs
979 Wed Jun 17 12:20:18 CEST 2020 jett/hyperbase/ui.cljs
5338 Tue Jun 09 13:00:06 CEST 2020 jett/hyperbase/core.cljs
576 Wed May 13 12:14:12 CEST 2020 jett/hyperbase/user.cljs
0 Wed Jul 08 18:49:46 CEST 2020 web/
240 Tue Apr 07 17:34:08 CEST 2020 web/index.html
0 Wed Jul 08 18:49:46 CEST 2020 web/css/
7313 Mon May 18 12:06:08 CEST 2020 web/css/site.cssdev.clj and web/ files probably shouldn't be in there but otherwise the file seems to be present?web and dev things aren't useful but I couldn't figure out how they would be harmful.shadow-cljs clj-repl and ( "jett/hyperbase/client.cljs")(slurp *1) and see if there are some funky chars in the beginning.jar -tvf works that the jar seems to be validpack, but maybe there's another argument I'm supposed to use. And to be clear, I don't care about pack. I just am trying to figure out the right way to package a cljs library using deps. We used to do this with lein trivially all the time and deploy to an internal maven server. I just can't quite figure out how to build an artifact with deps that works along with shadow-cljs.{:local/root "/path/to/your.jar"}? Your setup sounds the same as mine so I'm also really wondering what's going wrong 🙂pack.alpha doesn't have any manifest information.shadow-cljs server isn’t an option right? I see it mentioned in docs, just checking in case there’s possible workarounds.shadow-cljs server -A:foo and have the builds I start up inherit those options
> Aliases are only applied when a new instance/server is started. They do not apply when connecting to a running server using the `shadow-cljs` command.shadow-cljs server -A:foo is fine{:optimizations :simple}. that is pretty much the reason its so large.ADVANCED_OPTIMIZATIONS will map to {:optimizations :advanced} ?:release {:compiler-options {:optimizations :simple}}}:builds
{:converter {:target :node-script
:output-to "converter.js"
:main converter/run
}
}
I'd like to be able to do something like node converter.js group user (which would only convert groups and users)?(defn run [group user] ...) already gets the argumentssudo npm install mastodon-bot -g and run with mastodon-bot -hcljs lib into a js bundle for the browser?cljs app?^:export will make everything defined and callable. you can have as many of those in your lib as you want.Uncaught ReferenceError: $jscomp is not defined - however, i see https://github.com/thheller/shadow-cljs/commit/04e636404e976761fb1eac675db55e5d12518246 as well. going to do a fresh node_modules. anything else we should try?
update: clean node_modules didn't help.:target? if you are using headless-chrome and only need to target that you can set :compiler-options {:output-feature-set :es8} which gets rid of most polyfills (which $jscomp is for):bundle to get the npm package access. the code stays the same.deps.edn.["@material-ui/icons" :refer (ArrowForward)]
The console says it’s processing 6557 files instead of 1013 once I add that import line.
The solution seems to be described here but not sure how to do that in CLJS:
https://github.com/mui-org/material-ui/issues/12422#issue-347896444["@material-ui/icons/ArrowForward" :default ArrowForward]["@material-ui/icons/ArrowForward" :as ArrowForward :default defaultExport] and it was giving me an error.Stale Client! You are not using the latest compilation output
Is there a quick way of cleaning up everythin so shadow-cljs can recomplile everything from scratch?
Thank you?:output-dir and didn't adjust the paths you used to include the .js files?:modules {:foo ..} name but don't load the new foo.js file?:dev-http servers handle caching correctly so that doesn't happen but any other server may not do thatshadow-cljs watch app where app is the name of my app (original i know) then i get an exception aboud piggieback which i can't fathom.
➜ Cabotage git:(labtest-results-should-get-its-own-page) ✗ yarn watch
yarn run v1.22.4
$ shadow-cljs watch app;
shadow-cljs - config: /home/drewv/work/breezeehr/master-at-arms/Cabotage/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Downloading: binaryage/devtools/1.0.2/devtools-1.0.2.pom from
Downloading: binaryage/devtools/1.0.2/devtools-1.0.2.jar from
[2020-07-15 16:22:48.972 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
clojure.lang.Compiler.macroexpand (Compiler.java:7075)
clojure.lang.Compiler.eval (Compiler.java:7161)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:459)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
Caused by:
NoSuchFieldError ES3
cljs.closure__init.load (:133)
cljs.closure__init.<clinit> (:-1)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:348)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.10.14 running at
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[2020-07-15 16:23:17.405 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:348)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
=============================================================================
WARNING: The configured :dependencies in shadow-cljs.edn were ignored!
When using :deps they must be configured in deps.edn
==============================================================================(seq (:dependencies config)) so you definitely have something in :dependencies configured?node-repl, and getting lots of crashes using core.async. I'm finding the entire REPL (both with cider-jack-in-cljs and shadow-cljs server) crashes anytime I make an error inside of a go block. This is frustrating, because I have to restart the entire shadow-cljs server every time. Is anyone else experiencing this?(defn <!
^
Error: <! used not in (go ...) block
at Object.cljs$core$async$_LT__BANG_ [as _LT__BANG_] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:92:1)
at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/app/main.cljs:47:11
at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:4736:15
at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:4736:29
at Object.sval (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:3438:7)
at Object.cljs$core$ISeqable$_seq$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:3429:1)
at Object.cljs$core$seq [as seq] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:1234:7)
at Function.cljs$core$IFn$_invoke$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:9953:1)
at Function.cljs$core$IFn$_invoke$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:9966:1)
at switch__30781__auto__ (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/app/main.cljs:45:3)(+ 2 2) at the REPL, I get another error (below), and I'm forced to shut down the entire server.ERROR: Unhandled REPL handler exception processing message {:nrepl.middleware.print/buffer-size 4096, :ns app.main, :file *cider-repl Desktop/loserCLI:localhost:65433(clj)*, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :op eval, :column 11, :line 35, :id 34, :code (+ 2 2), :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/options {:right-margin 80}, :session 9e5bd5b2-32da-428c-b4ef-3ec6637ed31a}
java.lang.AssertionError: Assert failed: (some? worker)
at shadow.cljs.devtools.server.repl_impl$do_repl.invokeStatic(repl_impl.clj:19)
at shadow.cljs.devtools.server.repl_impl$do_repl.invoke(repl_impl.clj:19)
at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invokeStatic(nrepl_impl.clj:143)
at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invoke(nrepl_impl.clj:131)
at shadow.cljs.devtools.server.nrepl_impl$handle.invokeStatic(nrepl_impl.clj:216)
at shadow.cljs.devtools.server.nrepl_impl$handle.invoke(nrepl_impl.clj:210)
at shadow.cljs.devtools.server.nrepl$middleware$fn__7184.invoke(nrepl.clj:40)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at cider.nrepl$wrap_out$fn__7479.invoke(nrepl.clj:312)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at cider.nrepl.middleware.inspect$eval_reply.invokeStatic(inspect.clj:64)
at cider.nrepl.middleware.inspect$eval_reply.invoke(inspect.clj:62)
at cider.nrepl.middleware.inspect$handle_inspect.invokeStatic(inspect.clj:95)
at cider.nrepl.middleware.inspect$handle_inspect.invoke(inspect.clj:93)
at clojure.lang.Var.invoke(Var.java:388)
at cider.nrepl$wrap_inspect$fn__7455.invoke(nrepl.clj:215)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at nrepl.middleware.caught$wrap_caught$fn__6589.invoke(caught.clj:97)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at nrepl.middleware.print$wrap_print$fn__6325.invoke(print.clj:234)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at cider.nrepl$wrap_slurp$fn__7387.invoke(nrepl.clj:110)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at cider.nrepl$wrap_undef$fn__7551.invoke(nrepl.clj:471)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at cider.nrepl.middleware.track_state$handle_tracker.invokeStatic(track_state.clj:240)
at cider.nrepl.middleware.track_state$handle_tracker.invoke(track_state.clj:238)
at clojure.lang.Var.invoke(Var.java:388)
at cider.nrepl$wrap_tracker$fn__7543.invoke(nrepl.clj:460)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at nrepl.middleware.session$session$fn__6931.invoke(session.clj:297)
at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
at shadow.cljs.devtools.server.nrepl$start$fn__7215.invoke(nrepl.clj:138)
at nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
at nrepl.server$handle_STAR_.invoke(server.clj:16)
at nrepl.server$handle$fn__7009.invoke(server.clj:36)
at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)<! is indeed in a go block in my code, so I'm not sure why the first error is even happening... but I can't really debug it if it shuts down my REPL every time.)shadow-cljs server?server.node-repl if the node process crashes. state will be gone though. test 2.10.15<! used not in (go...) block error. I get a message that says The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone, followed by shadow-cljs - #11 ready!, which is great. Evaluation works right away. (+ 2 2) yields the expected result, and cider-eval-last-sexp is also working in the buffer.def and defn expressions. I'm in a namespace called app.main, evaluating either kind of statement returns #object[ReferenceError ReferenceError: app is not defined]. This happens both with cider-eval-last-sexp in the buffer and with def and defn statements used in the REPL.doom upgrade a moment to update all my Emacs packages, and I see that some REPL behaviour has changed. Now with the exact same steps (1. eval buffer 2. eval go block with <! problem), I'm no longer getting any error message at all in the REPL. No stack trace is printed; the only output is The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.<! used not in (go...) block even when I could see the whole stack trace... Now I'm totally helpless 😛#object[ReferenceError ReferenceError: app is not defined] is still problem.shadow-cljs more "self-documenting" to give clues to beginners like myself. I think having a good mental model of everything that's going on would help someone like me get more out of your User Guide.shadow-cljs watch app s i get a warning about shadow cljs devtools not being able to locate refactor nrepl:
[2020-07-17 09:22:55.580 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym refactor-nrepl.middleware/wrap-refactor}
FileNotFoundException Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
clojure.lang.RT.load (RT.java:462)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
clojure.core/load-lib/fn--6780 (core.clj:5948)
clojure.core/load-lib (core.clj:5947)
clojure.core/load-lib (core.clj:5928)
clojure.core/apply (core.clj:667)
clojure.core/load-libs (core.clj:5985)
I'm not sure what to do. Should i be including refactor nrepl middlware? I can make a minimal project if that would help debug this. Many thanks on any hints..nrepl.edn in your project and somewhere elsereact-jss in your library?react-jss directly and don't use your stuff your library already uses.:foreign-libs to "provide" react-jss(:require ["react-jss" :as x]) works regardless of using CLJSJS or shadow-cljs or bundlejs/ https://github.com/FieryCod/cljs-react-jss/blob/master/src/main/css_cljs/core.cljs#L19react-jss require and alias instead of the global js/ aliasjs/ globals anymore because the compiler does that automatically when using cljsjs["react-jss" :as react-jss] and compatibility will be preserved.17 | (let [x @loadable] 18 | (when-some [modules (.-modules loadable)] -----------------------------------------------^-------------------------------- Cannot infer target type in expression (. loadable -modules)Will there be more then that?
:compiler-options {:infer-externs true} turns them off:infer-externs :auto by default:configure stage and adds the preload like this:
(update-in build-state [:devtools :preloads] conj 'my.preload.namespace)Is it possible to do this?
:shadow.build.modules/configsvg-cards which is basically a big bag of PNGs and SVGs, but my shadow-cljs build isn’t serving them (I get 404). Is there some kind of way to make this work (other than manually copying from npm package to resources folder)?node_modules. it just deals with JS.node_modules/... into public before which worked fine. if you have a build step it has to take this into account.[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.8.0-alpha3 -d cider/piggieback:0.5.0 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.3-SNAPSHOT server -A:dev
I start release: npx shadow-cljs release -A:ui proddeps.edn aliases to switch dependencies. that cannot be done with a running server and does require a restart....
:app {:target :browser
:dev {:compiler-options
{:external-config {:guardrails {:throw? false}}
:closure-defines {goog.DEBUG true}}}
...-Dguardrails...npx shadow-cljs --force-spawn release -A:ui prod also works but I'd strongly recommend building a setup that doesn't require switching deps.edn aliaseslein which calls them profiles.:backend alias and maybe a :backend-prod or so and then one alias for :cljs which just configures the guardrails via build config without jvm property:enable-guardrails-clj alias that just sets the jvm property. so you can do clj -A:backend and clj -A:backend:enable-guardrails-cljshadow-electron-starter/node_modules/electron-serve/index.js:12
const getPath = async path_ => {
^^^^^
SyntaxError: Unexpected identifier[:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.17s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.21s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.24s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.28s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.19s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.19s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.27s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.18s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.21s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.18s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.17s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.16s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s) [:app] Compiling ... [:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.23s) [:app] Compiling ...
shadow-cljs.edn look like?:output-dir on the classpath. you can try 2.10.16 which should fix this.:source-pathsshadow-cljs.edn? can't find it in the docsshadow-cljs --cli-info says that I have [com.taoensso/sente "1.11.0"] as a direct dependency, but I'm not declaring it as suchlein deps :treenpx shadow-cljs run shadow.cljs.build-report your-build shadow-report.html might be what you are looking for. @dj942[:devtools :preloads])release mode so :preloads aren't included@fullcalendar/interaction:
Failed to inspect file
/home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.css
it was required from
/home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.js
Errors encountered while trying to parse file
/home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.css
{:line 4, :column 1, :message "primary expression expected"}
So that common/main.js file is a transitive dependency and is trying to pull in CSS with import './main.css'. I read up on "JavaScript Dialects" and it looks like I would need to use a Babel plugin or somesuch to transform the CSS-in-JS, and then use Shadow to compile the transformed files. But does that basically mean I can't get this to work for a transitive dependency like common/main.js without forking my dependency, to tell it where to find the transformed files?npx shadow-cljs or yarn shadow-cljs?shadow-cljs looks at the main module declared in package.json, rather than module? If so I think his proposed solution would apply to my case as well.main by default:js-options {:ignore-asset-requires true} in your build configshadow-cljs will automatically use the version installed in the project, even if using the global shadow-cljs install. you should always have a version installed in your project. the global install is optional though.:output-dir for release buildsnpm executable wasn’t even in my path anymore…. Huh! Whatever! 🙂(:require ["react-vega" :refer [VegaLite Vega]]
[reagent.core :as r])
(let [spec (clj->js {:width 400
:height 200
:mark "bar"
:encoding {:x {:field "a"
:type "ordinal"}
:y {:field "b"
:type "quantitive"}}
:data {:name "table"}})
data (clj->js {"table" [{"a" "A" "b" 28}
{"a" "B" "b" 20}]})]
[:> VegaLite {:spec spec
:data data}])
"react-vega": "7.4.0", "vega-embed": "6.10.0", "vega": "5.13.0", "vega-lite": "4.13.1"
"data": [{ "name": "table" }] but you have :data {:name "table"}shadow-cljs to the latest and started to have this error when compiling:
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
import * as THREE from 'three';
:target is this in? which version did you upgrade to? did you make sure to upgrade all dependencies properly in case you are using project.clj or deps.edn?- "shadow-cljs": "^2.8.106" + "shadow-cljs": "^2.10.17"
:target :browser
:release {:compiler-options {:optimizations :advanced
:output-feature-set :es8
:source-map true
:pseudo-names true
:cross-chunk-method-motion false}}shadow-cljs.edn for :dependencies:pseudo-names true though. thats for debugging and will make your build huge.Closure compilation failed with 1 errors --- client/components/simulation/trackball.js:1 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
shadow-cljs.edncider-jack-in:lein or :deps in shadow-cljs.edn as some true-ish valueimport and export and no other goog.* stuff?shadow-cljs.edn and no :lein or :deps keys:dependencies [ [cljs-drag-n-drop "0.1.0"] [cljs-http "0.1.46"] [com.stuartsierra/component "0.3.2"] [venantius/accountant "0.2.3"] [com.cemerick/url "0.1.1"] [com.taoensso/timbre "4.8.0"] [bidi "2.1.6"]
.shadow-cljs/builds dir. could be that the cache is confused about something.import * as THREE from 'three';
goog.* stuff in the file?.shadow-cljs2.8.1062.10.17 tooimport * as THREE from 'three';
let TrackballControls = function ( object, domElement ) {
....
};
TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
TrackballControls.prototype.constructor = THREE.TrackballControls;
export { TrackballControls };(:require ["./trackball.js" :as tb])
(tb/TrackballControls. camera element)Error in phase :compilation error.
The macro I'm trying to use : https://github.com/escherize/tracks
It's written in CLJC so it should work in clojurescript right ?
I added the dependency to my shadow-cljs.edn
:dependencies [[tracks "1.0.6"]]And in the file I'm trying to use it
(ns dummy (:require [tracks.core :refer-macros (deftrack)]))
(deftrack calculate-price-for-order
{:a {:c price}
:b {:d quantity}}
(* price quantity))
I also read the post from @thheller (https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html) but I'm not sure if this applies to macros from libraries. Following the post, I tried to define a tracks.core namespace in a CLJS file and refer itself, but it doesn't change the error.
Any ideas ?Error in phase :compilation and if I wait 15 sec, I get this
Exception in thread "async-dispatch-7" java.net.SocketException: Socket closed
at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:150)
at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
at nrepl.transport$bencode$fn__5881.invoke(transport.clj:109)
at nrepl.transport.FnTransport.send(transport.clj:28)
at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159)
...
and the shadow-cljs process dies...alter-meta! doesn't do anything useful in CLJS:closure-defines like https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines but nothing seems to change, is there something I’m doing wrong?
; shadow-cljs.ed
...
:builds {:dev
{:target :react-native
:closure-defines {client.home/foo "bar"}
; client/home.cljs
(def foo "Hayea!")
...
[rn/text {:style ui/header-style} foo]
...(goog-define foo "default"). a regular def does nothing with regards to closure-defines.:target is for. there could be a :target :goja. from the looks of it the output of :node-script release builds might just work?enhanced-cljs-completion?, pretty sure I can just switch that off for now and it'll continue to work. Thank you so much for the insight.#object[Error Error: No protocol method ReadPort.take! defined for type null: ] . Then, I did a (tap> *e) in the REPL so that I could take a look at the :stack key on the object using the (amazing) shadow-cljs Inspect tool.Error: No protocol method ReadPort.take! defined for type null:
at Object.cljs$core$missing_protocol [as missing_protocol] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:318:3)
at cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_37176 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async/impl/protocols.cljs:13:1)
at Object.cljs$core$async$impl$protocols$take_BANG_ [as take_BANG_] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async/impl/protocols.cljs:13:1)
at Function.cljs$core$IFn$_invoke$arity$3 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
at Function.cljs$core$IFn$_invoke$arity$2 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
at cljs$core$async$take_BANG_ (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
at cljsEval (<eval>:1:36)
at global.SHADOW_NODE_EVAL ([stdin]:105:10)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:11:1)
at Object.shadow$cljs$devtools$client$shared$IHostSpecific$do_invoke$arity$2 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:100:5).cljs files on any of these lines, so I'm not sure where to start looking for the error. To be clear, I'm happy to debug the actual error on my own, I'd just love a tip for getting started.(<! something) where something is nilNo protocol method ReadPort.take! defined for type null <! is calling that protocol. the trace is basically just going from the helper fn through the entire implementation ending up at the protocol<! is also called take! basicallygo block are rewritten pretty heavily so the stack traces often don't quite make sensecore.async and go blocks. That helps me understand better, thank you once again.main function, which calls a few other functions, and I just wasn't really sure where to start looking for the error.(comment ...) blocksapp.main cljs file that contained the <! or the go block that I messed up on.[:app] Build failure: The required namespace "react" is not available, it was required by "mranderson047/reagent/v0v8v0_alpha2/reagent/core.cljs".
npm install react react-dom create-react-class react-flip-move react-highlight.jsfirst. But it might be nice if the examples "just worked", although I understand that might be more difficult.
manifest.edn completely?:compiler-options {:output-feature-set :es7} or maybe :es6 or :es8. depends on what the lib uses and what karma supports$jscomp issues. if not maybe try upgrading..gitignore.:output-dir should be gitignored 😛git push to deploy.project is the source and project/build is a separate repo containing the artifact). yes, it's the same strategy as github pages and some other static page providers.:advanced builds? didn't try in a while but it was bad?npm install --save path already and the path library is available in node_modules. Any help appreciated.path package you need to have shadow-cljs installed in your project. that provides the required polyfills.node-gyp stuff is for building native packages so very likely it won't work in the browserException in thread "XNIO-1 I/O-1" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x70 at [Source:
(tap> app-state) and the UI 🙂(tap> (pr-str app-state)) in the REPL(js/console.log (pr-str (:dashboard app-state))) or so[:strong {} "And maybe not this. And maybe not this. "
[:span {} " And maybe not this. " [:strong
{} "And maybe not this. And maybe not this. "]]]:js-options {:resolve {"sodium-native" false}} that will make it ignore that packagecljsjs/moment is also a problem in itself so that may be your issue. shadow-cljs does not support CLJSJS.(:require ["moment" :as mom]) and then (mom/whatever ...) should be fine. dont use cljsjs.moment and js/moment:devtools key on my build, but it doesn't seem to be taking effect when I restart the server. I'm expecting the REPL to start in the namespace app.main, according to my shadow-cljs.edn config below, but it still starts in cljs.user. repl-pprint doesn't seem to be having any effect either.
{:source-paths
["src"]
:dependencies
[[fullcontact/full.async "1.1.0"]]
:builds
{:main
{:target :node-script
:main app.main/main
:output-to "public/main.js"
:devtools {:repl-init-ns app.main
:repl-pprint true}}}}["namespace" :as something] appears to replace whatever requirejs is loading
Any hints/things to look into would be appreciatedshadow-cljs.edn :
{:source-paths
["src/cljs"
"src/js"]
...
From src/cljs/.../core.cljs , I want to render a react component exported from a js file
(ns core
(:require ["react" :as react]
["react-dom" :as react-dom]
["/Component.js" :default Example]))
(.log js/console Example)
(defn init! []
(react-dom/render (Example) (js/document.querySelector "#root")))
(defn reload! []
(init!))
src/js/Component.js :
import React from "react";
export default function Example() {
return React.createElement(
"div",
...src/cljs and src/js. just put the .js file in the same directory as your CLJS fileTypeError: Cannot read property 'createElement' of undefined
React is not loaded properly somehow.import * as React from "react"--pseudo-names or --debug?shadow.cljs.devtools.client.env.js in the dev compiled outputted esm module? As it uses shadow.cljs.devtools.client.env.module_loaded. I'm always getting the error
Uncaught TypeError: Cannot read property 'module_loaded' of undefined
at shared.js:91shared.js file. It's fixed when I include the lines
import "./cljs-runtime/shadow.cljs.devtools.client.env.js";
SHADOW_ENV.setLoaded("shadow.cljs.devtools.client.env.js");watch I presume?compilewatch--debug or --pseudo-names?--debug output build(rum/defc user-chat-input < rum/reactive []
#?(:cljs (let [csrf-token (.getAttribute (. js/document (getElementById "aft")) "data-aft")
input-atom (rum/react user-msg-input-atom)]
[:div.userinputwrap
[:div.userinputrapp
[:form#in {:on-submit (fn [e] (.preventDefault e)
(.log js/console "send message via sente net event")
(chsk-send! [:clientsent/chat-msg {:input input-atom :location (js/decodeURI (. (. js/window -location) -pathname))}])
(reset! user-msg-input-atom "")
)}
[:input {:placeholder "submit chat here, be kind"
:auto-focus true
:value (rum/react user-msg-input-atom)
:on-change (fn [e] (do (println (-> e .-target .-value))
(reset! user-msg-input-atom (-> e .-target .-value))))}]]
[:script {:src (str "main.js?v" 6)}]]]))
#?(:clj
[:div.userinputwrap
[:div.userinputrapp
[:form#in
[:input {:placeholder "submit chat here, be kind" :autofocus true}]]
[:script {:src (str "main.js?v" 6)}]]]))
at a glance can you catch anything egregious ?[:script {:src (str "main.js?v" 6)}]?[:script ...] for the cljs pathshadow-cljs release app --debug?react-dom code (which is already minified so its not affected by --debug)hydrate which I have never used so no clue what you are doing(let [in-data (cljs.reader/read-string (.getAttribute (. js/document (getElementById "pcp")) "data-mggs"))
in-answers (cljs.reader/read-string (.getAttribute (. js/document (getElementById "pcp")) "data-inanswers"))
page-type (.getAttribute (. js/document (getElementById "pcp")) "page-type")]
(println page-type in-data in-answers)
(reset! indata in-data) ;set storange atoms
(reset! inansw in-answers)
(if (= "question" page-type) (do (rum/hydrate (question-page @indata @inansw) (.getElementById js/document "rhqp"))
(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))))
(if (= "room" page-type) (do (rum/hydrate (chat-page in-data) (.getElementById js/document "rhcp"))
(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))
(scroll-to-bottom)))
(if (= "allqp" page-type) (do (rum/hydrate (all-question-page @indata)
(.getElementById js/document "rhaq")) ))
(if (= "setts" page-type)
(let [in-dn (.getAttribute (. js/document (getElementById "ecce")) "data-displayname")]
(reset! displayname in-dn)
(.log js/console in-dn)
(rum/hydrate (rolo-settings @displayname)
(.getElementById js/document "rhsp"))
;(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))
))):advanced since they are all renamed#?(:cljs
(defn- textarea-keydown [callback]
(fn [e]
(if (and (== (.-keyCode e) 13) ;; enter
(not (.-shiftKey e))) ;; no shift
(do
(callback (.. e -target -value))
(set! (.. e -target -value) "")
(.preventDefault e))))))
to submit on a :textarea which it would appear solves my problem i think...bitstamp.js:631, it opens a new tab in Firefox and I get an alert that the line can't be found. I try typing in a line that I know exists and it still can't be found. In fact, the tab opens to view-source: but it's an empty page. No code lines. Nothing.
Not sure what the expected behavior is because I've never known my environment to work any other way. But this feels wrong. It's a fairly barebones project.
{:dev-http {8008 ["classpath:public"]}
:nrepl {:port 9999
:middleware []}
:deps true
:builds
{:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "js/main"
:modules {:main {:entries [com.owoga.bitstamp]
:init-fn com.owoga.bitstamp/init}}
:devtools {:repl-init-ns cljs.user
:console-support false
:after-load com.owoga.bitstamp/refresh
:repl-pprint true}}}}➜ my-project tail resources/public/js/main/cljs-runtime/com.owoga.bitstamp.js
com.owoga.bitstamp.refresh = (function com$owoga$bitstamp$refresh(){
taoensso.timbre._log_BANG_.cljs$core$IFn$_invoke$arity$10(taoensso.timbre._STAR_config_STAR_,new cljs.core.Keyword(null,"info","info",-317069002),"com.owoga.bitstamp",null,330,new cljs.core.Keyword(null,"p","p",151049309),new cljs.core.Keyword(null,"auto","auto",-566279492),(new cljs.core.Delay((function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Re-rendering root."], null);
}),null)),null,1062859293);
return reagent.dom.render.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [com.owoga.bitstamp.order_book], null),document.getElementById("order-book"));
});
goog.exportSymbol('com.owoga.bitstamp.refresh', com.owoga.bitstamp.refresh);
//# sourceMappingURL=com.owoga.bitstamp.js.map:devtools {:loader-mode :script}:asset-path "/js/main". relative paths are problematic sometimes if you use any kind of push-state routing or soloader-mode :script that fixes it. Tried each individually and together. Get success with just loader-mode script.(require '[cljs.build.api :as b])
(b/watch "src"
{:main 'handlers.core
:output-dir "out/"
:output-to "build/js/main.js"
:optimizations :simple
:target :nodejs})watch for release builds. you can run shadow-cljs server and then shadow-cljs release app whenever you want to rebuild. it'll be quick, just need to trigger it manually. or just use an external watcher to trigger that command. I recommend doing it manually since release optimizations can take a long time you usually end up compiling "prematurely" and then having another compile queue up.watch with :simple though? whats wrong with just watch?watch seems to require some dependencies (such as websocket). My idea of using watch with a simple build is that I could have that running and as I make changes I could very quickly deploy the updated code to AWS.["mui-datatables" :default MUIDataTable] (the readme has import MUIDataTable from "mui-datatables";), and my component looks like:
The issue is resolved, removed the code to not fill the whole channel
["mui-datatables" :default MUIDataTable] (the readme has import MUIDataTable from "mui-datatables";), and my component looks like:
The issue is resolved, removed the code to not fill the whole channel
(map js/JSON.parse (string/split-lines x)) takes approximately 10 seconds to run with an 7mb file on my local machine however running the equivalent with Javascript (using js/eval) is less than a second. The reason I think this is a shadow bug and not Cljs is that we’ve recently started to have our functions that do this timeout and it’s lining up with when we switched to shadow. I think it’s specifically the split-lines command that is taking much longer. I am using the latest version of shadow. My next step is going to make a minimal reproducible examples showcasing the differences between shadow, clj, and raw nodejs.
Edit: Looks like it’s not unique to Shadow. I’m seeing the same performance differences w/ a regular Clojure repl. I guess it’s a coincidence that the bugs started showing up around the same time. Sorry about that!cider-jack-in-cljs (per https://shadow-cljs.github.io/docs/UsersGuide.html#cider). I’m never given the option to choose a build, instead apparently it tries to create one, and this fails since I’ve already got a shadow-cljs server running. I’ll note that I’ve also got a .dir-locals.el set up per the cider instructions but this seems to be getting ignored. On the other hand it seems like I can connect to the shadow-cljs server just fine by using cider-connect-cljs instead. It’s obviously not a problem since I’ve got it working, but it’s very much not what is in the reference either for shadow-cljs or cider. I will also note that I’m using lein for dependencies instead of the default--could this be causing this? Anyways, just curious, not a big deal since it seems like I’m up in running now.node_modules? why does that affect you?/src/js along with the .js.map -Files.sourceMappingURL comment?#127 is about so it would be a separate issuesourcesContent. closure will not find the file otherwise.------ WARNING #1 - ----------------------------------------------------------- Resource: Failed to resolve sourcemap at Component.js.map: Component.js.map
:dev-http, what does the SPA have to do with that?{...
:dev-http
{8000
{:root "public"
:handler
:proxy-url ""}}}:proxy-skip (defn should-this-proxy [req] true|false):proxy-skip [#"^/something" #"^/else"]shadow.http.push-state/handle is what we want, then the new config really just needs to be a predicate:handler is called it is passing through https://undertow.io/undertow-docs/undertow-docs-2.1.0/index.html#blocking-handler[:shadow.cljs.devtools.server.dev-http/file-recorder
{:on-request
#object[shadow.cljs.devtools.server.dev_http$start_build_server$file_request_fn__19970 0x6fce3691 "shadow.cljs.dev:builds {:app {:target :npm-module
:output-dir "node_modules/shadow-cljs"}}}
gives me such error:
[:app] Configuring build.
[:app] Build failure:
Invalid configuration
-- Spec failed --------------------
{:target :npm-module,
:output-dir "node_modules/shadow-cljs",
:build-id :app}
should contain key: :entries
| key | spec |
|==========+=================|
| :entries | (coll-of |
| | simple-symbol? |
| | :distinct |
| | true |
| | :min-count |
| | 1 |
| | :kind |
| | vector?) |
-- Relevant specs -------
:shadow.build.targets.npm-module/target:
(clojure.spec.alpha/keys
:req-un
[:shadow.build.targets.shared/output-dir
:shadow.build.targets.npm-module/entries]
:opt-un
[:shadow.build.targets.npm-module/runtime
:shadow.build.targets.shared/devtools])
:shadow.build.config/build+target:
(clojure.spec.alpha/and
:shadow.build.config/build
(clojure.spec.alpha/multi-spec
shadow.build.config/target-spec
:target))
-------------------------
Detected 1 error{:frontend
{:target :browser
:modules {:main {:init-fn }}
}}
does not contain :entries but does not throw the same error.:target :browser has different config that :target :npm-module:target :npm-module you need to specify :entries [at-least-one.of-your.namespaces]:npm-module in the first place?:target :react-native and not :npm-module:shadow.undertow/file in the DSL example from abovecljs.analyzer/*cljs-file* does the trick, but with shadow-cljs I only seem to get the part of the path after the source directory"hello_world/other.cljs" rather than "/Users/.../src/hello_world/other.cljs".jar files?:target :bootstrap feature in Shadow and am running into trouble with macros. The :entries vector of my bootstrap build contains instaparse.core, and the build fails with:
The required namespace "instaparse.macros" is not available, it was required by "instaparse/core$macros.cljc". "instaparse/macros.clj" was found on the classpath. Maybe this library only supports CLJ?Tried patching the problem by copying https://github.com/Engelberg/instaparse/blob/master/src/instaparse/macros.clj into my
src folder, but named macros.cljc (thanks for the ability to quickly add custom implementations of arbitrary namespaces, btw). This solved that particular problem, but another similar error pops up:
The required namespace "" is not available, it was required by "cljs/repl$macros.cljc". "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?I feel like I must be holding this tool wrong, as the same code and namespaces can be used to generate an analyzer cache with my own old solution, which generated a node script with Boot and simply executed it. Any tips where I should look next?
2.10.19 lets you specify :proxy-predicate some.ns/some-fn. should be (defn some-fn [ex config] true|false) where ex is the undertow HttpServerExchange (eg. (.getRequestURI ex) to get request path) and config is the :dev-http config mapDOMException: Failed to construct 'WebSocket': The URL 'ws://:8237/chsk?... Exceptions in my console, when I install a service worker?
Everything works fine as far as I can see. Live reloading is working..slurp with (io/resource the-file) should do itthe-file is a relative path?:dump-core (https://cljs.github.io/api/compiler-options/dump-core) not supported in Shadow CLJS? It’s not listed in https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options as either supported or not, and it seems the option is not forwarded to the compiler. Is this intentional? Can I affect this through my build settings somehow?:target :bootstrap, which doesn’t seem to work (https://clojurians.slack.com/archives/C6N245JGG/p1596225051349100).:target :bootstrap works just fine. just some namespaces seem to cause problems. you don't have to precompile them though either. :dump-core wouldn't do that either.:entries [cljs.core] which would be equiv to :dump-corecider-jack-in-clj&cljs would be great!shadow.cljs.devtools.api/watch-compile! and shadow.cljs.devtools.api/watch-compile-all! to force building a running watch. which however won't reload any config since that should be automatic?slurp with `(io/resource the-file)` should
it seems though that sometimes when this code is run during initial compilation (e.g. when running shadow-cljs watch app), it can't find the file.(slurp (io/resource ana/*cljs-file*))(defmacro run-tests!
[]
(read-string (str "(do " (rewrite/rewrite-without-non-comment-blocks-cljs (slurp (io/resource ana/*cljs-file*))) ")")))):refer-macros is sooo outdated https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.htmlrun-tests! that is run in clj-mode. so it had nothing with cljs-file to do(io/resource *file*) in the clj macro 🙂 rather than just *file*read-string if I quote it, right?`(do ~(read-string ...))
(do ~(read-string ...))`str solutionrefer to macros like that 🙂(gensym) and foo# they may be using different names in each build, which then may get different names in :advanced and so on:modules is why all this exists in the first place 😉$ cat shadow-cljs.edn
��{:source-paths ["src"]
:dependencies [[reagent "0.8.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:init-fn app.main/main!}}}}}src that shadow-cljs has previously used instead of the sources from the library. Now I'm getting:
[2020-08-04 14:47:11.441 - INFO] duplicate resource graphql_builder/generators/shared.cljc on classpath, using file:/Users/harri/.gitlibs/libs/floatingpointio/graphql-builder/7e8311225d5595e4456b8fd6338b127a80b7aab6/src/graphql_builder/generators/shared.cljc over file:/Users/harri/Development/hesburger/core-client/src/graphql_builder/generators/shared.cljcfor each of the overridden files, and they are not patched. This is only affecting 1 machine out of 4 working ones.
src that shadow-cljs has previously used instead of the sources from the library. Now I'm getting:
[2020-08-04 14:47:11.441 - INFO] duplicate resource graphql_builder/generators/shared.cljc on classpath, using file:/Users/harri/.gitlibs/libs/floatingpointio/graphql-builder/7e8311225d5595e4456b8fd6338b127a80b7aab6/src/graphql_builder/generators/shared.cljc over file:/Users/harri/Development/hesburger/core-client/src/graphql_builder/generators/shared.cljcfor each of the overridden files, and they are not patched. This is only affecting 1 machine out of 4 working ones.
clj -Spath returns a proper classpath, but it is in a different ordersrc:test:.... and in the failing machine, they are somewhere in the middledeps.edn then that is solely responsible for constructing the classpath and nothing shadow-cljs does affects thatdissoc build options via the :`config-merge` option? use case: for the release build, we have set up ns-aliases. but for a specific release build, I want to remove one of those ns-aliases:configure stage to bend the configuration of the release build to my will. the hooks really provide a lot of flexibility @thheller, very nice!:target :browser?:compiler-options {:output-feature-set :es6} or whatever language level is appropriate:es8 is good if you have bunch of async/await code in libsproject.clj not minepackage.json version can stay older usually, just need to have it at all.:output-feature-set controls which JS features are transpiled awaydeps.cljs does not contain shadow-cljs if I find that becoming a thing.deps.cljs is not the place to do this for shadow-cljsnpm install shadow-cljs when the notebook CLJ launches or whateverpackage.json)❯ shadow-cljs compile test
shadow-cljs - config: /Users/benny/projects/client/shadow-cljs.edn
shadow-cljs - connected to server
[:test] Compiling ...
========= Running Tests =======================
SHADOW import error /Users/benny/projects/client/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$$react_navigation$native.js
/Users/benny/projects/client/node_modules/react-native/index.js:13
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1047:16)
at Module._compile (internal/modules/cjs/loader.js:1097:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/Users/benny/projects/client/node_modules/@react-navigation/native/lib/commonjs/useBackButton.tsx:2:1)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
===============================================
[:test] Build completed. (164 files, 163 compiled, 0 warnings, 7.45s):target :react-native works for react-native:test
{:target :node-test
:source-paths ["src/client/re-frame" "test"]
:output-to "out/node-tests.js"
:autorun true}shadow-cljs compile test why does it try to compile the react native specific code if i’m not referencing it in my test sources?-testIconContext for react-icons I’ve been able to import the actual icons ok, but I need to import IconContext for changing the Icon’s attributes. I’ve tried:
["react-icons" :default IconContext] ["react-icons" :refer (IconContext)] ["react-icons" :as IconContext] # I know that one shouldn't work but tried anywayAnd I always get:
[:app] Build failure:
package in /Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-iconsspecified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["lib"], :package-dir #object[java.io.File 0x627fddf1 "/Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-icons"]}
ExceptionInfo: package in /Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-iconsspecified entries but they were all missing
Any idea what I’m doing wrong? The Original react-icons doc for the import is at:
https://github.com/react-icons/react-icons#configuration"react-icons/lib/cjs/index.js" for now. the package seems to be bundled rather strangelypinkgorilla.deps would be a completely ok namespace and checking every possible deps.cljs file whether its an actual ns or not is not practical.package.json get filtered out by https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/npm_deps.clj#L222
Or in other words, if all the deps that shadow-cljs is responsible for are already in package.json shadow-cljs does not run any npm install command at all ?
Does that mean that the intended behaviour is that its a user's responsibility to run npm install prior to shadow-cljs manually or via another build tool ?js/URL to be resolved to custom class (like URL from react-native-url-polyfill) ? Or in general, how to change global var like js/window or js/document ?:js-options {:resolve {"react-native-url-polyfill" {:target :global
:global "URL"}}}js/URL resolves to. it literally means use the global URL object, whatever that may be.js/URL if you want to change it?(js/goog.exportSymbol "URL" whatever-it-should-be) in a namespace that is loaded before the one using itRequested module does not have an export "initSchema".import { initSchema } from '@aws-amplify/datastore';["/models/index" :refer [Post]](ns ex
(:require ["@aws-amplify/datastore" :refer [DataStore initSchema] :as foo]
#_["/models/index" :refer [Post]]
[cljs.core.async.interop :refer [<p!]]))
works just fine and initSchema is a fn if I log itimport * as foo from '@aws-amplify/datastore'; everything works and I can use foo but unfortunately this is generated code and would rather not have to update the require after each time I re-generate the file[2020-08-06 07:06:52.100 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 21}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
pretty frequently, and the only solution that I've found is to shut down shadow-cljs and start it again. I haven't figured out the actual circumstances this happens but I'll try to see if I see some similarities. I'm using Vim/Fireplace if that is something that might have to do with this.npm packages are imported in a separate step and converted to commonjs. closure does some strict checking for ESM files but since everything is CJS it only supports imports * as .... a bit annoying but pure ESM doesn't work unless everything is ESM and npm packages rarely are.releaseshadow-cljs - server version: 2.10.19 running at
clara.rules somehow. I'm not sure why, but it seems that whenever I get into a state where it fails to satisfy our constraints we get to an error state where I evaluate a form, and then it prints that error. We've had had issues with clara.rules previously too on CLJS that it might do something funky, might be related to compilation failing or something..cljs.user again and that itself causes an exception causing the cljs,user to not be available anymore?(ns cljs.user (:require some.namespace.that.fails))(throw (js/Error. "Lets fail")) to a NS and then load it => I get that error![2020-08-07 12:45:14.376 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(load-file \"filippos/core/models/data_types.cljs\")", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (load-file "filippos/core/models/data_types.cljs"), :source "(load-file \"filippos/core/models/data_types.cljs\")", :tag :shadow.cljs.repl/process-ex}[2020-08-07 12:45:47.721 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 8, :from 40}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}Require! in fireplace after I planted that throwload-file expects a file-path so src/main/filippos/core/models/data_types.cljs or an absolute path(throw ...) cannot possibly cause an error on the compiler sidenpm packages don'trequire ... :as after I incorrectly use require ... :default, the require ... :as fails and doesn’t do anything. I had to restart the shadow-cljs watch process and reconnect to get it to work.
Is this worth documenting as a gotcha? Spent quite a lot of time debugging, because I thought the CommonJS import was failing as well.:default will create the DayPicker binding. :as is only taken if there is no other binding by that name since its normally reserved as a namespace alias. not really something I can easily fix. Just use :as first and you won't run into this issueorg.clojure/clojure to your deps in lein, looks like you are getting an older versionshadow-cljs release build?
shadow-cljs - failed to loadI'm pulling my hair out here trying to figure out what's going on.
app.js:1994 Uncaught TypeError: $jscomp.inherits is not a function
at app.js:1994
at app.js:1645
at Object.shadow$provide.<computed> (app.js:1645)
at vs (app.js:2831)
at app.js:2211
at Object.shadow$provide.<computed> (app.js:2211)
at vs (app.js:2831)
at app.js:3230
at app.js:32711.6.0-alpha15Makefile in there with build and release tasks which document how I've been doing this.Uncaught TypeError is the real issue, as it's preventing the app from loading and doing The Thing. But it seems to be related to some weird shadow shenanigans that I've been unable to sort out.TypeError: $jscomp.asyncExecutePromiseGeneratorProgram is not a function at La.q.runAsync (app.js:492) at $jscomp.generator.Engine_.program_ (app.js:2153) at $jscomp.generator.Engine_.nextStep_ (app.js:20) at $jscomp.generator.Engine_.next_ (app.js:16) at $jscomp.generator.Generator_.next (app.js:21) at app.js:2125 at new Promise (<anonymous>) at N (app.js:2124) at Pc (app.js:2148) at $jscomp.generator.Engine_.program_ (app.js:2146) at $jscomp.generator.Engine_.nextStep_ (app.js:20) at $jscomp.generator.Engine_.next_ (app.js:16) at $jscomp.generator.Generator_.next (app.js:21) at t (app.js:2124)
:compiler-options {:output-feature-set :es8} to your build config.:compiler-options {:output-feature-set :es8} to your build config.:es8 featureset. Strangely though, when I then comment out that line and recompile it works again! Also, I may be crazy or have missed something, but I had it working yesterday again and then it just stopped. Is there any reason it would be misbehaving intermittently like this? Also very strange that it just magically started breaking with me not having changed very much.TypeError: $jscomp.asyncExecutePromiseGeneratorProgram is not a function to TypeError: $jscomp.inherits is not a function.shadow-cljs watch which I hadn't done in a while. And with the weirdness of turning on/off :es8 targeting fixing things, I wonder if this could have something to do with information Shadow is caching that isn't getting cleared out?npx create-cljs-project my-project
All OK.
cd my-project
npx shadow-cljs
Could not find shadow-cljs.edn config file. To create one run: shadow-cljs initOK... It's definitely in there though. Looks like it can't find it? Using node v12.18.3. The only thing I can run is
npx shadow-cljs help 😅 . Also tried installing globally, no different... Thx2.10.21 which fixes this. run npm install in the project dir to fix it2.10.21 which fixes this. run npm install in the project dir to fix itno dispatch macro for sfor the shadow reader like so
:closure-defines {client.config/api-base-url #shadow/env "API_URL"}API_URL might not be set? you can try #shadow/env ["API_URL" "default-value"]?2.10.18 it doesn’t care. that profile isn’t being used, so i wouldn’t even expect it to be evaluatedclj -m cljs.main -c myproject.core:target is extensible and meant to enable things like this. Its just not documented very well so writing it may be not so straightforward. do you have an example project for this? would be curious to know what the runtime is capable of. I saw Mike tweeting about about it but haven't looked into it myself yet.:target not too long ago. maybe that helps too https://github.com/titonbarua/shadow-cljs-gjs-target:target that.namespace just works:shadow.build/stage changing and you doing stuff depending on the stage:target impl. otherwise its the same.(tap> build-state) to explore what it looks like— when loaded via shadow.resource causes Invalid UTF-8 start byte 0x97 ? Stack Overflow is points to my files not being UTF-8 but I have tried to confirm that they are as best as I can.shadow-cljs release raises a NPE. My CIDER repl hot reloading is also broken. known bug?shadow-cljs release raises a NPE. My CIDER repl hot reloading is also broken. known bug?shadow-cljs server. I think this may have been a race condition from hot reload + release at the same time, but anyway it went away after a restartnode-test is an invalid target:
Target "node-test" for build :test was not found. The built-in targets are: - :browser - :browser-test - :node-script - :node-library - :npm-module - :karma - :bootstrapShould I just be using
node-script?:target :node-test? should exist unless you are on an ancient versionshadow watch for :node-script on a different (docker) host, than node app.js. :devtools-url "" yields remote-error Error: Unexpected server response: 200.
What's the best way to do this?:target node-test. note that it must be a keyword, otherwise it'll look for (ns node-test) which indeed does not exist.:target node-test. note that it must be a keyword, otherwise it'll look for (ns node-test) which indeed does not exist. actually results in the shadow-cljs UI that should be fine? did you verify that the http connect actually works?app.js tries to connect during shadow's boot up (docker volume, for sharing build results). removing app.js (and waiting for it to be re-generated) before connecting node, fixed it. thanks!shadow watch is running? If not, are there any barriers for that feature to be added? I can take a look at it 🙂:integration target, most of the time I get the following error:
File: /home/mauricio/.atom/packages/chlorine/repl-tooling/test/repl_tooling/repl_client/textual_representation_test.cljs:18:3
--------------------------------------------------------------------------------
15 | render/txt-for-result))
16 |
17 | (cards/deftest evaluate-to-text
18 | (async-with-clj-repl "text repr"
---------^----------------------------------------------------------------------
Encountered error when macroexpanding cljs.core/aset.
StackOverflowError:
cljs.analyzer/compiler-options (analyzer.cljc:168)
cljs.analyzer/checked-arrays (analyzer.cljc:178)
cljs.analyzer/checked-arrays (analyzer.cljc:174)
cljs.core/aset (core.cljc:1043)
cljs.core/aset (core.cljc:1041)
clojure.core/apply (core.clj:669)
....big stacktrace(defn root []
(let [this (r/current-component)
open-drawer #(this.refs.drawer.openDrawer)]
....
The reference for this.refs.drawer.openDrawer is lost on advanced optimization.
Some thoughts on how to circunvent this??(defn root []
(let [^js this (r/current-component)
open-drawer #(.. this -refs -drawer -openDrawer)]
The required JS dependency "process" is not available, it was required by "node_modules/auth0-js/dist/auth0.min.js" According to https://github.com/thheller/shadow-cljs/issues/519#issuecomment-508386654 this should be remediated by ensuring shadow-cljs is an app dependency... but it already is in my project (generated with luminus), or so I thought? The line in :dependencies in project.clj is [thheller/shadow-cljs "2.10.17" :scope "provided"]npm install shadow-cljs. that brings in the required process polyfill.Running application "main" with appParams: {"initialProps":{"exp":{"lastErrors":[{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":2},{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":3},{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":3}],"initialUri":"","manifest":{"env":{},"id":"@anonymous/reagent-expo-f0486819-2cb9-4ab2-ae63-272afd37af81","privacy":"public","assetBundlePatterns":["**/*"],"primaryColor":"#023C69","bundleUrl":"","slug":"reagent-expo","name":"hello-world","icon":"./assets/icon.png","xde":true,"loadedFromCache":false,"splash":{"resizeMode":"contain","backgroundColor":"#ffffff","image":"./assets/splash.png","imageUrl":""},"orientation":"portrait","entryPoint":"./app/index.js","iconUrl":"","isVerified":true,"version":"1.0.0","developer":{"tool":"expo-cli","projectRoot":"/home/rick/Repositories/dca3"},"mainModuleName":"app/index","debuggerHost":"192.168.2.36:19001","logUrl":"","packagerOpts":{"https":false,"dev":true,"lanType":"ip","hostType":"lan","minify":false,"urlRandomness":"84-n8h"},"sdkVersion":"35.0.0","platforms":["ios","android","web"],"hostUri":"192.168.2.36:19000","ios":{"supportsTablet":true},"updates":{"fallbackToCacheTimeout":0}},"shell":false}},"rootTag":81}. __DEV__ === true, development-level warning are ON, performance optimizations are OFFshadow-cljs clj-repl and then (shadow/get-server-addr)Failed to connect to localhost/127.0.0.1:9630shadow.user=> (shadow/get-server-addr) "172.19.0.1"
:local-ip "192.168.2.36" in the build config or shadow-cljs watch app -config-merge '{:local-ip "192.168.2.36"}':dev/after-load in the code? the namespace needs to be actually included in the build too? maybe via :preloads if its not part of your usual code?:local-ip "192.168.2.36" worked for me.(shadow/find-local-addrs) from the CLJ repl?shadow.user=> (shadow/find-local-addrs) Syntax error compiling at (REPL:0:0). Unable to resolve symbol: f in this context ([#object[java.net.NetworkInterface 0x7d151d89 "name:br-c8e7b746556e (br-c8e7b746556e)"] #object[java.net.Inet4Address 0x789f27e5 "/172.19.0.1"]] [#object[java.net.NetworkInterface 0x1dea0730 "name:wlp2s0 (wlp2s0)"] #object[java.net.Inet4Address 0x7dfe23c2 "/192.168.2.36"]])
src/cljs/user.cljs, and in shadow-cljs.edn, I have :preloads [cljs.user ,,,]. Using :after-load pointing to cljs.user/start in shadow-cljs.edn doesn’t work, nor does setting ^:dev/after-load meta on the var.preloads, it works.cljs.* files. they are filtered.cljs.user is special and should not be used for this.(:require ["the-npm-package/path/to/whatever.js" :as x]) which would be node_modules/the-npm-package/path/to/whatever.jsshadow-cljs - starting via "clojure" ------ ERROR ------------------------------------------------------------------- File: /<...redacted...>/foo.cljc Error in phase :compilation --------------------------------------------------------------------------------what can I do to narrow it down?
clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.758\"}}}" --main cljs.main --compile bug.core
Caused by: clojure.lang.ExceptionInfo: failed compiling constant: 1/4; clojure.lang.Ratio is not a valid ClojureScript constant. {:constant 1/4, :type clojure.lang.Ratio, :clojure.error/phase :compilation}
weirdly enough, if literal is just ratio 1/4 shadow shows (other) ns errors and warning, but if it is vector with ratio [1/4] - error is blank, as in previous messagethheller/shadow-cljs {:mvn/version "2.8.40"}, most commonly the core.cljs file there. Is this normal, or is there a further layer of "source-mapping" I could be enabling to actually get errors to reference my own source files?core.cljs file.core.cljs file, which makes it very difficult for me to track them down in my own source code (e.g. src/app/core.cljs).views.cljs, which I recognize). I've highlighted that one in the image below.core.cljs instead of cljs/core.cljs or so@foo when foo is nilviews.cljscljs.test/async:build-options {:ns-aliases {devcards-marked cljsjs.marked, devcards-syntax-highlighter cljsjs.highlight}}
specified. The problem is that this :build-options key is not available when setting up a :test build. So any files in devcards which match the -test$ regex will try to compile with this test build, but they will also end up including devcard.core leading to the marked issue.:build-options key is not available ...{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true
:main optional}}}
This is the list of config options according to the docs. It does not list :build-options as a valid config option. I thought maybe it is valid, but unlisted in the docs, so I tried including it in the test config options. This did not solve the issue though as opposed to my :mycards build which works fine.:build-options can be used in any build, the docs just don't mention it. just like :compiler-options and :js-options.renderer application namespaces. For instance, I can access fs fine from main, but not from the application code. I can access npm modules fine from the application as well, such as @material-ui/icons. Most of my code is based off of https://github.com/ahonn/shadow-electron-starter, and I have enabled nodeIntegration.(:require ["electron" :as elec :refer [ipcRenderer]]) to the top of a renderer file, and print elec, it is an empty js object.module$node_modules$electron$index returns an empty object(js/require "fs") . I need to understand the difference between :require and js/require ...js/require is commonJS require('') whereas :require is fancy ES6 import * from "" https://clojureverse.org/t/guide-on-how-to-use-import-npm-modules-packages-in-clojurescript/2298:target :browser for the renderer code. Perhaps shadow-cljs doesn't expect this code to also have node.js access in the case of electron?Exception in thread "XNIO-1 I/O-3" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8 at [Source:
"Křápová"Was something changed recently in using transit in Shadow-cljs? My version is 10.18.
s$ shadow-cljs node-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn shadow-cljs - connected to server cljs.user=> "Křápová" "Křápová" cljs.user=>
:browser by default will try to bundle all js requires which isn't what you want in case of electron. so you can either set :js-options {:js-provider :require} or :js-options {:keep-as-require #{"fs" ...}}:require will make everything go through require (so via nodeIntegration). :keep-as-require lets you select whichever packages but defaults to bundling all othersConnecting to remote nREPL server... Clojure 1.10.1 "Křápová" => "Křápová" (shadow/repl :client) To quit, type: :cljs/quit => [:selected :client] "Křápová"
(shadow/repl :browser) To quit, type: :cljs/quit => [:selected :browser] "Křápová" => "Křápová"
{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[reagent-utils "0.3.3"]
[re-frame "0.12.0"]
[com.cognitect/transit-cljs "0.8.264"]
[day8.re-frame/http-fx "v0.2.0"]
[hickory "0.7.1"]
[binaryage/devtools "0.9.10"]
[bidi "2.1.6"]
[com.taoensso/sente "1.15.0"]
[venantius/accountant "0.2.5"]
[com.cemerick/url "0.1.2-SNAPSHOT"]
[com.taoensso/timbre "4.10.0"]
[cljc.java-time "0.1.8"]
[bouncer "1.0.1"]
[orgpad/volcano "0.1.2"]
[macchiato/core "0.2.17"]
[macchiato/env "0.0.6"]
[mount "0.1.16"]]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :script}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}
:emails {:target :browser
:output-dir "emails/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.server.email.dev/init}}
:devtools {:http-root "emails"
:http-port 3600
:after-load orgpad.server.email.dev/mount-root
:watch-dir "emails"
:browser-inject :main}}
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}}}<meta charset="utf-8"> if its not in your HTML. wouldn't be the first time this fixed something.shadow-cljs cljs-repl client or just shadow-cljs node-repl or browser-repl<meta charset='utf-8'>
(shadow/nrepl-select :extension) , I appear to be connected to the browser environment within the extension. Anyone familiar with chromex to know how to get the REPL connected to the browser environment for the content-script (i.e., the actual loaded browser page)?(shadow/repl-runtimes :extension)
=>
[{:since #inst"2020-08-15T17:10:59.182-00:00",
:proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
:connection-info {:remote true, :websocket true},
:client-id 47,
:user-agent "Chrome 537.36 [MacIntel]",
:type :runtime,
:lang :cljs,
:build-id :extension,
:host :browser,
:dom true}
{:since #inst"2020-08-15T17:11:01.035-00:00",
:proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
:connection-info {:remote true, :websocket true},
:client-id 48,
:user-agent "Chrome 537.36 [MacIntel]",
:type :runtime,
:lang :cljs,
:build-id :extension,
:host :browser,
:dom true}]
is the runtime-id the same as the client-id?shadow/repl-runtime-select. Calling it with the client-id of 48 (seen above) and then running (shadow/nrepl-select :extension) does not result in the REPL calls getting eval’ed in the client-script environment.(shadow/repl-runtime-select :extension 88) => true (:default-runtime-id @(:state-ref (shadow/get-worker :extension))) => 87
(shadow/nrepl-select :extension {:runtime-id "<id>"}) does work. One thing that is frustrating with explicitly specifying the runtime id is if you refresh your browser, the id changes.Cursive nREPL client -> Shadow nREPL server -> CLJS clientBut I thought that second step was usually passed as a string rather than transit/JSON.
-Dfile.encoding=UTF-8 there, then restart IntelliJ, does that help?....["^ ", "~:op", "~:obj-result", ...:cljs-eval message the code is definitely garbled:js code looks like? it is cut off in the screenshot"čau" as expected. no garbled text or weird encodings.npx create-cljs-project foo cd foo npx shadow-cljs node-repl work?shadow-cljs watch client . This works when I send "čau" from Cursive.(shadow/repl :client) switches to ClojureScript REPL for the particular client.(shadow/repl :client) switches to the REPL of the :client build. whatever JS runtime is connected to thatshadow-cljs node-repl on my project. I connect to the REPL from Cursive and it works as above.(shadow/repl :client). it will attempt to switch to the REPL of the client build(shadow/node-repl) or (shadow/repl :node-repl) in case you already have done shadow-cljs node-replnpm install -g shadow-cljs to run the binary directly, and I had a quite old binary for some timenpm update -g shadow-cljsproject.clj and package.json, but I noticed that there was outdated version of Shadow-cljs displayed on the start when running shadow-cljs watch client, so I tried to update it in this waynpx shadow-cljs instead of shadow-cljs then so kinda annoying 😛C:\Shared\orgpad>shadow-cljs watch client ------------------------------------------------------------------------------ shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? NPM dependency "react" has installed version "^16.13.1" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.13.1" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.10.14 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... [:client] Build completed. (934 files, 79 compiled, 0 warnings, 29.43s)while having this in project.clj
[thheller/shadow-cljs "2.10.18"]
shadow-cljs.edn?:lein true or so in there?--------------- line shouldn't be there anymore. I fixed that.:lein true in your shadow-cljs.edn?{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[reagent-utils "0.3.3"]
[re-frame "0.12.0"]
[com.cognitect/transit-cljs "0.8.264"]
[day8.re-frame/http-fx "v0.2.0"]
[hickory "0.7.1"]
[binaryage/devtools "0.9.10"]
[bidi "2.1.6"]
[com.taoensso/sente "1.15.0"]
[venantius/accountant "0.2.5"]
[com.cemerick/url "0.1.2-SNAPSHOT"]
[com.taoensso/timbre "4.10.0"]
[cljc.java-time "0.1.8"]
[bouncer "1.0.1"]
[orgpad/volcano "0.1.2"]
[macchiato/core "0.2.17"]
[macchiato/env "0.0.6"]
[mount "0.1.16"]]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :script}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}
:emails {:target :browser
:output-dir "emails/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.server.email.dev/init}}
:devtools {:http-root "emails"
:http-port 3600
:after-load orgpad.server.email.dev/mount-root
:watch-dir "emails"
:browser-inject :main}}
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}}}project.clj at all as far as shadow-cljs is concernedpackage.json matterspackage.json used?:version "2.10.21" to your shadow-cljs.ednpackage.json.npm install afterwardsshadow-cljs.edn as mentioned above if that helpsnpm install shadow-cljs also updates itnpm install afterwardsnpx shadow-cljs insteadC:\Shared\orgpad>shadow-cljs watch client shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? NPM dependency "react" has installed version "^16.13.1" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.13.1" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.10.21 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... [:client] Build completed. (934 files, 0 compiled, 0 warnings, 99.62s)I get the same problem while testing both
shadow-cljs watch client and npx shadow-cljs watch client .JAVA_OPTIONS or so(System/getProperty "file.encoding")?Connecting to remote nREPL server... Clojure 1.10.1 (System/getProperty "file.encoding") => "Cp1250"
JVM_OPTS=-Dfile.encoding=UTF8 as a global environment variable:jvm-opts ["-Dfile.encoding=UTF8"] to your shadow-cljs.edn?.shadow-cljs/builds dir. no clue how the cache reacts to changing the file encoding 😛(map transit-read) to
(map (fn [x] (try (transit-read x) (catch Exception e (log/warn-ex e ::ws-read-fail {:x x})))))The required JS dependency "!!../../css-loader/index.js!./prosemirror.css" is not available, it was required by "node_modules/@aeaton/react-prosemirror/dist/index.js".
Dependency Trace:
nextdoc/devcards.cljs
nextdoc/text_editor.cljs
nextdoc/common/text_editor/editor.cljs
node_modules/@aeaton/react-prosemirror/dist/index.js:js-options {:ignore-asset-requires true} will ignore the css require which it previously did by default or warningsshadow.cljs.devtools.server/reload! is broken. shadow.cljs.devtools.server.runtime/instance-ref got changed into an atom here: https://github.com/thheller/shadow-cljs/commit/36e63a7801a2bafe0140fe9e49dbada9233335f8#diff-6f236ccd9b9e2a1e666f13927b75d522L3-R3 but shadow.cljs.devtools.server/reload! tries to call vreset! on it here: https://github.com/thheller/shadow-cljs/blob/6252e3b0843b21cfda49fe77bd0e51ad7b32782f/src/main/shadow/cljs/devtools/server.clj#L526. I guess reload! should call reset! instead.reload! is there. The callsite is in a user/reset type function.reload! at all there, though… need to dive into it a bit.(server/stop!) (server/start!) instead I guess- in the name?$jscomp isn't there:compiler-options {:output-feature-set :es8}:browser-test but not in :karma:compiler-options {:output-feature-set :es8} to the karma target sorts it out$jscomp in karma error we have just started using :output-feature-set :es6 about a week ago to workaround this issue and no problems so far. I think es5 is pretty much obsolete anyway as the only browsers that would matter for are Internet Explorer series (not MS Edge). So it should probably be asked, does anyone actually need es5 level polyfills by default ? @thheller @filipematossilva:karma default$jscomp not working properly. will figure out why its missing when I have timeCan't find 'shadow.cljs.devtools.cli' as .class or .clj for lein run: please check the spelling. Syntax error (FileNotFoundException) compiling at (/private/var/folders/z3/xn3w5qfj4cz854tgqrbgl9xc0000gn/T/form-init10942131942141271474.clj:1:126). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
> npx shadow-cljs release app shadow-cljs - config: /Users/tim/jsx-cljs-template/shadow-cljs.edn [:app] Compiling ... Closure compilation failed with 3 errors --- Component.js:2 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace) .... [2 more errors of this type]
Component.js look like.
//
import * as React from "react";
import StateProvider from "./StateProvider";
import { useStateValue } from "./StateProvider";
import defaultState from "./defaultState";
import Example2 from "./Component2";thheller/shadow-cljs dependency declared in project.clj?/app/borrow/models/1aabaeb8-c1a5-5c8e-858a-aa0bddf469dd, devtools try to get the source maps from /app/borrow/models/js/cljs-runtime/better_cond.core.js.map, instead from /app/borrow/js/cljs-runtime/better_cond.core.js.map. notice the /models/ part.
my config file is here: https://github.com/leihs/leihs-borrow/blob/mk/feat/booking-calendar/shadow-cljs.edn:asset-path "js" is incorrect then? should be :asset-path "/app/borrow/js"?/app/borrow/models/app/borrow/js/cljs-runtime/better_cond.core.js.map. besides that everything else works just fine based on my config…:module-loader (which you are not)===== ERROR ================= Failed to read config file: /Users/tonykay/fulcrologic/ucv/shadow-cljs.edn [line 86, col 141] No dispatch macro for e.when it reaches #env or #shadow/env
tools.reader. its already fixed in master just didn't cut a new release yet since I want to finish something else. https://clojure.atlassian.net/projects/TRDR/issues/TRDR-62#shadow/env ["FOO" "defaultVal"] so #shadow/env ["FOO" ""] would be the same behavior as before I thinkshadow-cljs compile app is different from that of shadow-cljs watch app.
By looking into their behaviour, it seems to me that the compile result is somehow reverting to some old version, possibly cached somewhere.
Does anybody know of a possible common reason for that?
(Here is my project: https://github.com/scicloj/gorilla-notes/blob/2821701/shadow-cljs.edn)
🙏.shadow-cljs cache subdirectory does not fix that.):resouce-paths in not a thing in shadow-cljs.edn and wouldn't apply anyways since you have :lein true and all classpath management is done by project.clj. setting :optimizations in :dev only does absolutely nothing since :dev ALWAYS forces :none and that cannot be modified. you can also leave :devtools always in since it will be ignored in release builds.:dev-http like that is not going to end well 😛watch and compile differ in that watch injects a bunch of extra REPL/hot-reloaded extra code, otherwise they should be the same:dev-http since it will conflict with :devtools {:http-port ..} otherwise{:lein true
:dev-http {8080 ["resources/public/"
"target"
"classpath:resources"
"classpath:resources/public"
"node_modules"
"node_modules/leaflet/dist"
"node_modules/mathjax/es5"
"node_modules/ag-grid-community"]}
:builds {:app {:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:target :browser
:modules {:main {:init-fn gorilla-notes.main/main!}}
:devtools {:after-load gorilla-notes.main/reload!}}}}:bootstrap target seems to be undocumented, and the anchor https://shadow-cljs.github.io/docs/UsersGuide.html#target-bootstrap (used by the very first mention of :bootstrap in the user's guide) is not attached to anything.
Is it an intentional omission?cljs and clj filesencore is indeed not compatible with bootstrapped CLJS, maybe it's worth creating an issue in its repo.The required namespace "taoensso.encore" is not available, it was required by "taoensso/timbre.cljs".shadow-cljs.edn, as the project currently uses:
:bootstrap
{:target :bootstrap
:output-dir "public/js/compiled/bootstrap"
:module-hash-names true
:entries [maria.user]
:exclude [cljs.js]}[:bootstrap] Build failure: The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc". "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ? + /live.html
:modules {:main {:entries [maria.user]}}sritchie/last_attempt branch here: https://github.com/sritchie/maria/tree/sritchie/last_attempt:bootstrap have any thoughts about what's going on, and why this bare :entries form is both required, but seems to get in the way of cljs compilation?:target :bootstrap does not support :modules so using it breaks stuff. :module-hash-names also has no effect. you just specify :entries and it will compile those to be available in self-hosted:exclude [cljs.js taoensso.encore]timbre requires it,taoensso.encore definitely does not support self-hosted CLJS(encore/something foo)sicmutils.env, which depends on namespaces that depend on timbre[:bootstrap] Build failure: The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc". "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ? + /live.html
taoensso.encore to :exclude - next to cljs.js - was tried already?exclude now.:exclude in the build configThe required namespace "io.aviso.exception" is not available, it was required by "taoensso/timbre$macros.cljc".taoensso.timbre#?(:clj
(defmacro bootstrap-repl!
"Bootstraps a repl or Clojure namespace by requiring all public vars from
sicmutils.env. From (This will only work at a repl in Clojurescript.)"
[]
`(require '~['sicmutils.env
:refer
(into [] (keys (ns-publics 'sicmutils.env)))])))[sicmutils.env :as e :include-macros true]requireenv#?(:clj
(defmacro with-literal-functions
[& args]
`(f/with-literal-functions :clj: browser.cljs. Is this a shadow-cljs limitation or a Clojurescript one, and is there something I can do about it?watch-mode, if that has anything to do with it"/css/view.css", which on the fs is at resources/public/css/view.css. I'm not using :dev-http so I have {:target :browser ... :devtools {:watch-dir "public" ...} in shadow-cljs.edn. does that look right? maybe I'm missing something in deps.edn? shadow command is server:watch-dir "resources/public"(:require ["docx4js"])
with :target :react-native, it works, but with :target :browser it throws
[:app] Build failure:
The required JS dependency "/node_modules/docx4js/lib" is not available, it was required by "shadow.js.shim.module$node_modules$docx4js$lib$props.js".
Dependency Trace:
r8/contree/styled_system.cljs
node_modules/docx4js/lib/index.js
node_modules/docx4js/lib/openxml/docx/document.js
node_modules/docx4js/lib/openxml/document.js
node_modules/docx4js/lib/document.js
shadow.js.shim.module.js
Apparently it trips over requiring node_modules/docx4js/lib/$props.js$ in their name ... why wouldn't there be 😛node_modules ...$.cljc file which uses a namespaced keyword in a :clj branch. When trying to evaluate that in a CLJS REPL, it barfs:
(cljs.core/load-file "/Users/lilactown/Code/amperity/app/service/web/web-ui/src/amperity/web/mx_segment/core.cljs")
------ ERROR -------------------------------------------------------------------
File: /Users/lilactown/Code/amperity/app/service/segment/segment-core/src/clj/amperity/mx_segment/folder.cljc:52:20
--------------------------------------------------------------------------------
49 | (do
50 | (pc/defresolver list-resolver
51 | [{:keys [tree] :as env} _input]
52 | {::pc/output [{::all config-keys}]}
--------------------------^-----------------------------------------------------
amperity/mx_segment/folder.cljc [line 52, col 20] Invalid keyword: ::pc/output.
--------------------------------------------------------------------------------
53 | (d/chain
54 | (list tree)
55 | (fn [seg-list]
56 | {::all seg-list})))
--------------------------------------------------------------------------------:clj branch as well, so if the reader is trying to interpret it it makes sense why it would barf. I would just expect it skip it since it’s in a reader conditional#?(:clj
(do
(pc/defresolver list-resolver
[{:keys [tree] :as env} _input]
{::pc/output [{::all config-keys}]}
(d/chain
(list tree)
(fn [seg-list]
{::all seg-list})))
(pc/defresolver get-resolver
[{:keys [tree] :as env} {:keys [::id] :as input}]
{::pc/input #{::id}
::pc/output [{::node config-keys}]}
(d/chain
(get tree id)
(fn [node]
{::node node})))))(:require [clojure.string :as pc])--- amperity/web/stitch/report_v2/viz.js:1 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
import and export, which it does)package.json dependencies: "local-package": "file:./local-package-src"::alias/ns behind a read-cond? Yeah, that would be good to get fixed in the reader ...`alias/foo
clojure.tools.reader/*alias-map* seems to be the only facility for that. I guess that could be hacked, by implementing ILookup, but there would be many open questions then, about how to proceed after read-cond has been resolved ...:read-cond :preserve, does it?::alias/kw would be part of the deal ..2.10.22.require("f" + "s") at https://github.com/lalalic/docx4js/blob/84ae60e0395e3cef066055d11392732b65c76d90/lib/document.js#L206
[:app] Compiling ...
[2020-08-21 11:47:11.520 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/docx4js/lib/document.js", :requires [{:line 206, :column 14}]}[:app] Build failure:
The required JS dependency "entities/maps/entities.json" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js".
Dependency Trace:
r8/contree/styled_system.cljs
node_modules/docx4js/lib/index.js
node_modules/docx4js/lib/openxml/docx/document.js
node_modules/docx4js/lib/openxml/document.js
node_modules/docx4js/lib/document.js
node_modules/docx4js/lib/$props.js
node_modules/cheerio/index.js
node_modules/cheerio/lib/cheerio.js
node_modules/cheerio/lib/parse.js
node_modules/htmlparser2/lib/index.js
node_modules/htmlparser2/lib/Parser.js
node_modules/htmlparser2/lib/Tokenizer.js
, where it refers to node_modules/entities/lib/maps/entities.json. Not sure, if that's related to the other error, somehow ..entities:target :react-native it works ...require("fs") are just to hide them from packagers. pretty stupid but I guess thats common in the JS world:target :react-native does no bundling whatsoever by shadow-cljs. its all done by react-native metroentities twiceentities htmlparser2/node_modules/entities cheerio/node_modules/entities
:js-options {:resolve {"entities/maps/entities.json" {:target :npm :require "entities/lib/maps/entities.json"}}} I think. never actually tried using it to override direct references but it should workrequire("fs") path in the browser anywaytap> from within the AWS lambdas and point it at a kind of IRC Bouncer/inbox style thing and then pick the tap>ed values up on my local machine using shadow inspecttap> never actually transfers the full value so that would be a problemtap> it from CLJasync-dispatch-N error when I shadow-cljs watch renderer . It happens non-deterministically, and usually mentions @material-ui/icons . The build is `
:renderer {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "js/compiled"
:modules {:renderer {:init-fn athens.core/init}}
:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {re-frame.trace.trace-enabled? true}}
:devtools {:preloads [devtools.preload
day8.re-frame.trace.preload]}}@material-ui/icons adds thousands of files to your build. I fixed something to that extent in some version. can't remember which.cljs.core.async is not a dependency in this projectlein deps :tree for conflicts2.8.110 to 2.10.22shadow-cljs server and then its printed on startup shadow-cljs - server version: 2.8.110 running at :autorun true:autorun true you can easily use other tools to achieve the same without being coupled to shadow-cljs. eg. https://github.com/kimmobrunfeldt/chokidar-cli just have that watch the :output-to file of the build and do stuff when it changes?js/process.env.WHATEVER_ENV_YOU_WANT--config-merge to use one build for testing and development."shadow-cljs watch test --config-merge \"{:closure-defines {tests.core/TEST_MODE \"tdd\" tests.core/SITE_URL \\\"$LOCAL_NAMESERVER\\\"}}\" "js/process.env. :closure-defines is definitely worse than doing that and pretty much only used by people in browser builds since that can't otherwise access your environment variablesws?watch running and then be able to quickly upload the artifact to AWS as I make code changes without having to do a full build every time{:source-paths ["src"]
:nrepl {:port 3333}
:dependencies [[binaryage/devtools "1.0.2"]
[reagent "1.0.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom]]
[nubank/workspaces "1.0.15"]]
:dev-http {8080 ["target/" "assets/"]}
:builds {:app {:output-dir "target/"
:asset-path "."
:target :browser
:modules {:main {:init-fn app.main/main!}}}
:cards {:target nubank.workspaces.shadow-cljs.target
:ns-regexp "-(test|cards)$"
:output-dir "target/workspaces"
:asset-path "workspaces"
:preloads []}}}
TBD, classpath indexing is gone.
{}
ExceptionInfo: TBD, classpath indexing is gone.
shadow.build.classpath/get-all-resources (classpath.clj:1225)
shadow.build.classpath/get-all-resources (classpath.clj:1223)
nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:10)
nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:9)
nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:36)
nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:30)
nubank.workspaces.shadow-cljs.target/process (target.clj:61)
nubank.workspaces.shadow-cljs.target/process (target.clj:53)
clojure.lang.Var.invoke (Var.java:384)
shadow.build/process-stage/fn--13688 (build.clj:162)
shadow.build/process-stage (build.clj:159)
shadow.build/process-stage (build.clj:151)
shadow.build/resolve (build.clj:407)
shadow.build/resolve (build.clj:403)
shadow.build/compile (build.clj:441)
shadow.build/compile (build.clj:434)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:440)
shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:429)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808/fn--14816 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14807 (util.clj:257)
java.lang.Thread.run (Thread.java:745)
:karma target for the first time — it works like a charm :+1: Thank you for it!:target :browser-test. don't need to use the workspaces target{:target :browser-test
:ns-regexp "-(test|cards)$"
:output-dir "target/workspaces"
:asset-path "workspaces"
:runner-ns nubank.workspaces.shadow-cljs.mount
:devtools
{:before-load nubank.workspaces.core/before-load
:after-load nubank.workspaces.core/after-load}}lein uberjar I get the following error:cljs {:source-paths ["src/cljs"]
:dependencies [
[org.clojure/clojurescript "1.10.773" :scope "provided"]
[com.google.javascript/closure-compiler-unshaded "v20200719"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
[thheller/shadow-cljs "2.10.22"]
[reagent "0.8.1"]
[re-frame "0.10.7"]
[kibu/pushy "0.3.8"]
[fork "2.0.0"]
[vlad "3.3.2"]
[day8.re-frame/http-fx "v0.2.0"]]}
:uberjar
{:resource-paths ["resources" "resources/sql"]
:source-paths ^:replace ["src/clj" "src/cljc"]
:prep-tasks ["compile"
["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
:hooks []
:omit-source true
:aot :all}})
here are the profiles entries in my project.clj. If I run lein run -m shadow.cljs.devtools.cli release app manually in a console, everything works fine.:prep-tasks ["compile" ["with-profile" "+cljs" "run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]`:prep-tasks ["compile"
["with-profile" "cljs"
["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]]release so closure compiler can do its thing. Brought it down to 11MB, still not great. Running gzip on that brings it down to 1.6MB, which I find acceptable for the interactive app that it is.Closure compilation failed with 4 errors --- kr/models/ronde-tempel-compiled.js:6 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace) ..
release that goes down even further to 1.2mB! nice 🙂.js files. still haven't figured out what the problem is though..js files seem to load okay, but the ones I ran manually through babel don't, they work in watch build though.bigfraction.js living inside of it too, that I'd love to package up as a different dependency:global-export entry that matched the NPM package, which I did and again that works great: https://github.com/cljsjs/packages/blob/master/fraction/build.boot#L35"fraction.js", and then this is on the user to only include one of cljsjs/fraction` vs cljsjs/bigfraction?fraction.js npm package and a bigfraction.js? thats all shadow-cljs needs to know. it doesn't even look at :foreign-libs for anythingfraction.js(:require ["fraction.js/bigfraction.js" :as bf])bigfraction.js instead, and then do this in build.boot:
(deps-cljs :provides ["fraction.js/bigfraction.js", "cljsjs.bigfraction"]
:requires []
:global-exports '{fraction.js/bigfraction.js Fraction
cljsjs.bigfraction Fraction})Fraction global it will conflict on thatline function but I'm getting error curve is not a function in line 23 https://github.com/d3/d3-shape/blob/master/src/line.js#L23
However, I can see that it is defined in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 (just few lines above its usage)
Is this related to shadow-cljs?
Here is snippet of how I use the line function
line (-> d3
(.line)
(.curve (.curveNatural d3))
(.defined #(not (js/isNaN (.-value %))))
(.x #(x (.-date %)))
(.y #(y (.-value %))))
_ (-> svg
(.append "path")
(.datum data)
(.attr "fill" "none")
(.attr "stroke" "green")
(.attr "stroke-width" 1.5)
(.attr "d" line))
EDIT:
Looking at the file generated by shadow for d3.js. The error is in line 349 in the attached snippetline function but I'm getting error curve is not a function in line 23 https://github.com/d3/d3-shape/blob/master/src/line.js#L23
However, I can see that it is defined in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 (just few lines above its usage)
Is this related to shadow-cljs?
Here is snippet of how I use the line function
line (-> d3
(.line)
(.curve (.curveNatural d3))
(.defined #(not (js/isNaN (.-value %))))
(.x #(x (.-date %)))
(.y #(y (.-value %))))
_ (-> svg
(.append "path")
(.datum data)
(.attr "fill" "none")
(.attr "stroke" "green")
(.attr "stroke-width" 1.5)
(.attr "d" line))
EDIT:
Looking at the file generated by shadow for d3.js. The error is in line 349 in the attached snippetcurve = curveLinear, means its just a rename for some reason and the actual function is coming from import curveLinear from "./curve/linear.js";ns :require?app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
at SVGPathElement.line (d3-shape.js:349)
at SVGPathElement.eval (d3-selection.js:399)
at Selection.each (d3-selection.js:366)
at Selection.attr (d3-selection.js:423)
at Object.repro_cljs_d3$core$init [as init] (core.cljs:77)
at eval (shadow.module.app.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:836)
at Object.env.evalLoad (app.js:2224)
at app.js:2404
Probably I'm missing some configuration?curve fn?d3?curveBasis: (...) curveBasisClosed: (...) curveBasisOpen: (...) curveBundle: (...) curveCardinal: (...) curveCardinalClosed: (...) curveCardinalOpen: (...) curveCatmullRom: (...) curveCatmullRomClosed: (...) curveCatmullRomOpen: (...) curveLinear: (...) curveLinearClosed: (...) curveMonotoneX: (...) curveMonotoneY: (...) curveNatural: (...) curveStep: (...) curveStepAfter: (...) curveStepBefore: (...)
curve example in the readme https://github.com/d3/d3-shape#curves
When using the generic d3 lib and use the line, I can draw a line chart, but the connection between the line/path are sharp. So I tried applying the curve function, but I'm getting the error above.
Using the d3-shape gives the same error.
I probably need to spend some time reading the docs and coded3-shape package not d3?(:require ["d3-shape" :as d3s]) (d3s/line) seems to have a .curve?d3-shape as mentioned above throws error as well when calling the (.curve)
line (-> (d3s/line)
(.curve (.curveNatural d3))
(.defined #(not (js/isNaN (.-value %))))
(.x #(x (.-date %)))
(.y #(y (.-value %))))
app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
at SVGPathElement.line (d3-shape.js:349)
at SVGPathElement.eval (d3-selection.js:399)
at Selection.each (d3-selection.js:366)
at Selection.attr (d3-selection.js:423)
at Object.repro_cljs_d3$core$init [as init] (core.cljs:76)
at eval (shadow.module.app.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:836)
at Object.env.evalLoad (app.js:2224)
at app.js:2427
If I understand the d3-shape code in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L10, it creates a var curve=curveLinear , which will be called later in the closure line 23, but it seems like by the time the closure get invoked, it throws an error that var curve declared in line 10 is not a function..curve(.attr "d" line)var curve has been hoisted?var curve is Natural which is this file https://github.com/d3/d3-shape/blob/master/src/curve/natural.js(.curve (.curveMonotoneX d3))
Correct way (dot hyphen)
(.curve (.-curveMonotoneX d3))d3 like that. it is a namespace alias so d3/curveMonotoneX would be correct and also looks better 😉2.11.0. it is however a breaking change in that only import Thing from "npm" is now supported. The previous import * as Thing from "npm" is now the error case. I hope its the last time I have to adjust this.import inside .js files on the classpath. CLJS remains the same.(s/instrument) at the bottom of that ns/top-level?instrument is that it is a macro and only instruments things that have been compiled by the type it is calledns also needs to require all namespaced its supposed to instrument(def ^:dev/after-load instrument-everything [] (js/cljs-eval "(cljs.spec.alpha/instrument)"))
(def ^:dev/after-load-async instrument-everything [done]
(-> (js/cljs-eval "(cljs.spec.alpha/instrument)")
(.then done))):build-options {:auto-require-suffixes #{"-spec"}} that will automatically add foo.bar-spec to the build if foo.bar is requiredinstrument issue needing to be called "late"(:require [cljs.spec.alpha :as s :include-macros true]) in my ns definition(s/instrument) at the top levelcljs.spec.test.alpha. not actually sure.(js/cljs-eval "(require 'cljs.spec.test.alpha) (cljs.spec.test.alpha/instrument)") of coursecljs-eval it?cljs-eval both like you have, rather than via preload?instrument is a macro so you need to realize what that meanscljs-eval it is ensured that the macro is expanded at a time where all other compilation has finished:preloads variant is better and probably more reliable but it is more work and easy to mess up<preload-ns> -> -> main.app-spec is fine but for example won't invalidate <preload-ns> when main.app-spec is changed and as such won't affect instrument:dev/always to the preload ns to always recompilemy.app.specs -> ?my.app.specs required somewhere. if you do that in the preload that is fine, or the :auto-require-suffixes I mentioned:preloads:dev/always or similar flags? code it will become "unstrumented". eg. watch compiles https://my.app and loads it so your fdef instrument is replaced:auto-require-suffixes stuff after all… will see 🤔instrument problem though 😉^:dev/after-load-async does right?import {
MuiPickersUtilsProvider,
KeyboardTimePicker,
KeyboardDatePicker,
} from '@material-ui/pickers';
with
(ns app.mui-component (:require ["@material-ui/pickers" :refer [MuiPickersUtilsProvider KeyboardTimePicker KeyboardDatePicker]]))having npm installed
"@material-ui/pickers": "^3.2.10",but end up with
shadow-cljs - failed to load module$node_modules$$material_ui$pickers$dist$material_ui_pickers shadow.js.jsRequire @ js.js:74 shadow.js.require @ js.js:113 eval @ app.mui_components.js:10 goog.globalEval @ main.js:577 env.evalLoad @ main.js:1670 (anonymous) @ main.js:2650 main.js:1672 An error occurred when loading app.mui_components.js env.evalLoad @ main.js:1672 (anonymous) @ main.js:2650 main.js:1673 undefined env.evalLoad @ main.js:1673 (anonymous) @ main.js:2650Any tips on what to check/try/read?
@material-ui/pickersimport and defs/cards/componests that end up relying on something undefined, I get no errors. When I remove the comments it’s like the whole namespace doesn’t load
react-dom.development.js:89 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See for details. * Move data fetching code or side effects to componentDidUpdate. * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: * Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder. Please update the following components: ReactGridLayout, ResponsiveReactGridLayout
@material-ui/pickers or something else?[:main] Build failure: Closure compilation failed with 2 errors --- kr/models/ronde-tempel-compiled.js:7 Requested module does not have an export "createElement". --- kr/models/ronde-tempel-compiled.js:7 Requested module does not have an export "useRef".
import { useRef, createElement } from 'react'import React, { useRef, createElement } from "react" works?import React from "react" and React.useRef might workshadow-cljs - server version: 2.10.13 running at
2.11.0. remember to update in project.clj or deps.edn if you use eitherwatch build works again, but having minification issues I think, for release
cannot read property 'geometry' of undefined
;;probably for
createElement("mesh", {
material: materials.red,
receiveShadow: true,
castShadow: true,
geometry: nodes.temple_railing_top.geometry,
name: "temple_railing_top",
position: [0.82, 2.23, -2.03],
rotation: [Math.PI, 0, Math.PI],
scale: [2.61, 2.61, 2.61]
})d3. By default, shadow would try to resolve a single d3 version. :js-options :resolve doesn't help here either, because it just lets me choose the d3 version to resolve, correct? How to best deal with this? Should I use rollup to package the two libraries?require and module.exports instead of import/export the file is treated as commonjs and as such does not go through :advanced:js-provider :externalrelease! thanks once again :):browser-test build is meant to be opened in a browser. it should generate an html file as part of its output that you can open:test {:target :browser-test
:test-dir "resources/public/test"
:ns-regexp "-test$"
:compiler-options {:language-in :es6
:output-feature-set :es6}
:devtools {:http-port 8021
:http-root "resources/public/test"}}test watch is runningshadow-cljs watch testenv.cljs:187 error when calling lifecycle function shadow.test.browser/start Error: Assert failed: cljs-test-display: Element with id "test-root" does not exist.index.html in test-dir<div id="test-root" />:browser-test should generate the index.html if it doesn't existprocess, hence triggering shadow's automatic require('process'), got moved by the closure compiler into a common base module, where it then failed to require process. But only in production mode.require('process') is added by shadow, it might have added the shadow$provide for process too late, because it didn't know about the require being cross-module moved, or something. If it's not obvious to you from the description, I can try to condense a test case ....:entries[:> react/Suspense {:fallback (r/reactify-component [loading/loading :loading/administration])}
[:> (lazy/component (slazy/loadable orgpad.client.views.administration.core/administration))]]
But I am getting the following error:
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
in Suspense (created by root-component)
in div (created by root-component)
in div (created by root-component)
in root-component (created by orgpad.client.views.root.root)
in orgpad.client.views.root.root
What am I doing wrong?(lazy/component (slazy/loadable orgpad.client.views.administration.core/administration))? returning?{:fallback (r/reactify-component [loading/loading :loading/administration])} should likely be {:fallback (r/as-element [loading/loading :loading/administration])}?(ns orgpad.client.views.widgets.lazy
(:require ["react" :as react]
[reagent.core :as r]
[shadow.lazy :as slazy]
[orgpad.client.views.loading :as loading]))
(defn- component
"React Lazy component which waits till the code is loaded and then replaces it with the component itself."
[loadable]
(react/lazy
(fn []
(-> (slazy/load loadable)
(.then (fn [root-el]
#js {:default (r/reactify-component (fn [props] [@loadable props]))}))))))
(defn lazy
"Renders a component whose source code may have to be first loaded. While the source code is loaded, renders the
loading screen for the given state. The single parameter is a map having the following keys:
:lazy/loadable - Call (slazy/loadable ).
:lazy/state - The loading state while the component's source code is loaded."
[{:lazy/keys [loadable state]}]
[:> react/Suspense {:fallback (r/reactify-component [loading/loading state])}
[:> (component loadable)]])
:require of a namespace you added to the :entries(require '[expound.alpha :as expound]) (set! clojure.spec.alpha/*explain-out* expound.alpha/printer) in the clojure vm that compiles macros…
Is there a way to wire shadow-cljs up to do that?user.clj at the root of the shadow jvms classpath?instrument errors will not be affected by that?(let [x]) or so the resulting spec error is printed by expoundinstrument myself, too scared of the code modifications it does 😛Closure compilation failed with 1 errors --- node_modules/jspdf/dist/jspdf.umd.min.js:355 Duplicate let / const / class / function declaration in the same scope is not allowed.
[:app] Build failure:
Failed to inspect file
/Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js
it was required from
/Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/index.js
Errors encountered while trying to parse file
/Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js
{:line 1, :column 1, :message "The file could not be parsed as JavaScript."}RuntimeException: Exception parsing "/Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js" com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:155) com.google.javascript.jscomp.JsAst.parse (JsAst.java:152) com.google.javascript.jscomp.JsAst.getAstRoot (JsAst.java:55) shadow.build.closure.JsInspector.getFileInfo (JsInspector.java:176) shadow.build.closure.JsInspector.getFileInfoMap (JsInspector.java:190) shadow.build.npm/get-file-info*/fn--10535 (npm.clj:549) shadow.build.npm/get-file-info* (npm.clj:548) shadow.build.npm/get-file-info* (npm.clj:490) shadow.build.npm/get-file-info (npm.clj:611) shadow.build.npm/get-file-info (npm.clj:608) shadow.build.npm/find-resource (npm.clj:709) shadow.build.npm/find-resource (npm.clj:661) shadow.build.resolve/find-npm-resource (resolve.clj:123) shadow.build.resolve/find-npm-resource (resolve.clj:94) shadow.build.resolve/fn--12489 (resolve.clj:257) shadow.build.resolve/fn--12489 (resolve.clj:226) clojure.lang.MultiFn.invoke (MultiFn.java:244) shadow.build.resolve/find-resource-for-string (resolve.clj:81) shadow.build.resolve/find-resource-for-string (resolve.clj:70) shadow.build.resolve/resolve-string-require (resolve.clj:375) shadow.build.resolve/resolve-string-require (resolve.clj:358) shadow.build.resolve/resolve-require (resolve.clj:591) shadow.build.resolve/resolve-require (resolve.clj:584) shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:50) shadow.build.resolve/resolve-deps (resolve.clj:34) shadow.build.resolve/resolve-string-require (resolve.clj:400) shadow.build.resolve/resolve-string-require (resolve.clj:358) shadow.build.resolve/resolve-require (resolve.clj:591) shadow.build.resolve/resolve-require (resolve.clj:584) shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:50) shadow.build.resolve/resolve-deps (resolve.clj:34) shadow.build.resolve/resolve-string-require (resolve.clj:400) shadow.build.resolve/resolve-string-require (resolve.clj:358) shadow.build.resolve/resolve-require (resolve.clj:591) shadow.build.resolve/resolve-require (resolve.clj:584) shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:50) shadow.build.resolve/resolve-deps (resolve.clj:34) shadow.build.resolve/resolve-string-require (resolve.clj:400) shadow.build.resolve/resolve-string-require (resolve.clj:358) shadow.build.resolve/resolve-require (resolve.clj:591) shadow.build.resolve/resolve-require (resolve.clj:584) shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:50) shadow.build.resolve/resolve-deps (resolve.clj:34) shadow.build.resolve/resolve-string-require (resolve.clj:400) shadow.build.resolve/resolve-string-require (resolve.clj:358) shadow.build.resolve/resolve-require (resolve.clj:591) shadow.build.resolve/resolve-require (resolve.clj:584) shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:50) shadow.build.resolve/resolve-deps (resolve.clj:34) shadow.build.resolve/resolve-string-require (resolve.clj:400) Caused by: StackOverflowError: com.google.javascript.jscomp.parsing.IRFactory.handleJsDoc (IRFactory.java:678) com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:829) com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpressionHelper (IRFactory.java:1840) com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1816) com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:3275)
(.on nodejs/process "SIGTERM" (fn []))
Cannot infer target type in expression (. nodejs/process on "SIGTERM" (fn []))
nodejs/process?(.on nodejs/process "SIGTERM" (fn []))(js/process.on ...) and banish cljs.nodejs from your codebase 😛:storybook
{:target :npm-module
:output-dir "out"
:entries [app.storybook]
:devtools {:enabled false}}}:npm-module, which I've never used before. That keyword doesn't appear in the user guide section you just linked, maybe that's why I missed it. Thought I'd give you a heads up!:npm-module? thats because there are a bazillion gazillion ways to use :npm-module and I can't possibly list all the "solutions":npm-module output and I have no clue what it does to it:npm-module in the Shadow-CLJS User Guide didn't lead me to the REPL Troubleshooting section, which is why I asked here. I thought you might appreciate knowing why a reader may have missed it.module.exports = {
stories: ["../stories/**/*.stories.js", "../out/**/*_story.js"],
addons: ["@storybook/addon-actions", "@storybook/addon-links"],
};"../out/**/*_story.js", but your CLJS namespace is stories.core, which for me is resulting in a stories.core.js file in my out folder."../out/**/*_story.js" , I've added "../out/**/stories.*.js" to the module.exports list in main.js and it seems to be working.stories.core to be included in the storybook build*_story.js files coming from?corp.design.button-story namespace*_story.js files, so I assumed it was a typo.stories.core so that shadow-cljs knows to build it
• in the storybook config using the glob pattern, so that the built file gets picked up by storybook’s CLIstories.core.js.babelrc was necessary? I would never have thought of that.storiesOf API?storiesOf API will be more accommodating to that, let me know if you have another idea!react-vega and I'm getting this issue
[:zubi] Build failure: The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js". Dependency Trace: zubi/dev.cljs zubi/client.cljs node_modules/react-vega/lib/index.js node_modules/react-vega/lib/Vega.js node_modules/react-vega/lib/utils/updateMultipleDatasetsInView.js node_modules/react-vega/lib/utils/updateSingleDatasetInView.js node_modules/vega-embed/build/vega-embed.js node_modules/vega/build/vega-node.js node_modules/vega-dataflow/build/vega-dataflow.js node_modules/vega-loader/build/vega-loader.js Searched for npm packages in: /home/souenzzo/src/zubi/node_modules See:I think that somehow
vega-loader thinks that it's running on nodejs (maybe ssr) and tryies to import a buffer.thheller/shadow-cljs {:mvn/version "2.11.0"}
Using "deps"
both JVM8 and JVM14 do the same error.npm install shadow-cljs in your project ...npm install --save-dev shadow-cljs and it do the hot-reoload even before I checkout logs/output
Tnks for shadow-cljs ❤️(tap> "==================") 😂:app {:target :browser
:js-options {:resolve {"foo" {:target :npm :require "foo"}}}}
Eval-ing the following code on the REPL:
(require '["foo" :as foo]) (js/console.log foo)I get the following:
{__esModule: true, default: ƒ}
So to make an instance of foo, I have to call (foo/default.)
Is there a way to specify within the build config that default should be “unwrapped” automatically, so that I can call (foo.)?
What I’m trying to solve (and perhaps there’s a better way): There’s a dependency foo which exports a constructor function directly via a UMD. Within tests I need to substitute foo with a mock, so I’m using a separate npm package foo-mock which is an ESM and the constructor is under the default export property.
The config in the end might look something like this:
:app {:target :browser
:js-options {:resolve {"foo" {:target :npm :require "foo"}}}}
:test {:target :browser-test
:js-options {:resolve {"foo" {:target :npm :require "foo-mock"}}}}
Thanks in advance!:resolve {"foo" {:target :npm :require "foo-mock$default"}} if you are on a recent version but I'm not sure that'll workBuild failure:
:resolve override for "foo" to "foo$default" which does not exist
{:tag :shadow.build.resolve/invalid-override, :require-from #object[java.io.File 0x4aa9328a ".../test.cljs"], :require "foo", :other "foo$default"}(:require ["foo" :default foo]) and direclty use (foo.) or (:require ["foo$default" :as foo]) (new "standard" variant likely coming in next CLJS release)module.exports.default = require("pusher-js-mock").Whatever;node_modules/pusher-js-mock-default/index.js or so:require redirect should be finedefmacro within a .`clj` file should use a fully-qualified namespace. But going by the shadow-cljs User Guide's https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages, I don't see how to use a fully-qualified namespace with CommonJS/ES6 imports, because they are referred to with strings as in (:require ["module-name"]).:browser-test and :node-test targets within the same shadow watch process? If I do this at the moment, shadow looks up for namespaces with "-test$" regexp and node-specific tests land in the browser-test target.
So the options would be either to run separate shadow processes with different classpaths, or to have more precise namespace naming convention for the regexps (like "$browser([\w-\.]+)test$" and "$node([\w-\.]+)test$")?your.app.frontend.foo-test vs your.app.backend.foo-test or your.app.whatever.foo-test?:namespaces [foo.bar-test ...] and :exclude #{foo.dummy-test} also exists:namespaces is used :ns-regexp has no effect though:filepath-regexp to filter based on the file paths?lein shadow watch app devcards should work and only give you one JVMdata_readers.cljc for a self hosted build? here is the shadow-cljs.edn: https://github.com/sritchie/maria/blob/sritchie/last_attempt/editor/shadow-cljs.edn:compiler-options {:data-readers true} to the bootstrap builddata_readers.cljc loaded, and I can see that it did make it into the jar(set!
cljs.tagged-literals/*cljs-data-readers*
(merge cljs.tagged-literals/*cljs-data-readers*
{'sicm/complex sicmutils.complex/parse-complex
'sicm/bigint sicmutils.util/parse-bigint
'sicm/ratio sicmutils.ratio/parse-ratio}))2.11.1 you can specify :test-paths ["test/node"] in the test build configs which will only make it use namespaces matching ns-regexp from those paths. they need to be classpath roots and already on the classpath though. maybe that works.hadow-cljs - starting via "clojure"
[2020-08-28 19:15:35.245 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
clojure.lang.Compiler.macroexpand (Compiler.java:7075)
clojure.lang.Compiler.eval (Compiler.java:7161)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:459)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
Caused by:
NoSuchFieldError ES3
cljs.closure__init.load (:133)
cljs.closure__init.<clinit> (:-1)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:427)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.10.21 running at
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[2020-08-28 19:15:45.805 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:427)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903):deps {:aliases [:cljs]} instead of :dependencies which I was avoiding for duplication reasons(:require ["@foo/bar" :as bar]) and then do [:> bar/DatePicker …]
The error I get is: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Looking at the react-datepicker issues, I came across: https://github.com/Hacker0x01/react-datepicker/issues/1333 but changing my tsx code to point at ReactDatePicker.default doesn’t seem to do the trick either.react-datepicker directly, but not when it’s nested in a component from another package.import * as React from 'react';
import ReactDatePicker from 'react-datepicker';
export interface DatePickerProps {
...
}
export const DatePicker = (props: DatePickerProps) => {
...
return (
<div>
<ReactDatePicker
...
/>
</div>
);
};:node-script target with :compiler-options {:hashbang false} yet a shebang still seems to be getting inserted at the beginning of my compiled file. any idea what might be causing that? I’m on 2.11.1
2. is there a way to inline generated source maps as opposed to keeping them in separate files?
:hashbang false is directly in the build config, not inside :compiler-options:compiler-options {:source-map-inline true}[:> Thing ...] Thing was undefined. so you said bar/DatePicker which probably meant bar/DatePicker is undefinedWARNING] can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs. even after I’ve run the npm install command?npx shadow-cljs ...npm uninstall -g shadow-cljs seems like it works but the binary is still therewhich shadow-cljs or soyarn?yarn global removesrc/clj and src/cljs?A session with the same parameters exists (clojure-projects/reviews:localhost:56442). You can connect a sibling instead. Proceed? (y or n) y
[nREPL] Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
[nREPL] server started on 57396
[nREPL] Establishing direct connection to localhost:57396 ...
[nREPL] Direct connection to localhost:57396 established
error in process filter: user-error: The shadow-cljs ClojureScript REPL is not available. Please check for details
error in process filter: The shadow-cljs ClojureScript REPL is not available. Please check for detailsimport * as React from "react";suddenly results in this error:
Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import React from 'goog:module$node_modules$react$index';?
.js are kinda weird now?
If i
import Card from "@material-ui/core/Card";I now only can use it via
<Card.default> ... </Card.default>The
import { foo } from "bar"
imports work as expected.tap> is super handy! is there any way to be able to send stuff from a server side process to the inspect tab via the same helper..?(:require [shadow.cljs.devtools.server :as shadow-server]) (defn start-shadow-inspect [] (println "Starting shadow-server...") (shadow-server/start!))^ It will find an open port and print on what port it started.
node-libs-browser.
https://github.com/advisories/GHSA-vh7m-p724-62c2node-libs-browser is deprecated and unlikely to be updated. Should I simply patch my yarn.lock file with a new elliptic version, or are there any plans for shadow-cljs that will sidestep this issue in the near future?require("crypto") and then use this in a browser (as :node-script etc will not use node-libs-browser)crypto-browserify are relaxed for the minor version; so the child dependencies can be updated, even if there isn't a new release of node-libs-browser.yarn upgrade. I now have {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "caafa6a6a3babea3a98afce4ffe4f9"}, :content ("[email protected]")}. The joys of semantic versioning (seriously). The version restrictions were loose enough in shadow-cljs deps that I received the updated child packages. Well that's solved my problem 😊:build-hooks but they are just for a particular build. I want to be able to add new builds dynamically. :relaxed:(shadow.cljs.devtools.api/release* {:build-id :app :target :node-script :main 'foo.bar/main :output-to "somewhere/script.js"} {})shadow-cljs release app but instead of loading the build config from shadow-cljs.edn you just pass it in directlyshadow-cljs.edn :builds but also requires the :build-id to be present--debug preserve line numbers by chance? 😬npm install @chainsafe/discv5cljs.user=> (require '["@chainsafe/discv5" :as discv5])
[2020-09-03 08:18:14.954 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(require '[\"@chainsafe/discv5\" :as discv5])", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (require (quote ["@chainsafe/discv5" :as discv5])), :source "(require '[\"@chainsafe/discv5\" :as discv5])", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:520)
shadow.cljs.repl/process-read-result (repl.clj:494)
shadow.cljs.repl/process-input (repl.clj:674)
shadow.cljs.repl/process-input (repl.clj:658)
shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813/fn--14821 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14812 (util.clj:257)
java.lang.Thread.run (Thread.java:834)
Caused by:
ExceptionInfo closure errors {:tag :shadow.build.closure/errors, :errors [{:resource-name nil, :source-name nil, :line -1, :column -1, :msg "Attempted to run pass \"markUntranspilableFeaturesAsRemoved\" on input with features it does not support. Running pass anyway.\nUnsupported features: [bigint]"}]}
shadow.build.closure/throw-errors! (closure.clj:1164)
shadow.build.closure/throw-errors! (closure.clj:1158)
shadow.build.closure/convert-sources-simple* (closure.clj:1902)
shadow.build.closure/convert-sources-simple* (closure.clj:1759)
shadow.build.closure/convert-sources-simple (closure.clj:2057)
shadow.build.closure/convert-sources-simple (closure.clj:2009)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1172)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1165)
shadow.build.compiler/compile-all (compiler.clj:1417)
shadow.build.compiler/compile-all (compiler.clj:1284)
shadow.build.api/compile-sources (api.clj:259)
shadow.build.api/compile-sources (api.clj:251)
------ REPL Error while processing ---------------------------------------------
(require '["@chainsafe/discv5" :as discv5])
Closure compilation failed with 1 errors
--- null:-1
Attempted to run pass "markUntranspilableFeaturesAsRemoved" on input with features it does not support. Running pass anyway.
Unsupported features: [bigint]ECMASCRIPT_2019. I’m not sure if that will resolve the compiler error or not:compiler-options {:output-feature-set :es-next} I believe it the setting. let me check.:compiler-options {:language-out :no-transpile}--debug adds source maps so you can get the original line from that?--debug build?release builds don't have source maps by default? did you enable them?--debug is source map + pseudo namesreact-dom or so.react-dom.production.min.js which doens't have source mapsconsole.loging them?(js/console.log ex) chrome source maps them. if you (js/console.log (.-stack ex)) it does not I believe:compiler-options changed anything, but thanks for your help:compiler-options {:language-in :es-next
:output-feature-set :es-next}:language-out not in:es-next and changes nothing:output-feature-set replaces :language-out:compiler-options {:language-out :no-transpile}:output-feature-set:output-feature-set is the newer option but I don't think it has a "do nothing" optionv20200830 maybe try thatv20200830 is referring to a shadow-cljs release?[com.google.javascript/closure-compiler-unshaded "v20200830"][com.google.javascript/closure-compiler-unshaded "v20200719"] (if you are on 2.11.x)build-state in a build hook will affect the build, but it does not appear to.
I have tried updating both :output-dir and :closure-defines in the :configure stage and the build appears to use their original values. (When I log the build config in subsequent stages it is updated, but the build does not reflect the update.)
Am I misunderstanding how to modify build-state via hooks?(assoc build-state :output-dir whatever) won't do anything(update-in build-state [:shadow.build/config :closure-defines] merge {some/other "config"}):output-dir of a :browser build you need to override this value https://github.com/thheller/shadow-cljs/blob/9178e39a84108b1c0b9b26368b161a9501f4b39f/src/main/shadow/build/targets/browser.clj#L317:target implementation and the :target implementation will already have taken everything out of :shadow.build/config and not look at it again(update-in build-state [:compiler-options :closure-defines] merge {}):configure stagewatch mode. Then I need to wait a bit until Shadow is done compiling, before starting the node process. Can I automate this in some way?srv=build/server.js
# run the server under node
( rm -f ${srv}; while [ 1 ]; do if [ -f ${srv} ]; then node ${srv}; else sleep 1; fi; done ) &
# watch-and-compile the server
( npx shadow-cljs watch server ) &
here the node script artifact being built is build/server.jswait and run everything as background tasks. at the start of the script i have this:
trap killgroup SIGINT
killgroup(){
echo killing...
kill 0
}
which kills everything launched in the script when ctrl-C is runshadow-cljs node-repl and go from there 😉(shadow/watch :my-app). But that doesn't seem to work in a node-repl? Am I mis-reading https://shadow-cljs.github.io/docs/UsersGuide.html#node-repl?:my-app build but can still just (require '[ :as x]) and (x/main "foo" "bar") or so (emulating a regular :node-script build for example)node-repl just manages the node process so you don't have to use hacks to wait for files to appear or so:preloads loading goog.string.format:require in the nsformat is actually it its own "namespace". looks a bit weird but works(ns my-app.core
(:require [goog.string :as gstring]
[goog.string.format]))goog.string and goog.string.format format are basically 2 namespacesgoog.string.format is not actually a namespace, only a functiongoog.string.format was required anywhere else but its not something you should rely on so the :require fixes thatshadow-cljs watch app --verbose or use the UI to see where it spends its time[:main] Compiling ... <- Resolving Module: :main (171 ms) <- Compile CLJS: minbedrift/ui.cljc (118 ms) <- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1460 ms) <- Cache write: minbedrift/ui.cljc (852 ms) <- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (1370 ms) <- build target: :browser stage: :compile-finish (312 ms) <- Flushing unoptimized modules (2066 ms) <- build target: :browser stage: :flush (2465 ms) [:main] Build completed. (1076 files, 2 compiled, 0 warnings, 6.64s)I think I saw much better compile times on this app before summer so something in the environment must have changed...
minbedrift/ui/kostnadsdeling/ui.cljc do? macro heavy stuff? maybe including huge edn data?Cache write: minbedrift/ui.cljc (852 ms) is also quite slowkostnadsdeling/ui has 593 lines, 31KB, and 13 direct macro calls, namely Fulcro's defsc .
minbedrift/ui has 3KB and 75 lines (and includes the kostnadsdeling.ui namespace and others).<- Cache write: minbedrift/ui.cljc (709 ms) <- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1339 ms) <- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (552 ms)after a trivial code change
"Runtime.ImportModuleError: Error: Cannot find module 'react'", in logs, which doesn't appear in the frontend build. Anyone know what i'm missing?node_modules for the lambda. node-script and node-library builds by default do not bundle their dependencies and will delegate to node to provide them. you can post process the output with something like https://github.com/vercel/ncc to make them fully self-contained if you want.ncc might be useful, thanksCannot infer target type in expression errors? The code compiles are first go, but it breaks hot-reloading. I'm trying to use web bluetooth.[:app] Build failure:
Failed to inspect file
<project>/node_modules/keypress/index.js
it was required from
<project>/node_modules/node-web-bluetooth/src/InteractiveTermList.js
Errors encountered while trying to parse file
<project>/node_modules/keypress/index.js
{:line 374, :column 30, :message "Octal integer literals are not supported in strict mode."}
{:line 375, :column 30, :message "Octal integer literals are not supported in strict mode."}watch are also very high, correct? I have just tested running npx shadow-cljs watch :main --verbose in https://github.com/fulcrologic/fulcro-rad-demo/, forcing a recompilation by changing a string at line 57 of src/shared/com/example/ui/sales_report.cljc Detailed verbose output in the thread.[:main] Compiling ... -> Resolving Module: :main <- Resolving Module: :main (83 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: com/example/ui/sales_report.cljc -> Compile CLJS: com/example/ui/dashboard.cljc -> Compile CLJS: com/example/ui.cljc <- Compile CLJS: com/example/ui/dashboard.cljc (136 ms) -> Cache write: com/example/ui/dashboard.cljc <- Compile CLJS: com/example/ui/sales_report.cljc (518 ms) -> Cache write: com/example/ui/sales_report.cljc <- Compile CLJS: com/example/ui.cljc (457 ms) -> Cache write: com/example/ui.cljc <- Cache write: com/example/ui/dashboard.cljc (616 ms) <- Cache write: com/example/ui/sales_report.cljc (753 ms) <- Cache write: com/example/ui.cljc (1201 ms) -> build target: :browser stage: :compile-finish <- build target: :browser stage: :compile-finish (20 ms) -> build target: :browser stage: :flush -> Flush: com/example/ui.cljc -> Flush: com/example/ui/dashboard.cljc -> Flush: com/example/ui/sales_report.cljc <- Flush: com/example/ui/dashboard.cljc (4 ms) <- Flush: com/example/ui.cljc (11 ms) <- Flush: com/example/ui/sales_report.cljc (17 ms) -> Flushing unoptimized modules -> Flush: shadow/module/main/append.js <- Flush: shadow/module/main/append.js (2 ms) <- Flushing unoptimized modules (1425 ms) <- build target: :browser stage: :flush (1583 ms) [:main] Build completed. (1014 files, 3 compiled, 0 warnings, 3.87s)Second recompile, 2.3s:
[:main] Compiling ... -> Resolving Module: :main <- Resolving Module: :main (70 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: com/example/ui/sales_report.cljc -> Compile CLJS: com/example/ui/dashboard.cljc -> Compile CLJS: com/example/ui.cljc <- Compile CLJS: com/example/ui/dashboard.cljc (53 ms) -> Cache write: com/example/ui/dashboard.cljc <- Compile CLJS: com/example/ui/sales_report.cljc (436 ms) -> Cache write: com/example/ui/sales_report.cljc <- Compile CLJS: com/example/ui.cljc (323 ms) -> Cache write: com/example/ui.cljc <- Cache write: com/example/ui/dashboard.cljc (593 ms) <- Cache write: com/example/ui/sales_report.cljc (618 ms) <- Cache write: com/example/ui.cljc (675 ms) -> build target: :browser stage: :compile-finish <- build target: :browser stage: :compile-finish (15 ms) -> build target: :browser stage: :flush -> Flushing unoptimized modules -> Flush: com/example/ui/sales_report.cljc -> Flush: com/example/ui/dashboard.cljc <- Flush: com/example/ui/sales_report.cljc (10 ms) -> Flush: com/example/ui.cljc <- Flush: com/example/ui/dashboard.cljc (14 ms) <- Flush: com/example/ui.cljc (7 ms) -> Flush: shadow/module/main/append.js <- Flush: shadow/module/main/append.js (0 ms) <- Flushing unoptimized modules (756 ms) <- build target: :browser stage: :flush (778 ms) [:main] Build completed. (1014 files, 3 compiled, 0 warnings, 2.32s)
[:main] Build completed. (1014 files, 1013 compiled, 0 warnings, 48.54s) [:main] Compiling ... -> Resolving Module: :main <- Resolving Module: :main (44 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: com/example/ui/sales_report.cljc -> Compile CLJS: com/example/ui/dashboard.cljc -> Compile CLJS: com/example/ui.cljc <- Compile CLJS: com/example/ui/dashboard.cljc (20 ms) -> Cache write: com/example/ui/dashboard.cljc <- Compile CLJS: com/example/ui/sales_report.cljc (82 ms) -> Cache write: com/example/ui/sales_report.cljc <- Compile CLJS: com/example/ui.cljc (78 ms) -> Cache write: com/example/ui.cljc <- Cache write: com/example/ui/dashboard.cljc (174 ms) <- Cache write: com/example/ui/sales_report.cljc (173 ms) <- Cache write: com/example/ui.cljc (216 ms) -> build target: :browser stage: :compile-finish <- build target: :browser stage: :compile-finish (8 ms) -> build target: :browser stage: :flush -> Flushing unoptimized modules -> Flush: com/example/ui/sales_report.cljc -> Flush: com/example/ui.cljc -> Flush: shadow/module/main/append.js <- Flush: shadow/module/main/append.js (5 ms) <- Flush: com/example/ui.cljc (22 ms) <- Flush: com/example/ui/dashboard.cljc (28 ms) <- Flush: com/example/ui/sales_report.cljc (38 ms) <- Flushing unoptimized modules (133 ms) <- build target: :browser stage: :flush (150 ms) [:main] Build completed. (1014 files, 3 compiled, 0 warnings, 0.68s)
[:main] Build completed. (1014 files, 3 compiled, 0 warnings, 0.56s)0.69s-> Resolving Module: :main <- Resolving Module: :main (24 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: com/example/ui/sales_report.cljc -> Compile CLJS: com/example/ui/dashboard.cljc <- Compile CLJS: com/example/ui/dashboard.cljc (11 ms) -> Cache write: com/example/ui/dashboard.cljc -> Compile CLJS: com/example/ui.cljc <- Compile CLJS: com/example/ui/sales_report.cljc (62 ms) -> Cache write: com/example/ui/sales_report.cljc <- Compile CLJS: com/example/ui.cljc (66 ms) -> Cache write: com/example/ui.cljc <- Cache write: com/example/ui/dashboard.cljc (141 ms) <- Cache write: com/example/ui/sales_report.cljc (134 ms) <- Cache write: com/example/ui.cljc (158 ms) -> build target: :browser stage: :compile-finish <- build target: :browser stage: :compile-finish (9 ms) -> build target: :browser stage: :flush -> Flushing unoptimized modules -> Flush: com/example/ui/sales_report.cljc -> Flush: shadow/module/main/append.js <- Flush: com/example/ui.cljc (1 ms) <- Flush: com/example/ui/sales_report.cljc (1 ms) <- Flushing unoptimized modules (177 ms) <- build target: :browser stage: :flush (189 ms) [:main] Build completed. (1012 files, 3 compiled, 0 warnings, 0.63s)
^js hint in the correct location? or just turn it off if you don't care about release. :compiler-options {:infer-externs false}(<p! (.writeValue ^js sock chunk))
Cannot infer target type in expression (. inst_48442 (writeValue inst_48443))
sock value is the result of de-refing an atomsock outside the go then annotate it there:after-load fn of a :target :browser build from the :flush hook of a :target :bootstrap build?(ns a-ns (:require [some.namespace :as sn])) (defmacro something [] (sn/some-function "do a thing"))… when used in another namespace seems to sporadically give me:
(ns another-ns) (something) ;=> Use of undeclared Var some.namespace/some-functionWhich is resolved by doing
(:require [some.namespace]) at the use site of the macro… but this hasn’t usually been necessary and the issue goes away from time to time.
This seems like it might be new behavior (I’m using 2.10.22), but that could be due to mutations in my own codebase.
Would really welcome any thoughts on this, I’ve tried debugging and poking around a bunch to no reliable discovery of the pattern causing the issue so far 🙂(ns app.util #?(:cljs (:require-macros [app.util])).shadow-cljs/release-snapshots/<build-id>/latest/bundle-info.edn file, maybe it contains what you need?const SortableMultiValue = SortableElement(props => {
const onMouseDown = e => {
e.preventDefault();
e.stopPropagation();
};
const innerProps = { onMouseDown };
return <components.MultiValue {...props} innerProps={innerProps} />;
});
<SortableSelect
components={{
MultiValue: SortableMultiValue,
}}
/>
one of the downfalls of working on cljs so long is i've long since forgotten all the javascript arcana!reagent I presume?(def SortableMultiValue
(SortableElement
(fn [props]
(let [mouse-down
(fn [e]
...)]
(react/createElement
components/MultiValue
(js/Object.assign
#js {:innerProps
#js {:mouseDown mouse-down}}
props))))))
[:> SortableSelect {:components #js { :MultiValue SortableMultiValue}}]const - that's after my time. been cljsing since 2012 😅 it's super occasional that i need something like this.
thank you @thheller! using rum actually, but yeah, this gets me there!const with var, if that makes it more readable 😉dev.preload is being loaded from the :devtools {:preloads [dev.preload]} slot in my shadow-cljs.edn. I have (js/console.log "We are preloading.") right at the top of my dev.preload namespace and nothing is being printed in the browser. What should I try next?"We are preloading" when the app loads, so I know that dev.preload is the correct namespace.
(ns app.core (:require [dev.preload]))
:devtools {:preloads [dev.preload]} in my build config would have the same effect, please let me know if there's an extra step or if there's something that I missed. If it helps, my :source-paths is just ["src"], and the file is src/dev/preload.cljs.:builds
{:app
{:target :npm-module
...
:devtools {:preloads [dev.preload]}}}:npm-module does not support preloads:npm-module is sort of deprecated and kinda dead:npm-modulenpm-module target, and having the Storybook process load all the compiled .js files that are prefixed with my stories namespace.:npm-module?:node-script be worth trying?:esm is the more modern :npm-module but its probably not an option for storybook:esm target is coming pretty close... But I'm getting these two warnings:
Warning: unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.
Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
in Transition (created by CSSTransition)
in CSSTransition (created by app.sidebar.modal_left)
in app.sidebar.modal_left (created by stories.core.sidebar_modal)
in stories.core.sidebar_modal (created by reagent3)
in reagent3 (created by storyFn)
in div (created by storyFn)
in storyFn
in ErrorBoundary:modules are not meant for this.:main {:entries [app.main]
:init-fn mut.main/pre-init}
:cards {:entries [app.dev.cards]
:depends-on #{:main}}
From a human perspective, obviously they essentially give us separate exposed entry points into the app i.e. init fns.:main module larger than it needs to be:cards might mean it can’t dead code eliminate something it otherwise would be able toimport { Filter, FilterSettingsModel, GridComponent, IFilter, Inject } from '@syncfusion/ej2-react-grids'
with
export default class App extends React.Component<{}, {}>{
public Filter : IFilter = {
type: 'CheckBox'
}
public render() {
return <GridComponent dataSource={data} filterSettings={this.FilterOptions}
allowFiltering={true} height={273}>
<ColumnsDirective>
<ColumnDirective field='OrderID' width='100' textAlign="Right"/>
<ColumnDirective field='CustomerID' filter={this.Filter} width='100'/>
<ColumnDirective field='EmployeeID' width='100' textAlign="Right"/>
<ColumnDirective field='Freight' width='100' format="C2" textAlign="Right"/>
<ColumnDirective field='ShipCountry' width='100'/>
</ColumnsDirective>
<Inject services={[Filter]} />
</GridComponent>
}
}
How do I use `services={[Filter]}` with CLJS? IFilter interface what?#js [#js {:type "CheckBox"}] I presume, not actually a clue if typescripts adds anythingIFilter is a TypeScript interface, they have no runtimeimport { Filter } confuses me? what is that?public Filter = { type: "CheckBox" } is just regular property syntax?class or did you want to do that?App(defclass Something
(extends SomethingElse)
(field foo 1)
(field bar)
(constructor [this x]
(super "foo")
(set! bar (+ foo x)))
Object
(someMethod [this foo])
SomeProtocol
(foo [this bar]))(Something. 1)some.ns.Something = class some$ns$Something { constructor(x) { ... }}class but then life happened. I think someone created a library that does it by extending/altering the compiler at a distance:target :npm-module support repl?shadow-cljs - #34 ready! - like messages on development? The reason I need is because I'm compiling for a target that if I try to print on console, it raises an error 😱(set! shadow.cljs.devtools.client.browser/devtools-msg (fn [])) in a preload or sowebsocket.cljs:12 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED . How can I solve it? REPL is not working too in VS Code, but for Clojure (not a script one) it's working fine. Tried both Chromium and Firefox.:output-dir or :modules {:main ...} to :modules {:app ...} or so? anything that affects where the output goes basically but did not update your HTML to load that code and instead still load the old stuff?shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.0 running at shadow-cljs - nREPL server started on port 8777
:asset-path is for a :bootstrap build is? If I try to do advanced compilation, I get errors about goog not found from the bootstrap stuff in particular.:bootstrap does not have that setting at all. :advanced is not compatible with bootstrap, must use :simple:simple ? (ie both the app and bootstrap builds):advanced doesn't work with :bootstrap a shadow-cljs limitation, or a fundamental self-hosted cljs limitation?:nrepl {:port 9000} or so in your shadow-cljs.edn?:simple for both my :app and :bootstrap targets ... and when I try to load the page, I get some shadow-cljs logs that say "failed to load 8" "failed to load 16" and "failed to load 23" each of those is a jsRequire call of some sort ... can you provide any hints about debugging what might be causing this?:js-provider :shadow (requiring then on the ns form). For example, jsdom have the following code somewhere:
exports.Canvas = null;
let canvasInstalled = false;
try {
require.resolve("canvas");
canvasInstalled = true;
} catch (e) {
// canvas is not installed
}
if (canvasInstalled) {
const Canvas = require("canvas");
if (typeof Canvas.createCanvas === "function") {
// In browserify, the require will succeed but return an empty object
exports.Canvas = Canvas;
}
}canvas installed. Is there a workaround, or should I use the default :js-provider and use something else to bundle my js file?require.resolve):js-options {:resolve {"canvas" false}} so it won't bundle it:esm when embedding into other targets. thats needs a lot more work before that becomes practical.:npm-module should work fine *BUT* you need to ensure the REPL ns is loaded from JS(require "./cljs/whatever.your.ns")shadow.cljs.devtools.client.browserif (process.env.NODE_ENV === "development") { require ... } in the JSshadow.cljs.devtools.client.browseresm sometime. I have a large interest in getting seamless TS and cljs interop. But don’t always control the bundling experience:advanced is supposed to do:asset-path "/js" not a relative :asset-path "js":asset-path : perfect. Thanks!localhost/portfolio/ ; however, I need it to work without the slash at localhost/porfolio . Suggestions?a but I want the compiler to really pull in b.cljs.{:browser
{:js-options
{:resolve {a {:require b}}}}}:build-options {:ns-aliases {a b}}. eg. https://github.com/day8/re-frame-debux#option-2-namespace-aliases-with-shadow-cljs:dependencies [[some-dep "version" :exclusions [foo]]deps.edn? Because you can create an alias with :override-deps to point to your fork; and then pull in the deps via alias in shadow.import Select, { components } from 'react-select';
in this:
(ns yep
(:require ["react-select" :default react-select]
["react-select/async" :default react-select-async]))
I also need to import Option from "react-select" somehow:override-deps works since they are different artifacts, not different versions, I'm including district0x/mount and want to exclude mount since the both contains the same namespaces{mount {:git/url "" :sha ...}}
(But you would need to add a deps.edn to your forked repo){:mvn/version "..." :mvn/artifact ...}Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- nil ========= Running Tests ======================= internal/modules/cjs/loader.js:968 throw err; ^ Error: Cannot find module 'xmlhttprequest'
npm install xmlhttprequest? Guess you are using :node-test and a library that does a require("xmlhttprequest") somewhere?shadow-cljs compile test. I added a dependency to use cljs-ajaxnpm install xmlhttprequest should fix it(:require ["react-select" :as react-select :default Select :refer (Option)]) or sonode_modules (there were just tooooo many). you can touch node_modules/that-package/package.json though to trigger a recompile:advanced unlike node_modules which is only :simple(dotimes [x 1000] (prn x)) (might be because I'm on windows?)81
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
nil
user=> ^C
user=> *print-fn* in sci instead of only *out* which works better for CLJS(re-frame/reg-event-db
::check-web3
(fn-traced [db [_ js-window]]
(let [web3-enabled (exists? (.-ethereum js-window))]
(js/console.log (str "Browser is web3? " web3-enabled " " (.-ethereum js-window) " " js-window))
(assoc db :web3-enabled? web3-enabled))))
I'm trying to check for window.ethereum which is a proxy object added by http://MetaMask.io extension .lein release and load the app via static servergoog.object/get^js type hint fixes the issue with advanced compilation (fn-traced [db [_ ^js js-window]] .
Thanks again.com.google.guava/guava {:mvn/version "23.0"} manually to my deps today, because of:
[2020-09-15 12:49:30.646 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError com/google/common/collect/Streams
com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)
com.google.javascript.jscomp.Compiler.findModulesFromInput (Compiler.java:1914)
com.google.javascript.jscomp.Compiler.findModulesFromEntryPoints (Compiler.java:1870)
com.google.javascript.jscomp.Compiler.parseInputs (Compiler.java:1679)
com.google.javascript.jscomp.Compiler.parseForCompilationInternal (Compiler.java:954)
com.google.javascript.jscomp.Compiler.lambda$parseForCompilation$4 (Compiler.java:937)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:129)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:843)
com.google.javascript.jscomp.Compiler.parseForCompilation (Compiler.java:935)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:693)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
Caused by:
ClassNotFoundException com.google.common.collect.Streams
jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
java.lang.ClassLoader.loadClass (ClassLoader.java:522)
com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)com.datomic/dev-local 0.9.195 com.google.errorprone/error_prone_annotations 2.3.4 com.datomic/client-api 0.8.54 com.cognitect/anomalies 0.1.12 com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
:frontend alias and a :backend alias(run! prn (range 500))
https://babashka.org/xterm-sci/"js-build" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"] which command or flag could help me? (that code from project.clj file)release produces an optimized build:modules:target :browser) buildcljs-runtime dir confuses you that is from watch or compile builds and is not needed in release builds. you can optionally just clean out the :output-dir before running the release:release {:output-dir "somewhere/else"} see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configurationconst Logo_1 = require("./Logo");
require("../styles/overlay.css");
const { Header, Content, Sider, Footer } = antd_1.Layout;
exports.Overlay = (props) => {
return (React.createElement(antd_1.Layout, null, ...:js-options {:ignore-asset-requires true} but it is better to just avoid them to begin withshadow-cljs - failed to load module$node_modules$highlight_DOT_js$lib$core:target?cli version: 2.8.26 node: v13.7.0 with :target :browser:compiler-options {:output-feature-set :es6} in your build config2.11.4deps.edn / package.jsonyarn global add shadow-cljs and bumped to 2.11.4 and it seems to have fixed the issue:target :bootstrap build and it works great to get all the sources, but if any code captured in the bootstrap is changed and then after-load function is called in the host build and I run boot/init again, I get stale code in the bootstrap build. Seems if the index has been built once, it never tries to fetch any code again.
Feels a bit at odds with the fantastic reload mechanics of Shadow, and is not particularly helpful while developing. I tried a workaround where I would simply reset the index-ref and force all sources to be fetched again, but the ran into issues with goog namespaces “already being provided”.
Feels like I’m maybe holding the tool wrong? Has anyone else found a nice reloadable workflow when working with the bootstrap target?import {AgGridColumn, AgGridReact} from 'ag-grid-react';
import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-alpine.css';
to a cljs import.
["ag-grid-react" :as agr :refer [AgGridReact]] ;;TODO: can't figure out how to bring in styles: ["ag-grid-community/dist/styles/ag-grid.css"] ["ag-grid-community/dist/styles/ag-theme-alpine.css"]The compiler error looks like this:
errors in file: /home/jarrett/.../NewSite/node_modules/ag-grid-community/dist/styles/ag-grid.css
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/ag-grid-community/dist/styles/ag-grid.css", :js-requires [], :js-errors [{:line 6, :column 72, :message "Semi-colon expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: /home/jarrett/.../NewSite/node_modules/ag-grid-community/dist/styles/ag-grid.css:require:npm-moduleundefined is not an object (evaluating 'Z4.$l') but it works just fine when running dev builds?Z4 was before, it shouldn't have been renamed.
Or you have something different happening in the release build so that Z4 is a genuine variable that has a value of undefined.(ns notifications.notifications
(:require [clara.rules :as clara])
(:require-macros [clara.macros :refer [defrule defsession]]))
(defsession session 'notifications.notifications
:fact-type-fn :type)
(defn testz [user-id]
{[:user/id user-id] [:user/id]})
(defrule follow
"A rule which isd fired on every follow"
[:context [env] (= ?env env)]
[:follow [{followed-id :followed/id user-id :user/id}]
(= ?followed-id followed-id)
(= ?user-id user-id)]
=>
(testz ?user-id))
(defn handle-event [env event]
(-> session
(clara/insert (merge env {:type :context})
event)
(clara/fire-rules))):sources-paths ["src/main" "../that-subproject/src/main"] if its just about source paths:before-load
^:dev/always on the ns https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks(clara/clear-ns-productions!) needs to be put in the nsshadow-cljs watch command. How can I make this happen?:push-state/headers key as described in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http) seems promising for this, but adding it doesn’t seem to have any effect{...
:builds
{:app
{:target :browser
...
:modules {:app {:entries []}}
;; to enable in development only
:dev {:closure-defines { true}}
;; to enable always
:closure-defines { true}
;; you may also enable it for release as well
:release {:closure-defines { true}}
}}
you could use :dev and :release to use hardcoded versions. or start shadow from the command line and then cider-connect-cljs to the already running instance with easily set env vars(setenv VARIABLE VALUE). make a function that does this and then calls cider-jack-in-cljs and you might be good if you really wan to stay in emacs(cider-connect-cljs (list :host "localhost"
:port 7888
:cljs-repl-type 'figwheel-connected
'project-dir "~/projects/aclaimant/acl"))
in a function. you could adjust that as needed with a call to set-envnpx shadow-cljs watch :main running forever? Like so:
[:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.39s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.35s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s) [:main] Compiling ... [:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.34s) ... (forever) ...
:output-dir is also on any of the :source-pathsdev-resources 😛resources are filteredresources -directory with compiled / generated stuff but want to put it under target . What is the best setup for this? With Leiningen I can define cljsbuild output to go under target and then have two resource-paths , one under source resources and one from under target . Have I missed something in the manual? As far as I can see :http-root is singular.:dev {:compiler-options {:devcards true}}
in the docs, I'll try adding that as well@re-frame.db/app-db => #object[ReferenceError ReferenceError: re_frame is not defined]
Timeout while waiting for result.[2020-09-20 23:33:38.961 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(require '[orgpad.common.util.url :as url])", :ns cljs.user, :repl true}, :include-init true, :call-id 6, :from 52}}
AssertionError Assert failed: (symbol? repl-ns)
shadow.build.resolve/resolve-repl (resolve.clj:639)
shadow.build.resolve/resolve-repl (resolve.clj:639)
shadow.cljs.repl/repl-require (repl.clj:207)
shadow.cljs.repl/repl-require (repl.clj:187)
shadow.cljs.repl/process-read-result (repl.clj:514)
shadow.cljs.repl/process-read-result (repl.clj:494)
shadow.cljs.repl/process-input (repl.clj:680)
shadow.cljs.repl/process-input (repl.clj:658)
shadow.cljs.devtools.server.worker.impl/fn--15155 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--15155 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14818/fn--14819/fn--14827 (util.clj:285)(require '[orgpad.common.util.url :as url])index.js files?
NPM package A (`querystring`) emulates a node module, its entry point is index.js. It is required by NPM package B in my dependencies (`require("querystring")` ). Compilation fails because the compiler cannot find dependency querystring .
I, on the other hand, can require it by mentioning (:require ["querystring/index"]) . Indeed, I can fix this by altering altering package B to specify require("querystring/index") but it is a brittle solution at best. What would be a better fix?npm install shadow-cljs in your project. which you should be getting a warning on startup about.querystring is one of those node polyfill packages which will be installed if you npm install shadow-cljsnpm install querystring which didn't do the trick anywayreframe.db/app-db and now I have to use (require 're-frame.db) to make it work. What did make this change?shadow-cljs cljs-repl app session or soproject
|-- api
| |-- src\clj
|
|-- client 1
| |-- src\cljs
|
|-- client 2
|-- src\cljs:client1 :client2 builds be enough?:lein {:profile "+client"}lein with-profiles +client2 run -m shadow.cljs.devtools.cli watch build-idnode_modules to public or am i thinking about this all wrong?(when-not (fs/existsSync out-dir) (fs/mkdirSync out-dir))
karma start --single-run for the tests?:roots ["resources-devcards/public" "resources/public"] and has the push-state/index set to "devcards.html".
To repro the problem, I start shadow-cljs up fresh. I navigate to http://localhost:3001/devcards.html and make a change to my css file. shadow-cljs will reload the css. In the console, I see "shadow-cljs: load CSS /css/main.css" printed exactly one time for each css change. This is the expected behavior. Now I open a second tab with my main app at http://localhost:3000/. I now make a single CSS change and see the "load CSS" message printed 3 times in the main app's console. If I make another change, I get the the load CSS message printed 6 times in the main app console. The next single change results in 12 load CSS. The whole time, the devtools console at 3001 is also printing out exponentially more load CSS messages. I also notice that even when I'm not making any changes to the CSS, the head element is continuously flashing in the Elements tab. This indicates that the head element is changing frequently. This pattern will continue until both tabs crash completely. The Chrome message is "Error code: SIGILL".
This issue is quite disruptive to our workflow. I'm on Ubuntu 20.04 but we have other devs on Mac that have been experiencing this as well. Chrome 85.0.4183.102. This has popped up fairly recently so rolling back to an earlier version may be a good solution for the time being.<link rel="stylesheet" type="text/css" media="screen,projection" href="/css/main.css">
<link rel="stylesheet" type="text/css" media="screen,projection" href="/css/devcards.css">
And the main :app index.html file (which is also on the classpath of the devcards app) relies on just one file:
<link rel="stylesheet" type="text/css" media="screen,projection" href="/css/main.css">
cloneNode will copy inline listeners.head element in the Elements tab in Chrome. After making a CSS change, I observe 2^(number of css changes) <link> elements added. It will then slowly start removing some number of those. This is with 2.10.22.(:require ["@date-io/dayjs" :default DayjsUtils]
["@material-ui/pickers" :refer (DatePicker MuiPickersUtilsProvider)]
[orgpad.client.util.date :as date])
I have also tested other versions of including this, the value of DayjsUtils in REPL is nil. I was following https://material-ui-pickers.dev/getting-started/usage[:> MuiPickersUtilsProvider {:utils DayjsUtils}
[:> DatePicker {:value (date/parse "2020-06-18" true)
:on-change #(js/console.log %)}]]react_devtools_backend.js:2273 Warning: Failed prop type: The prop `utils` is marked as required in `MuiPickersUtilsProvider`, but its value is `undefined`.
in MuiPickersUtilsProvider (created by orgpad.client.views.widgets.date_picker.date_picker)
in orgpad.client.views.widgets.date_picker.date_picker (created by orgpad.client.views.widgets.grid.item)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.item)
in orgpad.client.views.widgets.grid.item (created by orgpad.client.views.widgets.grid.grid)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.grid)
in orgpad.client.views.widgets.grid.grid (created by orgpad.client.views.widgets.paper.paper)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.paper.paper)
in orgpad.client.views.widgets.paper.paper (created by orgpad.client.views.administration.users.user_filter)
in orgpad.client.views.administration.users.user_filter (created by orgpad.client.views.widgets.grid.item)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.item)
in orgpad.client.views.widgets.grid.item (created by orgpad.client.views.widgets.grid.grid)
in div (created by ForwardRef)
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.grid)
in orgpad.client.views.widgets.grid.grid (created by orgpad.client.views.administration.users.users)
in orgpad.client.views.administration.users.users (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
in function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
} (created by orgpad.client.views.administration.core.administration)
in orgpad.client.views.administration.core.administration (created by reagent4)
in reagent4 (created by orgpad.client.views.widgets.lazy.lazy)
in Suspense (created by orgpad.client.views.widgets.lazy.lazy)
in orgpad.client.views.widgets.lazy.lazy (created by root-component)
in div (created by root-component)
in div (created by root-component)
in root-component (created by orgpad.client.views.root.root)
in orgpad.client.views.root.root
overrideMethod @ react_devtools_backend.js:2273
printWarning @ checkPropTypes.js:21
checkPropTypes @ checkPropTypes.js:83
validatePropTypes @ react.development.js:1715
createElementWithValidation @ react.development.js:1814
reagent$impl$template$make_element @ template.cljs:422
reagent$impl$template$native_element @ template.cljs:334
reagent$impl$template$vec_to_elem @ template.cljs:366
reagent$impl$template$as_element @ template.cljs:385
reagent$impl$component$wrap_render @ component.cljs:114
reagent$impl$component$do_render @ component.cljs:141
(anonymous) @ component.cljs:164
reagent$ratom$in_context @ ratom.cljs:42
reagent$ratom$deref_capture @ ratom.cljs:55
reagent$ratom$run_in_reaction @ ratom.cljs:537
reagent$impl$component$render @ component.cljs:164
finishClassComponent @ react-dom.development.js:17161
updateClassComponent @ react-dom.development.js:17111
beginWork @ react-dom.development.js:18621
beginWork$1 @ react-dom.development.js:23180
performUnitOfWork @ react-dom.development.js:22155
workLoopSync @ react-dom.development.js:22131
performSyncWorkOnRoot @ react-dom.development.js:21757
(anonymous) @ react-dom.development.js:11090
exports.unstable_runWithPriority @ scheduler.development.js:654
runWithPriority$1 @ react-dom.development.js:11040
flushSyncCallbackQueueImpl @ react-dom.development.js:11085
flushWork @ scheduler.development.js:598
channel.port1.onmessage @ scheduler.development.js:165
material-ui-pickers.js:48 Uncaught TypeError: Utils is not a constructor
at eval (material-ui-pickers.js:48)
at mountMemo (react-dom.development.js:15443)
at Object.useMemo (react-dom.development.js:15739)
at Object.exports.useMemo (react.development.js:1522)
at MuiPickersUtilsProvider (material-ui-pickers.js:47)
at renderWithHooks (react-dom.development.js:14804)
at beginWork (react-dom.development.js:17483)
at HTMLUnknownElement.callCallback (react-dom.development.js:189)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:238)
at invokeGuardedCallback (react-dom.development.js:293)(ns orgpad.client.views.widgets.date-picker
(:require ["@date-io/dayjs" :as dayjs]
["@material-ui/pickers" :refer (DatePicker MuiPickersUtilsProvider)]
[orgpad.client.util.date :as date]))
(defn date-picker
[]
[:> MuiPickersUtilsProvider {:utils dayjs}
[:> DatePicker {:value (date/parse "2020-06-18" true)
:on-change #(js/console.log %)}]])
Fuck this shit, I don't think I will ever understand enough JS to know how this stuff works.nil..js output files and produce HTML files. Eleventy does its thing with a command line utility, so I've got a build hook setup with shadow-cljs to call node node_modules/.bin/eleventy on the :flush event.
Eleventy needs a module.exports = my_render_func in the JS module that it reads, so I'm using the :esm target in my shadow-cljs.edn. As Eleventy expects CommonJS, I'm using the NodeJS esm library to make my shadow-cljs output compatible. This means that in my :flush build hook, I'm calling (sh "node" "-r" "esm" "node_modules/.bin/eleventy").
So far, this is working perfectly with shadow-cljs compile site. Eleventy produces all the expected HTML files. The problem comes when I run shadow-cljs watch site. Shadow-cljs gets stuck at the "compiling..." stage and never finishes. Do you have any suggestions for a workaround? Eleventy seems to be a good fit so far for shadow-cljs, and I feel like I'm really close to a smooth workflow. I'd love to write up a blog post to help others with shadow-cljs + Eleventy, but this part has me stumped.:flush hook.:builds
{:site
{:target :esm
:output-dir ".shadow-cljs-cache"
:build-hooks
[(build.hooks/eleventy)]
:modules {:index.11ty {:exports
{default pages.index/default}}}}}}(defn eleventy
{:shadow.build/stage :flush}
[build-state & args]
(let [output (sh "node" "-r" "esm" "node_modules/.bin/eleventy")]
(when-not (empty? (:err output))
(println (:err output)))
(println (:out output)))
build-state)watch command itself that you can run separately and skip the hook altogether?shadow-cljs compile.index.11ty.js, which exports.default a function that calls reagent's render-to-static-markup and returns an HTML string. Eleventy is basically running index.11ty.js, taking the HTML string, and creating the resulting HTML file (with some templating that it takes care of).index.11ty.js, one created by shadow-cljs compile and one created by shadow-cljs watch. I noticed that there's a bunch of extra shadow.* namespaces that are imported in the version created by shadow-cljs watch, I figure some of these for hot-reloading functionality in the browser and providing the ability to connect to a REPL. I suspect that when Eleventy evaluates index.11ty.js, it's getting stuck somewhere on this REPL/hot-reload code.:devtools {:enabled false} in your build config:node-library though?:esm seems like a weird choice if you actually want commonjs?:node-library a while, but I got the same error as in https://github.com/thheller/shadow-cljs/issues/304.
No protocol method ISwap.-swap! defined for type cljs.core...
module.exports = my_render_func with the :npm-module target, which is mentioned later in that issue.foo.js yourself that just has module.exports = require("./path-to-npm-module-output/your.ns").the_export;(defn ^:export the-export [foo bar] ...) in that ns--watch command, as you suggested in your first response. With this alternative workflow, I set Eleventy up to call shadow-cljs compile site every time it reloads.No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object].shadow-cljs watch. It's hanging on Compiling ..., and after I ctrl-c to exit, I'm getting a successful message Eleventy saying Copied 9 files / Wrote 1 file in 0.94 seconds, followed by shadow-cljs - #3 ready!. The HTML generation does in fact work perfectly after I ctrl-c to get out of the Compiling... message.{:devtools {:enabled false}} as you suggested fixes the hanging problem. It no longer gets stuck on Compiling.... I feel even closer to the solution now, but Hot Reload really seems important to the workflow. Fingers crossed you have an idea for me!shadow-cljs watch build1 build2 build3 and then shadow-cljs cljs-repl build1 and so on (or nrepl) to talk to a specific REPL for a given build2.9.2 to the latest version, there is an error on Android, but works fine on ios , react native projectgoog.math.Long is used by cljs.core. sounds like a bug in hermes to me though?:version "2.9.5" in shadow-cljs.edn (assuming you use neither project.clj nor deps.edn)shadow-cljs compile build and load itrelease builds don't evalshadow-cljs compile buildapp/index.js is self-contained and won't connect to the REPLevalLoad callsenv.evalLoad = function(name, code) {
goog.globalEval(code);
};{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ee978b808a8fae8a8b9d859a819e"}, :content ("[email protected]")}console.log("loading", name, code) or so:output-feature-setclass Long and that maybe confuses Hermes?compile buildsSHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n const asserts \x3d goog.require(\x22goog.asserts\x22);\n const reflect \x3d goog.require(\x22goog.reflect\x22);\n class Long {\n constructor(low, high) {\n this.low_ \x3d low | 0;\n this.high_ \x3d high | 0;\n }\n toInt() {\n return this.low_;\n }\n toNumber() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n }\n isSafeInteger() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n }\n toString(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n }\n getHighBits() {\n return this.high_;\n }\n getLowBits() {\n return this.low_;\n }\n getLowBitsUnsigned() {\n return this.low_ \x3e\x3e\x3e 0;\n }\n getNumBitsAbs() {\n if (this.isNegative()) {\n if (this.equals(Long.getMinValue())) {\n return 64;\n } else {\n return this.negate().getNumBitsAbs();\n }\n } else {\n var val \x3d this.high_ !\x3d 0 ? this.high_ : this.low_;\n for (var bit \x3d 31; bit \x3e 0; bit--) {\n if ((val \x26 1 \x3c\x3c bit) !\x3d 0) {\n break;\n }\n ...compile but not watch?goog.math.Long/** @const */ var reflect in 2.9.4 vs const reflect in 2.11.4:output-feature-set :es5 that should change the rewriting{:target :react-native
:init-fn app.core/init
:output-dir "app"
:dev {:devtools {
:autoload true
:reload-strategy :full
:after-load app.core/reload
:compiler-options {:source-map false
:output-feature-set :es5}}
:local-ip #shadow/env "SHADOW_HOST"}
:release {:compiler-options {:output-feature-set :es6
:warnings-as-errors true
:infer-externs :auto
:optimizations :advanced
:js-options {:js-provider :closure}}}}const reflect syntax in index.js
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n const asserts \x3d goog.require(\x22goog.asserts\x22);\n const reflect \x3d goog.require(\x22goog.reflect\x22);\n class Long {\n constructor(low, high) {\n this.low_ \x3d low | 0;\n this.high_ \x3d high | 0;\n }\n toInt() {\n return this.low_;\n }\n toNumber() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n }\n isSafeInteger() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n }\n toString(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n }\n getHighBits() {\n return this.high_;\n }\n getLowBits() {\n return this.low_;\n }\n getLowBitsUnsigned() {\n SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n /** @const */ var asserts \x3d goog.require(\x22goog.asserts\x22);\n /** @const */ var reflect \x3d goog.require(\x22goog.reflect\x22);\n /** @final @constructor */ var Long \x3d function(low, high) {\n /** @private @const @type {number} */ this.low_ \x3d low | 0;\n /** @private @const @type {number} */ this.high_ \x3d high | 0;\n };\n /**\n * @return {number}\n */\n Long.prototype.toInt \x3d function() {\n return this.low_;\n };\n /**\n * @return {number}\n */\n Long.prototype.toNumber \x3d function() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n };\n /**\n * @return {boolean}\n */\n Long.prototype.isSafeInteger \x3d function() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n };\n /**\n * @param {number\x3d} opt_radix\n * @return {string}\n * @override\n */\n Long.prototype.toString \x3d function(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n };\n /**\n * @return {number}\n */\n Long.prototype.getHighBits \x3d function() {\n return this.high_;\n };\n /**\n * @return {number}\n */\n Long.prototype.getLowBits \x3d function() {\n return this.low_;\n };\n /**\n :compiler-options {:output-feature-set :es5} at the top level of your build config map when you want to use hermes on react-native target:target :karma and it not launching the headless chrome when running npx karma start --single-run?[2020-09-24 13:16:06.847 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 1, :from 24}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/fn--15169/fn--15172 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
My config currently looks like this, basically the minimal one I could get my hands on.
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[reagent "1.0.0-alpha2"]]
:dev-http {8081 "public"}
:nrepl {:port 8082}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn app/init}}}}}
I come from using figwheel and figwheel-main for a long time, first time using shadow-cljs for a project, so probably I'm doing something wrong here. Using neovim, vim-fireplace. Running shadow-cljs by running npx shadow-cljs watch frontend , connecting my repl by doing :Connect 8082 and then :Piggieback :frontend . Everything works except until I reload the page, then starting to get that error above and the only thing I can do to make it work is restarting shadow-cljs watch again, then it starts working.create-cljs-project so got the version from thereprintln's and alike, nothing extremeeval to be the cause here. release builds will not eval and instead load the code directly.hermes so can't say much more:es5 should not be a required setting but if it makes hermes happy then fine just set it:dev {:compiler-options {:output-feature-set :es5}} if you only want it in dev[:app] Build failure:
override to file that doesn't exist
{:tag :shadow.build.npm/invalid-override, :require-from #object[java.io.File 0x4d68156d "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-dataflow/build/vega-dataflow.js"], :require "vega-loader", :file #object[java.io.File 0x41ebcb92 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.node.js"], :override "./build/vega-loader.js", :override-file #object[java.io.File 0x5d156b61 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.js"]}
ExceptionInfo: override to file that doesn't exist
shadow.build.npm/find-resource (npm.clj:735)
shadow.build.npm/find-resource (npm.clj:661)
shadow.build.resolve/find-npm-resource (resolve.clj:123)
shadow.build.resolve/find-npm-resource (resolve.clj:94)4.3.3 but 4.3.2 still had the non-min file https://unpkg.com/browse/vega-loader@4.3.2/build/vega-loader.js"vega-loader": "4.3.2", "vega-canvas": "1.2.4"apparently, version 1.2.5 of the vega-canvas package suffered from the same issue.
:module-hash-names explains I should probably use the generated manifest.edn with it, but can't seem to find any ways of not having to manually (or write a script for it) replace the path in my index.html to the fingerprinted bundle. Is there no option for this?:build-hooks
[(shadow.html/copy-file
"out/demo-browser/index.src.html"
"out/demo-browser/public/index.html")]<script src="/js/main.js"> if you build config has :asset-path "/js" :modules {:main ...}clj-run to trigger the function:warnings-as-errors {:ignore #{transit.*}} I believe?(deftype DefaultHandler [] Object (tag [this v] "unknown") (rep [this v] (pr-str v)))
Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)
{:warning :infer-warning, :line 8, :column 1, :msg "Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)"}
ExceptionInfo: Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)(set! *warn-on-infer* false) is a quickfix until then 😉(deftype ^js DefaultHandler []
Object
(tag [this v] "unknown")
(rep [this v] (try
(str v)
(catch :default e
(when goog.DEBUG
(log/warn "Transit was unable to encode a value."))
"UNENCODED VALUE"))))deps.edn includes a com.datomic/dev-local dep? Compilation hangs for me when I include it but works fine if I remove it.:source-paths I do not succeed when it comes to actually requiring the file:js-options with :resolve to my json file to no availjs/require to let metro fill it in(def data (js/require "../assets/foo.json")):output-dirshadow/lazy:lein true and moved all clojurescript deps into shadow-cljs.edn. When I run shadow-cljs watch app it fails with the required namespace devtools.preload is not available.
But binaryage/devtools 1.0.2. Is one of my dependencies in shadow-cljs. edn.
What is the problem? Should i go back to combination of lein and shadow-cljs even if it is discouraged fy shadow-cljs website?[] or so?shadow-cljs info shows a bitshadow-cljs watch :my-test something-here
?shadow-cljs watch my-test --config-merge "{:autorun true}"AssertionError Assert failed: (rc/valid-resource-id? src-id) shadow.cljs.devtools.server.worker.impl/eval17300/fn--17303/fn--17306 (impl.clj:808) error? :shadow.cljs.devtools.server.util/handle-ex reports {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "common/lists.cljc"]... and :sources seems to include a nil which I presume is causing the problem. Unfortunately I can't quite work out what's causing the nil.deps.edn aliases etc) but has been working brilliantly until I made too many changes without testing stepwise.:a
[2020-09-29 20:04:36.176 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "common/lists.cljc"] [:shadow.build.classpath/resource "common/allocations.cljc"] [:shadow.build.classpath/resource "test/tools.cljc"] [:shadow.build.classpath/resource "test/examples.cljc"] [:shadow.build.classpath/resource "test/common/allocations.cljc"] [:shadow.build.classpath/resource "test/common/api.cljc"] [:shadow.build.classpath/resource "test/common/appointments.cljc"] [:shadow.build.classpath/resource "test/common/dates.cljc"] [:shadow.build.classpath/resource "test/common/fsm.cljc"] [:shadow.build.classpath/resource "test/common/lists.cljc"] [:shadow.build.classpath/resource "test/common/message.cljc"] nil [:shadow.build.classpath/resource "test/common/core.cljc"] [:shadow.build.npm/resource "node_modules/react/cjs/react.production.min.js"] [:shadow.build.classpath/resource "test/client/events/requests.cljs"] [:shadow.build.classpath/resource "test/client/core.cljs"] [:shadow.build.npm/resource "node_modules/scheduler/cjs/scheduler.production.min.js"] [:shadow.build.npm/resource "node_modules/react-dom/cjs/react-dom.production.min.js"] [:shadow.build.npm/resource "node_modules/scheduler/cjs/scheduler-tracing.production.min.js"] [:shadow.build.npm/resource "node_modules/react-is/cjs/react-is.production.min.js"] [:shadow.build.npm/resource "node_modules/prop-types/factoryWithThrowingShims.js"] [:shadow.build.classpath/resource "cljs/user.cljs"]], :call-id 5, :from 57}}
ExceptionInfo no output for id: [:shadow.build.classpath/resource "test/examples.cljc"] {:resource-id [:shadow.build.classpath/resource "test/examples.cljc"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/eval17300/fn--17303/fn--17306 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
Timeout while waiting for result.2.11.4 just in case[2020-09-29 09:40:52.675 - WARNING] provide conflict for #{goog.structs.Set} provided by web/js/bootstrap/js/goog.structs.set.js and {"/goog/structs/set.js" #{goog.structs.Set}}outdir-dir ? or asset-path ? I see no explicit classpath in my shadow-cljs.edn.:source-paths and the :output-dir being on said source path:source-paths have my output dir on them - but if I remove it from source-paths and restart shadow-cljs, I get the same error.cljs-runtime dir which bootstrap doesn't have:js-options :resolve with :target :global.
So here comes the question: If we want to use :target :global on react-native what is the best way to populate global? In our web app we can execute JS before the app runs, but on mobile I didn’t find a way to do so.:js-options {:resolve {"quill" {:target :global :global "quill"}}} .
Quill is just one of many examples and it would be great not to have to restructure all code around those dependencies, but find a solution at build tool level.:js-provider :external if thats coming from webpack or so? only desribed here currently https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external:js-options {:resolve {"quill" false}}(:require ["quill" :as q]) the q will be false:target :bundle:external stuff maybeUncaught TypeError: Cannot read property 'hydrate' of undefined(ns pwa.core
(:require [react-dom :as react-dom]
[reagent.core :as r]))hydrate in the code you pasted so no clue how you are using it?(ns ^:figwheel-hooks pwa.core
(:require [pwa.shared :as shared]
[react-dom :as react-dom]
[reagent.core :as r]))
(defn mount [el]
(react-dom/hydrate (r/as-element [shared/root]) el))node_modules/react-dom is empty for some reasonnpmhtml-react-parser for the server side part, which meant i also had to install react and react-dom with npm.
Have tried clearing node_modules completely and reinstalling multiple times, npm installing the same version as reagent (16.13.0)ls node_modules/react-dom/ build-info.json index.js package.json README.md server.js test-utils.js unstable-fizz.browser.js unstable-fizz.node.js cjs LICENSE profiling.js server.browser.js server.node.js umd unstable-fizz.js unstable-native-dependencies.js
npm install or so maybe try doing thatshadow-cljs.edn:
{:source-paths ["src"]
:dependencies [[cljs-ajax "0.8.0"]
[org.clojure/core.async "1.3.610"] ; ignored by shadow-cljs (embedded)
[funcool/cuerdas "2.2.0"]
[clojusc/defun "0.4.0"]
[frankiesardo/linked "1.3.0"]
[jamesmacaulay/cljs-promises "0.1.0"] ; FIXME: When batching cartography files: uncomment and `shadow-cljs pom`
;;[cider/cider-nrepl "0.23.0"] ; for Calva + Shadow-cljs
[net.cgrand/xforms "0.19.2"]]
:nrepl {:port 3333}
:builds {:lib {:target :node-library
:output-dir "public/census"
:output-to "public/census/census.js"
:compiler-options {:optimizations :advanced
:source-map-include-sources-content false}
:exports-var census.core/census}
:geo {:target :node-library
:output-dir "public/geo"
:output-to "public/geo/batch_convert.js"
:compiler-options {:optimizations :simple}
:exports-var configs.geojson.core/batch_convert}}}(ns configs.geojson.core
(:require
[cljs.core.async :refer [>! <! chan promise-chan close! take! put! pipeline-async]
:refer-macros [go go-loop]]
[cuerdas.core :refer [join]
:as s]
[clojure.set :refer [map-invert]]
[defun.core :refer-macros [defun]]
[cljs-promises.async :refer [value-port]] ;; Fixme: Need this dependecy -< move configs to separate project
[census.utils.core :refer [map-target error err-type]]
[configs.utils.core :refer [read-edn FileSaver]]
[configs.geojson.filepaths2018 :refer [paths]]
[clojure.reader :refer [read-string]]
["fs" :as fs]
["shpjs" :as shpjs]
["mkdirp" :as mkdirp]))
(def geoKeyMap (read-edn "./src/configs/geojson/index.edn"))clj::shadow.user=> ; Creating cljs repl session... ; Connecting cljs repl: shadow-cljs... ; The Calva Connection Log might have more connection progress information. ; Connected session: cljs, repl: node-repl ; TIPS: You can choose which REPL to use (clj or cljs): ; *Calva: Toggle REPL connection* ; (There is a button in the status bar for this) cljs::cljs.user=> ; Evaluating file: core.cljs ; ------ WARNING - :redef -------------------------------------------------------- ; Resource: <eval>:16:1 resolve already refers to: cljs.core/resolve being replaced by: cljs-promises.core/resolve -------------------------------------------------------------------------------- nil cljs::configs.geojson.core=> #object[TypeError TypeError: Cannot read property 'core' of undefined] cljs::configs.geojson.core=>
node-repl I get the same no matterdefundefun? the warning is from cljs-promises? no clue what defun is?var AWS = AWSXRay.captureAWS(require('aws-sdk')); that example doesn't explain where AWSXRay is coming fromvar ddb = AWSXRay.captureAWSClient(new AWS.DynamoDB()); that doesn't explain where AWS is coming fromvar AWSXRay = require('aws-xray-sdk');
var AWS = AWSXRay.captureAWS(require('aws-sdk'));
var ddb = AWSXRay.captureAWSClient(new AWS.DynamoDB());(ns foo.bar
(:require
["aws-xray-sdk" :as aws-xray]
["aws-sdk" :as aws-sdk]))
(def aws (aws-xray/captureAWS aws-sdk))
(def ddb (aws-xray/captureAWSClient (aws.DynamoDB.)))resolve already refers to: cljs.core/resolve being replaced by: cljs-promises.core/resolve is the issue, when I remove that, smooth sailing. Is there a way to alias a function within a dependency like this?["aws-sdk" :as aws-sdk-clean] ; clean means without x-ray
["aws-xray-sdk" :as aws-xray-sdk]
then use this form to wrap the sdk with xray
(let [capture-full-sdk (j/get aws-xray-sdk :captureAWS)] (capture-full-sdk aws-sdk-clean))then you can use this let form to construct a service client where aws-sdk is the wrapped sdk
[s3-client (j/get aws-sdk :S3)
s3 (new s3-client)]
(:refer-clojure :exclude (resolve)) in the ns would fix it too^js hints whenever I want to interop with that object. Would there by another way that doesn’t require adding ^js everywhere?
(defonce ^:private remote-config
(atom nil))
(defn init! []
(reset! remote-config (firebase/remoteConfig))
(set! (.-settings ^js @remote-config)
#js {:minimumFetchIntervalMillis config/remote-config-fetch-interval})
(p/do!
(.ensureInitialized ^js @remote-config)
(.fetchAndActivate ^js @remote-config)))^js with a (let [^js cfg @remote-config] ...) and just operating on cfg but other than that I don't know of a way to typehint deref(def thing nil) (set! thing "something") should be fine?div with height: 100%. if I set that to 200px or so it displays the table just fine?index.html and app.css files in my public directory. I'd like to invoke that :static node target (which becomes resources/bin/static.js) during the normal :browser target live reload compilation. All of the generator code for producing the index and css files live in a namespace separate from my primary application, as I don't want that code ending up in the released app. I've tried every configuration trick I can find in the user manual:
+ :dev/before-load or :dev/after-load doesn't appear to work as the gen namespace isn't required by app (is my guess).
+ Adding a separate module (the generator ns) that depends on app ns. This nearly worked, but was invoking things in a cljs context which meant I didn't have access to write files to the system.
+ :build-hooks after :flush stage
Currently my shadow file looks like this:
{:deps {:aliases [:cljs]}
:builds
{:browser
{:target :browser
:modules {:app {:entries []}}
:output-dir "resources/public/js/my/app"
:asset-path "/js/my/app"
:devtools {:before-load my.gen/generate!
:after-load
:http-root "resources/public"
:http-port 43234}}
:static
{:target :node-script
:main my.gen/generate!
:output-to "resources/bin/static.js"
:compiler-options {:reader-features #{:node}}}}}
Anyone have any ideas?:flush hook of the :static builds. I'm assuming that also loads all the code the browser build is loading(:refer ["d3-hierarchy" :as d3])and call (.tree d3) which worked before, but now it says tree is not a function, and on inspection the d3 object is just an empty map. I cleaned, restarted the build, even re-installed all npm dependencies, but it didn't change it. Any idea how that might've happened?[nil] is not a valid hiccup form for a component in the same namespace, which by this point is literally just
(defn foo [] [:div "wtf"])
cljsjs/react-select in a reagent project (I'm pretty new to CLJS). The problem is, I get this: The required namespace "cljsjs.react-select" is not available, output from shadow-cljs. The dependencies in my shadow-cljs.edn file look like this:
:dependencies [[binaryage/devtools "1.0.0"]
[nrepl "0.7.0"]
[stylefy "2.2.1"]
[reagent "0.10.0"]
[cljsjs/react-select "2.4.4-0" :exclusions [cljsjs/react]]]
My require statement inside the reagent component looks like this:
(:require
[cljsjs.react-select]
[stylefy.core :as stylefy
:refer [use-style]]))
Does anyone have an idea of what I might be doing wrong---or an example of code working with cljs/react-select that I might be able to consult?cljsjs , check out this part of the docs: https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjsmodels/index.js file contains this:
// @ts-check
import { initSchema } from '@aws-amplify/datastore';
import { schema } from './schema';
const { Product, ListedProduct, List } = initSchema(schema);
export {
Product,
ListedProduct,
List
};
The schema file is a JavaScript file with lots of data…
export const schema = {
"models": {
"Product": {
In development I can require these models from Clojurescript with (:require ["../models/index" :as model]) , and things like model/Product work just fine.
In production, with advanced compilation, the value of model/Product is undefined. In fact, all three of the models I'm playing with are undefined.
(js/console.log "Models:" #js {:List model/List
:ListedProduct model/ListedProduct
:Product model/Product})
That logs this in Firefox:
Models:
{…}
List: undefined
ListedProduct: undefined
Product: undefined
<prototype>: Object { … }
grocer.cljs:272:48DataStore it provides, but given these vars resolve to nothing…j/get-in or somodel/Product get renamed consistently though?js-interop in places, and I looked at adding simple externs."Product" (as in a String)(ns foo (:require ["../models" :as models])) (.subscribe DataStore models/Product)
(.subscribe DataStore (j/get-in models :Product))?models/Productexterns/<build>.txt I need to add something like this?
# Fix Amplify's models being undefined :) models/Product
Productecho ... into a file and mint a release build now. :+1:node-repl instead.shadow-cljs node-repl will launch it as will (shadow.cljs.devtools.api/node-repl) (from CLJ)ConjureShadowSelect asks for a build id that would be :node-repl (but it needs to be started elsewhere firstnode-repl, not :node-repl when selectingjs-joda via an npm module and my target is :browser. Unfortunately the js-joda code contains calls to the ES2016 feature .includes function (on Array) instead of indexOf which fails in IE11. I've tried all sorts of shadow-cljs config combinations wtihout any luck, e.g. :js-options {:babel-preset-config {:targets {:ie 11}} or :compiler-options {:rewrite-polyfills true} which I believe only writes polyfills for ES6+ anyway.:output-feature-set.includes properly:compiler-options {:force-library-injection #{"polyfill-name"}}:output-feature-set and other config options already, but I'll double check. Just to confirm, I don't need the babel-preset-config at all?includes call isn't being detected properly, as you say. For completeness, the offending lines in the third-party code are chained calls, so perhaps that makes it harder to detect https://github.com/js-joda/js-joda/blob/a1a635a7e4e506dfa7a9eedcc932571bdba9c1b2/packages/locale/src/format/cldr/CldrDateTimeTextProvider.js#L226:force-library-injection config key for now. Thanks!Object.values. The final shadow-cljs config was :compiler-options {:force-library-injection ["es6/array/includes" "es6/object/values"]}websocket.cljs:12 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.Any ideas how to overcome it?
:devtools {:use-document-protocol true}{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}
:login {:entries [vorstellung.login]}}}Warning: Potential Security Risk Ahead Firefox detected an issue and did not continue to . The website is either misconfigured or your computer clock is set to the wrong time. It's likely the website's certificate is expired, which prevents Firefox from connecting securely. If you visit this site, attackers could try to steal information like your passwords, emails, or credit card details.
base ❯ clj -A:dev:shadow-cljs release browser [:browser] Compiling ... npm package "react-transition-group" expected version "
:modules setup and their :depends-on config{:browser-core {:entries [core.browser]
:init-fn core.browser/main}
;; :view-checkout-payment-stage {:entries [view.checkout.payment-stage]
;; :depends-on #{:browser-core}},
:view-ui-cms-tooltip {:entries [view.ui.cms-tooltip]
:depends-on #{:browser-core}}
;; :view-checkout-delivery-stage {:entries [view.checkout.delivery-stage]
;; :depends-on #{:browser-core}}
:view-rich-content {:entries [view.rich-content]
:depends-on #{:browser-core}}
:view-debug-page {:entries [view.debug-page]
:depends-on #{:browser-core}}
:view-ui-hero {:entries [view.ui.hero]
:depends-on #{:browser-core}}
:view-product-lists {:entries [view.product-lists]
:depends-on #{:browser-core}}
:view-about-pages {:entries [view.about-pages]
:depends-on #{:browser-core :view-reservation :view-vouchers}}
:view-sis {:entries [view.sis]
:depends-on #{:browser-core :view-action-pages}}
:view-lps-pages {:entries [view.lps-pages]
:depends-on #{:browser-core}}
:view-help-forum {:entries [view.help-forum]
:depends-on #{:browser-core}}
:view-membership-gifts {:entries [view.membership.gifts]
:depends-on #{:browser-core :view-membership-common}}
:view-wines-factory {:entries [view.wines-factory]
:depends-on #{:browser-core}}
:view-newsletter {:entries [view.newsletter]
:depends-on #{:browser-core}}
:view-recipe {:entries [view.recipe]
:depends-on #{:browser-core}}
:view-settings {:entries [view.settings]
:depends-on #{:browser-core :view-checkout-payment}}
:view-notification {:entries [view.notification]
:depends-on #{:browser-core}}
:view-cards {:entries [view.cards]
:depends-on #{:browser-core}}
:view-action-pages {:entries [view.action-pages]
:depends-on #{:browser-core}}
:view-promo-pages {:entries [view.promo-pages]
:depends-on #{:browser-core}}
:view-office-page {:entries [view.office-page]
:depends-on #{:browser-core}}
:view-lp-affilation-page {:entries [view.lp.affilation-page]
:depends-on #{:browser-core}}
:view-new-brand-shop {:entries [view.new-brand-shop]
:depends-on #{:browser-core}}
:view-membership-common {:entries [view.membership.common]
:depends-on #{:browser-core}}
:view-reservation {:entries [view.reservation]
:depends-on #{:browser-core :view-vouchers}}
:view-membership-rebate {:entries [view.membership.rebate]
:depends-on #{:browser-core :view-product-lists :view-membership-common}}
:view-rodo {:entries [view.rodo]
:depends-on #{:browser-core}}
:view-brand-shops {:entries [view.brand-shops]
:depends-on #{:browser-core}}
:view-brandbank {:entries [view.brandbank]
:depends-on #{:browser-core}}
:view-membership-banner {:entries [view.membership.banner]
:depends-on #{:browser-core :view-membership-common}}
:view-lp-membership {:entries [view.lp.membership]
:depends-on #{:browser-core :view-ui-hero :view-lps-pages :view-membership-common :view-membership-banner}}
:view-checkout {:entries [view.checkout]
:depends-on #{:browser-core :view-product-lists :view-settings}}
:view-importer {:entries [view.importer]
:depends-on #{:browser-core}}
:view-survey {:entries [view.survey]
:depends-on #{:browser-core}}
;; :view-lp-fruits-and-vegs {:entries [view.lp.fruits-and-vegs]
;; :depends-on #{:browser-core}}
:view-cart {:entries [view.cart]
:depends-on #{:browser-core :view-product-lists}}
:view-page-logged-in {:entries [view.page.logged-in]
:depends-on #{:browser-core}}
:view-checkout-payment {:entries [view.checkout.payment]
:depends-on #{:browser-core}}
:view-login {:entries [view.login]
:depends-on #{:browser-core}}
;; :view-checkout-products-stage {:entries [view.checkout.products-stage]
;; :depends-on #{:browser-core}}
:view-mailing {:entries [view.mailing]
:depends-on #{:browser-core}}
:view-ui-video-player {:entries [view.ui.video-player]
:depends-on #{:browser-core}}
:view-cart-promotions {:entries [view.cart-promotions]
:depends-on #{:browser-core :view-vouchers}}
:view-shopping-lists {:entries [view.shopping-lists]
:depends-on #{:browser-core :view-product-lists}}
:view-products-product-page {:entries [view.products.product-page]
:depends-on #{:browser-core}}
:view-contest {:entries [view.contest]
:depends-on #{:browser-core}}
:view-lp-ready-meals-page {:entries [view.lp.ready-meals-page]
:depends-on #{:browser-core :view-ui-hero :view-product-lists :view-lps-pages :view-settings :view-reservation :view-checkout :view-checkout-payment}}
:view-email-preview {:entries [view.email-preview]
:depends-on #{:browser-core}}
:view-lp-business-page {:entries [view.lp.business-page]
:depends-on #{:browser-core :view-ui-hero :view-rodo}}
:view-vouchers {:entries [view.vouchers]
:depends-on #{:browser-core}}}{:browser-core {:entries [core.browser]
:init-fn core.browser/main}
:shared {:depends-on #{:browser-core}}
;; :view-checkout-payment-stage {:entries [view.checkout.payment-stage]
;; :depends-on #{:browser-core}},
:view-ui-cms-tooltip {:entries [view.ui.cms-tooltip]
:depends-on #{:shared}
}
;; :view-checkout-delivery-stage {:entries [view.checkout.delivery-stage]
;; :depends-on #{:shared}}
:view-rich-content {:entries [view.rich-content]
:depends-on #{:shared}}
:view-debug-page {:entries [view.debug-page]
:depends-on #{:shared}}
:view-ui-hero {:entries [view.ui.hero]
:depends-on #{:shared}}
:view-product-lists {:entries [view.product-lists]
:depends-on #{:shared}}
:view-about-pages {:entries [view.about-pages]
:depends-on #{:shared :view-reservation :view-vouchers}}
:view-sis {:entries [view.sis]
:depends-on #{:shared :view-action-pages}}
:view-lps-pages {:entries [view.lps-pages]
:depends-on #{:shared}}
:view-help-forum {:entries [view.help-forum]
:depends-on #{:shared}}
:view-membership-gifts {:entries [view.membership.gifts]
:depends-on #{:shared :view-membership-common}}
:view-wines-factory {:entries [view.wines-factory]
:depends-on #{:shared}}
:view-newsletter {:entries [view.newsletter]
:depends-on #{:shared}}
:view-recipe {:entries [view.recipe]
:depends-on #{:shared}}
:view-settings {:entries [view.settings]
:depends-on #{:shared :view-checkout-payment}}
:view-notification {:entries [view.notification]
:depends-on #{:shared}}
:view-cards {:entries [view.cards]
:depends-on #{:shared}}
:view-action-pages {:entries [view.action-pages]
:depends-on #{:shared}}
:view-promo-pages {:entries [view.promo-pages]
:depends-on #{:shared}}
:view-office-page {:entries [view.office-page]
:depends-on #{:shared}}
:view-lp-affilation-page {:entries [view.lp.affilation-page]
:depends-on #{:shared}}
:view-new-brand-shop {:entries [view.new-brand-shop]
:depends-on #{:shared}}
:view-membership-common {:entries [view.membership.common]
:depends-on #{:shared}}
:view-reservation {:entries [view.reservation]
:depends-on #{:shared :view-vouchers}}
:view-membership-rebate {:entries [view.membership.rebate]
:depends-on #{:shared :view-product-lists :view-membership-common}}
:view-rodo {:entries [view.rodo]
:depends-on #{:shared}}
:view-brand-shops {:entries [view.brand-shops]
:depends-on #{:shared}}
:view-brandbank {:entries [view.brandbank]
:depends-on #{:shared}}
:view-membership-banner {:entries [view.membership.banner]
:depends-on #{:shared :view-membership-common}}
:view-lp-membership {:entries [view.lp.membership]
:depends-on #{:shared :view-ui-hero :view-lps-pages :view-membership-common :view-membership-banner}}
:view-checkout {:entries [view.checkout]
:depends-on #{:shared :view-product-lists :view-settings}}
:view-importer {:entries [view.importer]
:depends-on #{:shared}}
:view-survey {:entries [view.survey]
:depends-on #{:shared}}
;; :view-lp-fruits-and-vegs {:entries [view.lp.fruits-and-vegs]
;; :depends-on #{:shared}}
:view-cart {:entries [view.cart]
:depends-on #{:shared :view-product-lists}}
:view-page-logged-in {:entries [view.page.logged-in]
:depends-on #{:shared}}
:view-checkout-payment {:entries [view.checkout.payment]
:depends-on #{:shared}}
:view-login {:entries [view.login]
:depends-on #{:shared}}
;; :view-checkout-products-stage {:entries [view.checkout.products-stage]
;; :depends-on #{:browser-core}}
:view-mailing {:entries [view.mailing]
:depends-on #{:browser-core}}
:view-ui-video-player {:entries [view.ui.video-player]
:depends-on #{:browser-core}}
:view-cart-promotions {:entries [view.cart-promotions]
:depends-on #{:browser-core :view-vouchers}}
:view-shopping-lists {:entries [view.shopping-lists]
:depends-on #{:browser-core :view-product-lists}}
:view-products-product-page {:entries [view.products.product-page]
:depends-on #{:browser-core}}
:view-contest {:entries [view.contest]
:depends-on #{:browser-core}}
:view-lp-ready-meals-page {:entries [view.lp.ready-meals-page]
:depends-on #{:browser-core :view-ui-hero :view-product-lists :view-lps-pages :view-settings :view-reservation :view-checkout :view-checkout-payment}}
:view-email-preview {:entries [view.email-preview]
:depends-on #{:browser-core}}
:view-lp-business-page {:entries [view.lp.business-page]
:depends-on #{:browser-core :view-ui-hero :view-rodo}}
:view-vouchers {:entries [view.vouchers]
:depends-on #{:browser-core}}}Cannot infer target type in expression (. (. BigJSHandler -prototype) -rep)For this deftype
(deftype BigJSHandler [] Object (tag [this v] "bigjs") (rep [this ^js/Big v] (.toFixed v)) (stringRep [this v] nil))
(deftype ^js BigJSHandler ...) fixes it. otherwise you can also set (set! *warn-on-infer* false) before and true after to silence it for now^js worked perfectly. Also this externs worked too
var Object = function() {};
Object.prototype.tag = function() {};
Object.prototype.rep = function() {};
Object.prototype.stringRep = function() {};net::ERR_CONNECTION_REFUSED whenever I start the server. Has anyone encountered this error before with shadow-cljs?
I ask here because the terminal spat out an error that pointed to some shadow-cljs code.shadow.cljs.devtools.client.websocket
line 12. Still looking into it though. It seems like anything could cause this which is worrisome.:target :esm does what you need in release mode or any of the node stuff. just don't expect watch or compile to work. release output might work.figma one.
Currently I got the UI one working fine by having shadow-cljs output a npm-module that I'm including in a "vanilla JS" file, then webpack packs it + index.html into a single file with the JS embedded.
Having harder time getting the "code" context to work, as output from shadow-cljs (cljs-compiler maybe?) is either assuming it's in a browser OR nodejs context while in "code" context, neither global, process nor window is available:target :browser may work too, but again just in releasecompile or watch it will definitely try to access all of thoserelease a try, didn't try it before with the :browser target. Thanks for the guidance!compile for the "Figma UI target" and release for the "Figma background target", and using the :browser target for both. Thanks for the help!:ui-dev build you do not need:ui build is old since its still :npm-module?:target :figma-plugin or so that takes care of some of the messiness:figma-plugin target(defn dev-render-root {:dev/after-load true} []
(shadow/render-root "DcnetApp" (r/as-element [app-root]))
)
it’s called after I update the code, as expected
[Sun Oct 04 2020 19:17:50.501] LOG load JS dcnet_app/screens/home.cljs [Sun Oct 04 2020 19:17:50.507] LOG load JS dcnet_app/appnav.cljs [Sun Oct 04 2020 19:17:50.508] LOG call dcnet-app.ios.core/dev-render-rootbut the screen doesn’t get updated. anything else I might be missing?
.forceUpdate and updating ratom within the root component).
It does trigger re-rendering, but still displays old version of the code. I’ll let you know if I figure it out.src/add.js (`module.exports = add`) and this CLJS code in src/habit/core.cljs:
(ns habit.core
(:require [moment]
["/add" :as add]
))
(println (add 1 2))
(defn main []
(println "hi"))
With this shadow-cljs.edn:
{:source-paths
["src/"]
:dependencies
[]
:builds
{:m
{:target :node-script
:main habit.core/main
:output-to "out/core.js"
}}}
I then run sc cljs-repl m and node out/core.js which outputs "3" and "hi". However, in the repl, I get this error when trying to access add : #object[ReferenceError ReferenceError: module$add is not defined] . I can access moment fine. What am I doing wrong?ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
I keep getting these on shadow-cljs watchClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
clojure.core/namespace (core.clj:1597)
clojure.core/namespace (core.clj:1597)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:155)
shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:147)
cljs.analyzer/resolve-existing-var (analyzer.cljc:1276)
cljs.analyzer/resolve-existing-var (analyzer.cljc:1271)
cljs.compiler/fn--9175 (cljs_hacks.cljc:740)
cljs.compiler/fn--9175 (cljs_hacks.cljc:717)(:require ["@shoelace-style/shoelace" :refer [SlButton]]) and
(:requre ["@shoelace-style/shoelace" :as sl]) and I end up with nil for SlButton or sl/SlButtontools.namespace?:entries [the.ns]npx — shadowcljs 2.11.4 is specified in the package.json(:requre ["@shoelace-style/shoelace" :default SLButton])(:require ["@shoelace-style/shoelace/dist/custom-elements/index.js" :refer [defineCustomElements setAssetPath SlButton]])It ends up with an html custom element (web component) now I still have to figure out how to access the element after doing:
(.define js/customElements "sl-button" SlButton)SlButton is defined as a class, but
sl-button is not defined. I probably just need to learn more how web components work with reagent.[:sl-button ...] like any other regular dom element:refer and stuff may not actually exist because you don't need it if it already self-registers: Now that I try that, it
does inject <sl-button>… into the DOM now, but I’m getting a
Uncaught ReferenceError: regeneratorRuntime is not defined
index.js:2654 Uncaught ReferenceError: regeneratorRuntime is not defined
at initializeComponent (index.js:2654)
at _connectedCallback (index.js:2944)
at HTMLElement.connectedCallback (index.js:3049)
at commitPlacement (react-dom.development.js:8835)
at commitAllHostEffects (react-dom.development.js:18656)
at HTMLUnknownElement.callCallback (react-dom.development.js:150)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
at invokeGuardedCallback (react-dom.development.js:257)
at commitRoot (react-dom.development.js:18914)
at eval (react-dom.development.js:20419)
But at least that is something I can track down now hopefully.
Thanks again for your help!
Oh, I didn’t try with theregenerator-runtime might be enough(:require ["regenerator-runtime"]) should do it in case you didn't try .. you said "refer" which would be incorrectnpm install regenerator-runtime first of course)(:require ["regenerator-runtime"])`` works great. Preferred to <script> tag Thanks again!watch and release? Basically just want a way of running release every time the files change. watch will call compile on file change, as I understand it, so if there is a way of getting it to run release instead?watchman-make you can do anything you want after files are changed e.g. watchman-make -p './src/***/**.cljs' -t release https://facebook.github.io/watchman/docs/watchman-make.htmlrelease would be a target in your Makefile to run shadow-cljs release {target} )inotifywait route as I already had that installed and didn't need to download anything new 🙂*:ignore-warnings`*` option in shadow-cljs that defaults to false. shadow-cljs should already avoid compiling when there is warnings, but you can set :ignore-warnings to true to compile anyways (which might lead to breakage). I know you mentioned compilation errors, but I do think Bruce talks about compilation warnings, not errorswarn-on-reflection ?
I mean, to be "super safe" about to access .-props:js-options {:babel-preset-config { ... }}? I'm trying to enable polyfills for IE11.:compiler-options {:output-feature-set :es5} (which is the default):es3:compiler-options, instead of :babel-preset-config, because my project probably don't have such npm packages. Thanks for your answer, I'll try it.release only$ yarn run shadow-cljs compile lambda --verbose shadow-cljs - config: /home/jcf/code/example/shadow-cljs.edn Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true [:lambda] Compiling ... -> build target: :node-library stage: :configure <- build target: :node-library stage: :configure (3 ms) -> Resolving Module: :mainWith both
release and compile I get this error after the output above:
The required namespace "example.lambda" is not available, it was required by "shadow/umd_helper.cljs".I've found a GitHub issue related to generating single files, with a recommendation to use
ncc to package everything into a single file, which I can do as soon as I have something compiling.
My build looks like this:
{:builds
{:lambda
{:deps {:aliases [:lambda]}
:output-to "amplify/backend/function/example/src/index.js"
:target :node-library
:exports {:handler example.lambda/handler}
:devtools {:enabled false}
:compiler-options {:infer-externs :auto
:source-map true}}}}
I've triple checked the namespace and path to my namespace and it's very correct (I've copied and pasted the name back and forth to be doubly sure).$ yarn run shadow-cljs compile lambda --verbose shadow-cljs - config: /home/jcf/code/example/shadow-cljs.edn Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true [:lambda] Compiling ... -> build target: :node-library stage: :configure <- build target: :node-library stage: :configure (3 ms) -> Resolving Module: :mainWith both
release and compile I get this error after the output above:
The required namespace "example.lambda" is not available, it was required by "shadow/umd_helper.cljs".I've found a GitHub issue related to generating single files, with a recommendation to use
ncc to package everything into a single file, which I can do as soon as I have something compiling.
My build looks like this:
{:builds
{:lambda
{:deps {:aliases [:lambda]}
:output-to "amplify/backend/function/example/src/index.js"
:target :node-library
:exports {:handler example.lambda/handler}
:devtools {:enabled false}
:compiler-options {:infer-externs :auto
:source-map true}}}}
I've triple checked the namespace and path to my namespace and it's very correct (I've copied and pasted the name back and forth to be doubly sure).deps.edn I have an alias that sets :paths ["src"]…:node-library that I can package up with ncc I'd be extremely grateful./home/jcf/code/example/src/example/lambda.cljs. make sure it actually exists. the :deps inside :builds is incorrect. it is supposed to be at the top level/home/jcf/code/example/src/example/lambda.cljs. make sure it actually exists. the :deps inside :builds is incorrect. it is supposed to be at the top level:deps could be nested. I want to use different dependencies for different builds, and went for :aliases…:deps or is it to do with source paths (e.g. src/cljs)?
I was trying to include a different set of third-party dependencies (my Lambda doesn’t need Rum) and have all my Clojure-like source collocated.:paths though:paths ["src"] in deps.edn is set correctly(defmacro deftags [& tags] `(do…in one NS, require it in another,
(ns mxweb.tag
(:require
[mxweb.gen :as gen]))
(gen/deftags a abbr acronym ...etc..)
…then a check reports
------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: mxweb/tag.cljc:5:2 Use of undeclared Var mxweb.gen/deftagsA conventional CLJS build using the
lein meis scripts works OK. Thx!:require-macros in the mxweb.gen ns for itself:require-macros in the using mxweb.tag NS and was seeing the same error. Thx to @U05224H0W’s blog post I see the linkage is a bit hairier than I realized and will give it another go. btw, I had everything in .cljcs, and will start by moving macros into a .clj just to reduce the unknowns.mies scripts. That worked OK, but I am curious about Shadow. One puzzle is that I do not have the macros in a .clj, which I do remember as a requirement! I guess the .cljc gives me the .clj compile for the macros? Anyway, I plan to KISS and move the macros into a .clj, then set things up as you have described. Thx!.cljc as far as CLJS macros are concerned are just two files in one. one for CLJ one for CLJS. the macro rules are exactly the same but IMHO it is much easier to follow those rules with two actual files instead of onedeftag generates a macro. 🙂 Results shortly…TypeError: Class constructor _o cannot be invoked without 'new' (ns myapp.core (:require ["@tonejs/piano" :refer (Piano)])) (Piano.)I had set :compiler-options :output-feature-set to :es6 with no luck. Any help appreciated. Thanks.
["^ ","~:op","~:access-denied"] . Any help would be appreciated.:es3, still no luck. IE throws exception about Object.assign.:compiler-options {:force-library-injection ["es6/object/assign"]}:build-options {:ns-aliases {from to}}shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.8.110 running at
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
File: /home/nas/proiecte/homebank-ofx/src/main/netdava/homebank/app/hello.cljs
no source by provide: recom.core
{:provide recom.core}
ExceptionInfo: no source by provide: recom.core
shadow.build.data/get-source-id-by-provide (data.clj:186)
shadow.build.data/get-source-id-by-provide (data.clj:183)
shadow.build.data/get-source-by-provide (data.clj:189)
shadow.build.data/get-source-by-provide (data.clj:188)
shadow.build.compiler/fn--11892 (compiler.clj:340)
shadow.build.compiler/fn--11892 (compiler.clj:322)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.build.compiler/do-compile-cljs-resource/fn--11967/fn--11976 (compiler.clj:623)
shadow.build.compiler/do-compile-cljs-resource/fn--11967 (compiler.clj:618)
shadow.build.compiler/do-compile-cljs-resource (compiler.clj:562)
shadow.build.compiler/do-compile-cljs-resource (compiler.clj:520)
shadow.build.compiler/maybe-compile-cljs/fn--12065 (compiler.clj:897)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:896)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:872)
shadow.build.compiler/par-compile-one (compiler.clj:1005)
shadow.build.compiler/par-compile-one (compiler.clj:960)
shadow.build.compiler/par-compile-cljs-sources/fn--12101/iter--12123--12127/fn--12128/fn--12129/fn--12130 (compiler.clj:1078)
clojure.core/apply (core.clj:665)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/with-bindings* (core.clj:1973)
clojure.core/apply (core.clj:669)
clojure.core/bound-fn*/fn--5749 (core.clj:2003)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
java.lang.Thread.run (Thread.java:834)
Here is my shadow-cljs.edn:
{:builds
{:app {:asset-path "/js"
:modules {:main {:init-fn netdava.homebank.app.core/main}}
:output-dir "public/js"
:target :browser}
:csv2json {:target :node-library
:output-to "csv2json.js"
:output-dir "out/csv2json-lib"
:exports-fn netdava.homebank.csv/generate-exports}
:parse-demo {:target :node-script
:main netdava.homebank.csv-demo/main
:output-to "out/parse-demo.js"}
:dir-converter {:target :node-script
:main netdava.homebank.dir-converter/main
:output-to "out/dir-converter.js"}
:test {:ns-regexp "-nodetest$"
:output-to "out/test.js"
:target :node-test
:compiler-options {:infer-externs :auto}}
:ci {:target :karma
:output-to "out/ci.js"
:ns-regexp "-test$"}}
:dependencies [[bux "0.3.0"]
[devcards "0.2.6"]
[re-com "2.9.0"]
[reagent "0.8.1"]]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src/main" "src/csv2json" "src/test"]}
thanks in advance.re-com.core not recom.core?component.cljs:127 Error rendering component (in netdava.homebank.app.hello.converter > > > > re_com.buttons.button) reagent$impl$component$do_render @ component.cljs:127 eval @ component.cljs:143 reagent$ratom$in_context @ ratom.cljs:37 reagent$ratom$deref_capture @ ratom.cljs:43 reagent$ratom$run_in_reaction @ ratom.cljs:504 netdava.homebank.app.hello.convert_btn_render @ component.cljs:143 finishClassComponent @ react-dom.development.js:14742 updateClassComponent @ react-dom.development.js:14697 beginWork @ react-dom.development.js:15645 performUnitOfWork @ react-dom.development.js:19313 workLoop @ react-dom.development.js:19353 callCallback @ react-dom.development.js:150 invokeGuardedCallbackImpl @ react-dom.development.js:200 invokeGuardedCallback @ react-dom.development.js:257 replayUnitOfWork @ react-dom.development.js:18579 renderRoot @ react-dom.development.js:19469 performWorkOnRoot @ react-dom.development.js:20343 performWork @ react-dom.development.js:20255 requestWork @ react-dom.development.js:20229 scheduleWork @ react-dom.development.js:19912 updateContainerAtExpirationTime @ react-dom.development.js:20573 updateContainer @ react-dom.development.js:20658 ReactRoot.render @ react-dom.development.js:20954 eval @ react-dom.development.js:21091 unbatchedUpdates @ react-dom.development.js:20460 legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087 render @ react-dom.development.js:21156 reagent$dom$render_comp @ dom.cljs:21 eval @ dom.cljs:44 eval @ dom.cljs:39 eval @ core.cljs:74 netdava$homebank$app$core$render @ core.cljs:20 netdava$homebank$app$core$main @ core.cljs:25 eval @ shadow.module.main.append.js:4 goog.globalEval @ main.js:577 env.evalLoad @ main.js:1670 (anonymous) @ main.js:1941
main.js:1673 TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
at eval (validate.cljs:87)
at validate_arg (validate.cljs:87)
at eval (core.cljs:4736)
at eval (core.cljs:4736)
at Object.eval [as sval] (core.cljs:3439)
at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3496)
at Object.cljs$core$seq [as seq] (core.cljs:1234)
at Object.cljs$core$every_QMARK_ [as every_QMARK_] (core.cljs:4239)
at Object.re_com$validate$validate_fns_pass_QMARK_ [as validate_fns_pass_QMARK_] (validate.cljs:102)
at Function.eval [as cljs$core$IFn$_invoke$arity$variadic] (validate.cljs:117)
[thing {:foo "bar"}] where thing is undefined or sore-frame-template to obtain a working re-com appSHADOW import error <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js
App threw an error during load
<DIR>/node_modules/electron-store/index.js:13
...options
^^^
SyntaxError: Unexpected token ...
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js:3:40
at global.SHADOW_IMPORT (<DIR>/resources/main.js:64:44)
shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[re-frame "1.1.1"]
[cider/cider-nrepl "0.21.0"]]
:dev-http {8080 "resources/public/"}
:builds {:main {:target :node-script
:output-to "resources/main.js"
:main app.main.core/main}
:renderer {:target :browser
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:init-fn app.renderer.core/start!}}}}}
package.json
{
"name": "placeholder",
"version": "1.0.0",
"description": "placeholder",
"main": "resources/main.js",
"scripts": {
"dev": "./node_modules/.bin/shadow-cljs watch main renderer",
"build": "./node_modules/.bin/shadow-cljs compile main renderer",
"clean": "rm -rf resources/public/js/* && rm -rf target"
},
"keywords": [
"shadow-cljs",
"reagent",
"electron"
],
"author": "placeholder",
"devDependencies": {
"electron": "^10.1.3",
"shadow-cljs": "^2.11.5"
},
"dependencies": {
"@material-ui/core": "^4.11.0",
"create-react-class": "^15.6.3",
"electron-store": "^6.0.1",
"normalize.css": "^8.0.1",
"react": "^16.13.0",
"react-dom": "^16.13.0"
}
}node and then require("electron-store"). that should give you the same error.vm.runInThisContext call from Node with a spread operator (as thats the command in shadow-cljs thats choking) I dont have any issues. So it seems to be just from the context of shadow-cljs that its barfing. I'm going to dig into electron a bit and see if it does anything special to node or the vm that might effect this, but otherwise still a little stumped. Anyhow, thanks for your help here I really appreciate it.shadow.js.shim.module$electron_store.js is literally only doing require("electron-store") and the failure is in that file. shadow-cljs has not processed that file in any way and it is just up to electron fulfilling that require.:module-loader true
:modules {:base {:entries [app.debug app.auth]}
:common {:entries [app.index]
:depends-on #{:base}}
:app {:init-fn app.main/init!
:depends-on #{:common}}
:cloud {:entries [app.main.cloud]
:depends-on #{:app}}}:cloud {:entities?;; app/main.cljs
(defn init! []
(loader/with-module :cloud
(fn []
(let [cloud (resolve 'app.main.cloud/dashboard)]
(cloud)))))failed to load clojure.set.js Error: Namespace "clojure.set" already declared.with-module?(-> (loader/load :cloud) (.then (fn [] ...))with-module is forresolve issues(def components
(lazy/loadable {:cloud app.main.cloud/dashboard)})
(defn init! []
(-> (lazy/load components)
(.then
(fn [{:keys [cloud]}]
(cloud)))))base.js:2226 failed to load goog.dom.inputtype.js Error: Namespace "goog.dom.InputType" already declared.(js/setTimeout (fn [] _here_ ) 0) or so{:type :dtd, :data ["html" nil nil]}./client as the path. much more predictable if you use absolute paths with the proper absolute :asset-path as wellFAIL in (my-test) (module1/file_test.cljs:31:13)The problem is that I cannot click on the file path in the terminal and open the file directly, since it's missing the "src/test/" at the beginning
cider.piggieback, which I've read shadow-cljs doesn't use at all. I'm using cider-jack-in-cljs with both :deps and :nrepl in my shadow-cljs.edn:
{:deps {:aliases [:client]}
:nrepl {:port 8777}
,,,}
I've tried adding Cider deps to my deps.edn even though Cider injects its deps/middleware for me:
/usr/bin/clojure -A:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
I haven't tried adding my client alias to my global CLI opts because I don't want browser-based dependencies being loaded in a server REPL but if that's the problem I can probably juggle things around.
I've also read in a GitHub issue that use of :dependencies is recommended over use of :deps but that's on an old issue and I can't find any mention of such a recommendation in the shadow-cljs user guide.
I keep reading that it's a simple as running cider-jack-in-cljs so I'm feeling a little dumb I guess. :shrug:.dir-locals.el contains this:
((nil
(cider-clojure-cli-global-options . "-A:dev:test")
(cider-default-cljs-repl . shadow-select)
(cider-known-endpoints . (("localhost" "8777")))
(cider-shadow-default-options . ":REDACTED")
(cider-preferred-build-tool . clojure-cli)))
{:clojure.main/message
"Execution error at nrepl.cmdline/require-and-resolve (cmdline.clj:195).\nNo namespace: cider.piggieback found\n",
:clojure.main/triage
{:clojure.error/class java.lang.Exception,
:clojure.error/line 195,
:clojure.error/cause "No namespace: cider.piggieback found",
:clojure.error/symbol nrepl.cmdline/require-and-resolve,
:clojure.error/source "cmdline.clj",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.lang.Exception,
:message "No namespace: cider.piggieback found",
:at [clojure.core$the_ns invokeStatic "core.clj" 4162]}],
:trace
[[clojure.core$the_ns invokeStatic "core.clj" 4162]
[clojure.core$ns_resolve invokeStatic "core.clj" 4369]
[clojure.core$ns_resolve invokeStatic "core.clj" 4359]
[clojure.core$ns_resolve invoke "core.clj" 4359]
[nrepl.cmdline$require_and_resolve invokeStatic "cmdline.clj" 195]
[nrepl.cmdline$require_and_resolve invoke "cmdline.clj" 185]
[nrepl.cmdline$fn__3236 invokeStatic "cmdline.clj" 199]
[nrepl.cmdline$fn__3236 invoke "cmdline.clj" 199]
[clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
[clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
[clojure.lang.PersistentVector reduce "PersistentVector.java" 343]
[clojure.core$transduce invokeStatic "core.clj" 6883]
[clojure.core$into invokeStatic "core.clj" 6899]
[clojure.core$into invoke "core.clj" 6887]
[nrepl.cmdline$__GT_mw_list invokeStatic "cmdline.clj" 226]
[nrepl.cmdline$__GT_mw_list invoke "cmdline.clj" 224]
[nrepl.cmdline$build_handler invokeStatic "cmdline.clj" 235]
[nrepl.cmdline$build_handler invoke "cmdline.clj" 228]
[nrepl.cmdline$options__GT_handler invokeStatic "cmdline.clj" 304]
[nrepl.cmdline$options__GT_handler invoke "cmdline.clj" 295]
[nrepl.cmdline$server_opts invokeStatic "cmdline.clj" 352]
[nrepl.cmdline$server_opts invoke "cmdline.clj" 340]
[nrepl.cmdline$dispatch_commands invokeStatic "cmdline.clj" 443]
[nrepl.cmdline$dispatch_commands invoke "cmdline.clj" 436]
[nrepl.cmdline$_main invokeStatic "cmdline.clj" 459]
[nrepl.cmdline$_main doInvoke "cmdline.clj" 454]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 665]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause "No namespace: cider.piggieback found"}}
Stacktrace hidden in a file by Clojure. 👆shadow-cljs server or so and then connect remotely to 8777 (however you do that I don't know though)clojure call above doesn't seem to be using shadow-cljsshadow-cljs watch process but I get errors about middleware being missing. I've added the middleware to my deps.edn and get the same errors.;; Connected to nREPL server - ;; CIDER 0.26.1 (Nesebar), nREPL 0.7.0 ;; Clojure 1.10.1, Java 14.0.2 ;; Docs: (doc function-name) ;; (find-doc part-of-name) ;; Source: (source function-name) ;; Javadoc: (javadoc java-object-or-class) ;; Exit: <C-c C-q> ;; Results: Stored in vars *1, *2, *3, an exception in *e; ;; ;; ClojureScript REPL type: shadow-select ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :REDACTED)) ;; WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information) To quit, type: :cljs/quit ;; => [:selected :REDACTED]WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.0 and n/a, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user> cljs.user>
deps.edn?:client alias:
cider/cider-nrepl {:mvn/version "0.25.4"}
refactor-nrepl/refactor-nrepl {:mvn/version "2.5.0"}
And now Cider tells me this:
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
~/.config/clojure/deps.edn and made sure there's no ~/.clojure/deps.edn. Where this snapshot version of Cider is coming from, I'm unsure.deps.edn are ignored…:aliases
:client
:extra-deps
applied-science/js-interop {:mvn/version "0.2.7"}
cider/cider-nrepl {:mvn/version "0.25.4"}deps.edn file. 😄0.25.3 and you have 0.25.4 so that might be the problem tooclojure -A:client -Stree or whatever the command was to list the tree. maybe that explains wheres its coming from/usr/bin/clojure -A:dev:test:client alias you setup?shadow-cljs.edn file I have :deps {:aliases [:client]} …
Do I need the initial invocation of Clojure to include :client too?Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
DEPRECATED: Libs must be qualified, change compliment => compliment/compliment
DEPRECATED: Libs must be qualified, change nrepl => nrepl/nrepl
DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl
WARNING: When invoking clojure.main, use -M
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
nREPL server started on port 33897 on host localhost.localdomain -
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by dynapath.defaults$eval29666$fn__29667 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of dynapath.defaults$eval29666$fn__29667
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
;; Connected to nREPL server -
;; CIDER 0.26.1 (Nesebar), nREPL 0.8.0
;; Clojure 1.10.1, Java 14.0.2
;; Docs: (doc function-name)
;; (find-doc part-of-name)
;; Source: (source function-name)
;; Javadoc: (javadoc java-object-or-class)
;; Exit: <C-c C-q>
;; Results: Stored in vars *1, *2, *3, an exception in *e;
;; Startup: /usr/bin/clojure -A:client:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
;;
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :grocer))
;;
;; => :missing-nrepl-middlewareuser>
user> :client to my CLI opts.cider-jack-in-cljs-nrepl-middlewares var that takes a list of strings from the looks of it.cider-jack-in-cljs-nrepl-middlewares is a variable defined in
cider.el.
Value
("cider.piggieback/wrap-cljs-repl")
Set
Documentation
List of Clojure variable names.wrap-cljs-repl with shadow-cljs, right? I thought I read that shadow provides its own middleware.Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information) To quit, type: :cljs/quit ;; => [:selected :grocer]No available JS runtime. See >🙂
(js/alert "Hi, there!").:fs-watch {:polling true} in shadow-cljs.edn makes it work{:nrepl {:port 8777}
:source-paths ["src/cljs"]
:fs-watch {:polling true}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn mui.core/init}}
:autobuild true
:devtools {:http-root "resources/public"
:http-port 8280
:autobuild true
:preloads [devtools.preload]}}}
:devtools {:after-load mui.core/start}}
Is it correct?:fs-watch map?:polling true doesn't actually do anything since it is a hawk only option 😛shadow.cljs.devtools.server.fs-watch file
- (if (and (str/includes? os-name "Mac") (not (false? (:hawk config)))) + (if (not (false? (:hawk config)))and config
:fs-watch {:watcher :polling
:hawk true}
After these changes, hot reloading finally started to work!:hawk true(str/includes? os-name "Mac") precondition.lein new re-frame demorf +ciderand then
lein depsand
npm installand then running in emacs
cider-jack-in-cljsI got a user> prompt, but attempting to eval the :require statement in core.cljs with
cider-eval-defun-at-pointgenerated
Unhandled java.io.FileNotFoundException Could not locate reagent/dom__init.class, reagent/dom.clj or reagent/dom.cljc on classpath.which I assume will apply to every dependency. How should I start troubleshooting this?
------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared
winjpc.js:145 TypeError: Cannot read property 'call' of undefined
at pa (winjpc.js:262):compiler-options {:infer-externs :auto} let's se if that does the trick...lein new reagent myapp +shadow-cljs generated project… I’m not sure I can do this in ClojureScript, actually.[:input.insit { :type "text"
:value rc
:auto-focus :true
:on-change (fn [e] (reset! email-input (.. e -target -value)))}][2020-10-17 01:50:37.230 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-1f3b9bdc.js", :requires [{:line 1630, :column 33}]}return Promise.resolve().then(function () {
return _interopNamespace(require(`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {...}, consoleError);Shadow-cljs - reconnecting message. it's noted in the repo that this was only tested on the windows platform, but maybe someone has an idea? (I also removed the Content-Security-Policy part)ERR_CLEARTEXT_NOT_PERMITTED . I then added a rule in my config.xml to fix this. Now I have an ERR_CONNECTION_REFUSED error. Checking now if I need to add any extra rules or something.10.0.2.2 . So the solution is to add this to your shadow-cljs.edn devtools config: :devtools-url ""cordova-cljs repo, so other people don't have to bump their heads against the wall: https://github.com/thheller/cordova-cljs/pull/2:foreign-libs, but it sounds like that is not compatible with shadow-cljs.npx shadow-cljs server produce a .nrepl-port file?.shadow-cljs/nrepl.port.nrepl-port.shadow-cljs/nrepl.port(ns app (:require ["left-pad" :as left-pad])) ; Cursive loading the app.cljs ns in the repl: Loading src/main/app.cljs... Syntax error macroexpanding clojure.core/ns at (src/main/app.cljs:1:1). ((:require ["left-pad" :as left-pad])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
shadow/repl wasn't running. as always, thanks for your help:infer-warnings show up in the shadow-cljs hud? they show up in the stdout, but we’d like to see them in the hud as well:warnings-as-errors also treat :infer-warning as an error:warnings-as-errors?Parse error. illegal use of unknown JSDoc tag "pd"; ignoring itdoing a release build, when it gets to this line in a library I am using: https://github.com/ptaoussanis/tufte/blob/master/src/taoensso/tufte.cljc#L315 There is a comment with a code snippet ending @pd. ANy way to quiesce that? Not a big deal at all.
:npm-module should sort of work. :esm is sort of finished except for a "do not bundle X packages" setting I guess:target 's as plugins/extensions to shadow-cljs, to keep the core smaller and not having to implement everything in shadow-cljs. Something you thought about?:target accepts a symbol. so :target your.lib/my-target would call that function:target just expands to shadow.build.targets.<name-of-kw>/process:browser is by far the most complicated so can be hard to understand what is happeningNamespace "xxx" already declared . Happens for both esm and npm-module. I think i remember similar things happening a little while back when I tried to import cljs code from shadow in webpack.
Error: Namespace "cljs.core" already declared.
at Object.goog.provide (webpack-internal:///./dist/cljs/cljs-runtime/cljs_env.js:102:13)
at eval (webpack-internal:///./dist/cljs/cljs-runtime/cljs.core.js:4:6)
at Module../dist/cljs/cljs-runtime/cljs.core.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:199:1)
at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
at eval (webpack-internal:///./dist/cljs/index.js:41:85)
at Module../dist/cljs/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2298:1)
at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
at eval (webpack-internal:///./pages/index.js:2:77)
at Module../pages/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2310:1)
at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31);; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[reagent "0.8.1"]]
:builds
{:site {:target :npm-module
:output-dir "site/src/cljs"
:build-hooks [(shadow.next-js/create-pages)]
:entries []}
:esm {:target :esm
:output-dir "dist/cljs"
:build-hooks [(shadow.next-js/create-pages)]
:modules {:index {:exports {page_index }}}}}}npm run dev
shadow-cljs watch esm>
watch won't workcompilelet.
So, if I do something like this:
(let [res (ns some.namespace (:require ["js-dependency" :as dependency]))] res)And then try do define a function:
(defn a-fn [] (.useThis dependency)
It breaks with:
AssertionError Assert failed: (symbol? module)
shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:109)
shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:104)ns form in a let, it works fine. It's not a big deal, really - Shadow's hot-reload makes evaluating ns forms unnecessary, but I thought I would explain the issue anyway 😄ns is a special form which you cannot put into a let in CLJSload-file simply do not work if you wrap on letnil, so it does run... to some extend(defn simple-user-test {:shadow.build/stages #{:configure :flush :compile-prepare}} [state args]
(println "HELLO:")
(println (with-out-str (pprint args)))
(println (:shadow.build/stage state)))
state)
but if I pass in a keyword, like :flush (instead of the set) it works fine…?(defn simple-user-test {:shadow.build/stages #{:configure :flush :compile-prepare}} [state args]
(println "HELLO:")
(println (with-out-str (pprint args)))
(println (:shadow.build/stage state)))
state)
but if I pass in a keyword, like :flush (instead of the set) it works fine…?The hook is a just a normal Clojure function with some additional metadata. The {:shadow.build/stage :flush} metadata informs the compiler to call this hook for :flush only. You may instead configure {:shadow.build/stages #{:configure :flush}} if the hook should be called after multiple stages. At least one configured stage is required since the hook otherwise would never do anything.stages not stageshadow-cljs classpath. described in shadow-cljs --helpVisit '' in a browser? (y or n)(setq cider-offer-to-open-cljs-app-in-browser nil)(search-forward-regexp ":[0-9]+" nil 'noerror)shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.37 running atis it deterministic that the HTTP server output is before the shadow server output?
@tonejs/piano https://www.npmjs.com/package/@tonejs/piano using shadow-cljs to see if the error is just on my end. Trying to instantiate a Piano object using (Piano.) results in TypeError: Class constructor _o cannot be invoked without 'new' and I can't figure out how to debug it.:infer-warnings that get displayed. The default for this type of warning is false and there is no change in behavior when I add the additional compiler-option to set that warning type to false.
Why are there some :infer-warning types that still display during the build even though the option is turned off by default or explicitly?
------ WARNING #22 - :infer-warning --------------------------------------------
File: /ui/components/team.cljs:78:77
--------------------------------------------------------------------------------
75 | [:input {:placeholder "Username"
76 | :value username
78 | :on-change #(rf/dispatch-sync [::changeusername (.-target.value %)])}]
-----------------------------------------------------------------------------------^
Cannot infer target type in expression (. p1__110681# -target.value)(.. % -target -value) and the warning should go away?(.. % -target -value) and the warning should go away?.-target.value even works at allsweetalert2 from v9 to v10 in package.json, and I verified that project/node_modules/sweetalert2 contains the published code for v10. I cleared everything from the :output-dir and :asset-path. However, after a shadow restart and compile, I see the code for sweetalert2 v9 in the :output-dir again...~/node_modules doesn't have any cached version of sweetalert.shadow-cljs/builds. thats the cache maybe something is confusedbuilds?builds in years so I don't have a clue what you are doing that makes this necessaryUncaught ReferenceError: tests is not defined on the runner page.
My target:
{:target :browser-test
:test-dir "resources/public/js/test"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}}
My test file (in components/searchbar-test.cljs)
(ns components.searchbar-test (:require [cljs.test :refer (deftest is)])) (deftest a-failing-test (is (= 1 2)))Test file is right next to the implementation file, and it's correctly added to the classpath AFAIK (`:source-paths ["src/main"]` defined in shadow-cljs config) Running the tests with
npx shadow-cljs watch testindex.html in resources/public/js/test that calls tests.something in a script?resources/public/js/test and restarting the watcher for the tests solved the problem. Thanks once again172.17.134.96/28 , Win using 172.17.134.97 and WSL2 using 172.17.134.106.
The subnet for Win + phone is 192.168.0.0/24, Win using 192.168.0.193 and the phone 192.168.0.133.
So to solve it I had to:
1. Forward 192.168.0.193:9630 -> 172.17.134.106:9630 (Powershell's command netsh interface portproxy add v4tov4 listenport=9630 listenaddress=192.168.0.193 connectport=9630 connectaddress=172.17.134.106).
2. Run shadow-cljs with --config-merge '{:local-ip "192.168.0.193"}' .import stuff needs to goreact_devtools_backend.js:2450 Failed to load foo/core.cljs SyntaxError: Unexpected identifier
at eval (<anonymous>)
at Object.goog.globalEval (base.js:577)
at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:23)
at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:35)
at eval (browser.cljs:56)
at eval (env.cljs:232)
at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:204)
at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:240)
at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:48)
at eval (browser.cljs:92)
Any idea what might be causing this, or how I can fix it?^:export, and it started working as soon as I removed that keyword. Has ^:export been deprecated, or could there be something else going on?^:export is intended to work, considering that it’s mentioned in the documentation: https://shadow-cljs.github.io/docs/UsersGuide.html#_working_with_optimizations:export has not been changed. it works just like before.{:npm-deps {"xmlhttprequest" "1.8.0"}}
it's required like this:
["xmlhttprequest" :refer [XMLHttpRequest]]no complaints on compilation but get
Error: Cannot find module 'xmlhttprequest'at runtime. What am i missing?
node_modules directly. so either just include the node_modules whereever you are running it or post process the file with something like https://github.com/vercel/ncc:node-library build, and i'm attaching a JS runtime by running node out/index.js . whenever an error is thrown in the REPL, say for example from node's http package, the NodeJS process quits and i have to go through the process of restarting/re-attaching everything. is there a way to avoid this?shadow-cljs node-repl. that manages the node process for you.[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
[;...]/foo.css
it was required from
[...]/foo.js
Errors encountered while trying to parse file
[...]/foo.css
{:line 20, :column 1, :message "primary expression expected"}
Is there a way to get around this?:js-options {:ignore-asset-requires true} in your build config:ignore-asset-requires. Unfortunately, it still won’t load in a browser, because the JS code contains statements like require('foo.css').use();. Maybe there’s some other way to get this working?require('foo.css').use(); beforeimport which shadow-cljs doesn't supportbrowser.cljs:38 Failed to load my-project/monaco.cljs TypeError: Cannot redefine property: DiffEditor. Do you think there’s a way around this, or should I give up? 🙂(ns my-project.monaco (:require ["@monaco-editor/react" :refer [Editor]])) and then nothing else:modules config or :output-dirshadow-cljs classpath will do thatIllegal variable reference before declaration: a any idea what I can do to get rid of this?client, backend, common which refer to cljs, clj and ‘cljc’ respectively. My client uses shadow-cljs and after doing some reading I noticed that there are two ways to run shadow.
1. Via npm
2. Via lein
I’m confused on what is preferred here. I assume with running the client project via npm I would still get access to the repl right?
I also noticed that in lein generated projects the top level directory has a project.clj file and both the client and backend run off of lein. Ive noticed the same thing with luminus too and I am confused what is the preferred route.
It seems like running shadow via npm and the backend clj project via lein would be right but what i mentioned above makes me hesitant that it is the "right way"src/main that houses all .clj/s/c files but namespaced accordinglysrc/main/acme/project/frontend.cljs etcsrc/project_name/{client,backend,common}
ok cool im going to go your route since i like it as well. just need to make Calva play nice with it!Closure compilation failed with 1 errors --- node_modules/ibmcloud-appid-js/dist/appid.umd.min.js:44 Illegal variable reference before declaration: a
jsrsasign: a = a,
var foo from js module(?) which does not export it?
specifically https://github.com/paulrosen/abcjs/blob/master/src/write/abc_glyphs.js#L21
(:require ["abcjs/src/write/abc_glyphs"]); :refer [glyphs]]exposes only 1 top-level var:
module.exports = Glyphs;https://github.com/paulrosen/abcjs/blob/master/src/write/abc_glyphs.js#L234
var do you want to access? in general you cannot access var unless it is part of some exported objectvar glyphs =
inti function.^:dev/after-load tagged function to do the actual re-render:after-load in the build config https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reloadtap> were not caught in the inspector is it normal?shadow-cljs compile <build-id> produce the same output as a compile during shadow-cljs watch <build-id> does? (wrt to the CLOSURE_DEFINES )CLOSURE_DEFINES , I am serving my SPA from a docker container and would like to serve a client that has shadow-cljs “enabled” (i.e. connects to a REPL)watch? why do you want compile?shadown-cljs watch <build-id> process that I’m running locallyshadow-cljs watch createswatch in the Dockerfile?<script src=":<port>/js/main.js"> or so[:http :host] settings in shadow-cljs.edn would instruct the client what shadow-cljs HTTP server to connect to to but it seems that it only instruct the HTTP server what ip/dns to listen to, am I missing something?:devtools-url controls where it connects to if its not the host:devtools {:use-document-host false} if just localhost is ok$ node_modules/.bin/shadow-cljs watch :main shadow-cljs - config: /Users/holyjak/Work/customersupport-app/shadow-cljs.edn shadow-cljs - starting via "clojure" DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl (/Users/holyjak/.clojure/deps.edn) DEPRECATED: Libs must be qualified, change mount => mount/mount (deps.edn) DEPRECATED: Libs must be qualified, change hiccup => hiccup/hiccup (deps.edn) # now it printed nothing more for minutes...
server has the same issue.user.clj that does stuff on load?clj with whatever aliases you might need(require '[shadow.cljs.devtools.server :as srv]) and (srv/start!)lein-doo https://github.com/littleredcomputer/sicmutils/blob/master/project.clj#L71 and I suspect that the testing experience would be way better with shadow-cljs... also I'm finally at a phase where I can start developing UI components off of this work, so it's time to switch. just wanted to make sure I wasn't missing any pieces wrt library:dependencies and require in their ns?shadow-cljs.edn for clojurescriptshadow-cljs.edn is in their project. that is the only relevant one. all others have no effect.tools.edndeps.edn is its own thing.------ WARNING #1 - :undeclared-var -------------------------------------------- File: /Users/borkdude/.gitlibs/libs/borkdude/sci/971614de14a6fd00e6991d1afd6c0ce9fbda104c/src/sci/impl/fns.cljc:51:32 -------------------------------------------------------------------------------- 48 | (throw-arity fn-name macro? args)) 49 | ret))) 50 | ctx #?(:clj (.assoc ctx :bindings bindings) 51 | :cljs (-assoc ctx :bindings bindings)) --------------------------------------^----------------------------------------- Use of undeclared Var sci.impl.fns/clojure
clojure.lang.ExceptionInfo or anything clojure.lang.* reallyclojure. maybe that provides a better clue^clojure.lang.Associative ctx so thats most likely it(.get ^java.util.Map ctx :bindings)shadow-cljs watch main on a clone of https://github.com/fulcrologic/fulcro-rad-demo
Execution error (IllegalArgumentException) at shadow.build.cljs-bridge/eval14597$loading (cljs_bridge.clj:1).\nNo matching field found: getRegisteredGroups for class com.google.javascript.jscomp.DiagnosticGroups\n"
react-date-picker are blindly expecting users to be using css loader. I notice that shadow (rightfully), isn't very happy about that
Failed to inspect file /home/hlolli/Documents/visitor/node_modules/react-calendar/dist/Calendar.css it was required from /home/hlolli/Documents/visitor/node_modules/react-date-picker/dist/entry.jsWould override be the good solution here? (solved)
react-date-picker are blindly expecting users to be using css loader. I notice that shadow (rightfully), isn't very happy about that
Failed to inspect file /home/hlolli/Documents/visitor/node_modules/react-calendar/dist/Calendar.css it was required from /home/hlolli/Documents/visitor/node_modules/react-date-picker/dist/entry.jsWould override be the good solution here? (solved)
["react-date-picker/dist/entry.nostyle.js" :default DatePicker] solves it, so it's solved:js-options {:ignore-asset-requires true} will just ignore them. that may or may not work depending on the lib.cljs.spec.test.alpha/instrument? I just ran into an error, where a var only became instrumented, after deleting .cpcache. Just a restart and regular clean didn't help ...instrument to :cache-blockers should fix it though, right?instrument is a rather difficult beast since it is a macro.cpcache or any cache really had anything to do with itinstrument was already running due to parallel compileinstrument, that would instrument all specced vars. After adding the transitively dependent namespace, that also calls instrument, to :cache-blockers, it seems fine ..instrument might not recompile(ns ^:dev/always this.calls.instrument) works too"main": "dist/index.umd.js" throws some error like Cannot read property 'createGenerator' of undefined , but it works if I use the esm instead. is that expected? can't find any mention of the difference in the user guidemain. compatibility is much better since not all packages provide module and mixing has been a nightmare in the past. it can work but it largely depends on the packages you use. can't say much about the createGenerator error without more information. you can make it use module via setting :js-options {:entry-keys ["module" "browser" "main"]} in the build config, the reverse is the default.:shadow {:main-opts ["-m" "shadow.cljs.devtools.cli"]} in my deps.edn to watch a build, should I get a REPL after navigating to my app? I remember getting this but haven’t seen it in awhile, and have been having issues connecting my editor and figured this was a good place to start.:CljEval (shadow/repl :my-app) it says shadow isn’t defined(shadow.cljs.devtools.api/repl :my-app)shadow.user but maybe you are just in user :nrepl {:port 51468} in my shadow-cljs.edn, so it should be the right one, since I explicitly connect to that port.cider/cider-nrepl?:missing-nrepl-middleware, so that is something outside shadow?clj -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"}}}' -m nrepl.cmdline --connect --host localhost --port 33333 , upgrade via (shadow/repl :my-app), so yeah, it seems like an nrepl connection issue. Thanks for taking a look, I’ll try to debug from here.shadow-cljs with external http server?shadow-cljs with external http server?.cljs source in browser.cljs source in browser is a shadow-cljs limitation2020-11-04 09:21:57,377 [XNIO-1 I/O-1] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1
How do I turn this off on the shadow-cljs server log?
my SLF4J config has an entry <logger name="org.xnio.nio" level="warn" /> but it doesn't seem like shadow reads that.org.xnio.nio doesn't affect io.undertow so you need to add that too. its your logging setup so you need to configure it.shadow-cljs limitation:asset-path in your build config:output-dir "resources/public/js" :asset-path "/js"
<script src="/js/main.js"> that is correct yes<script src="/js/main.js" type="text/javascript"></script>watch or compile builds)release does not have source maps enabled by defaultthheller/shadow-cljs {:mvn/version "2.11.2"}/js/cljs-runtime/cljs/core.cljs for example (or whatever port you are on) to see if its served correctlyapplication/json mime type:devtools {:autoload false} and it didnt workcompile after every code change it works, but the watch inserts multiple instances of the content script2.11.7java -version do you use? and which shadow-cljs version?deps.edn?shadow-cljs server then it will print shadow-cljs - server version: <version> running at on startupnpx shadow-cljs server or npm install -g shadow-cljs:web-worker true in shadow-cljs), but the web-worker keeps some state in an atom that I don’t think I can access from the REPL currently?tap> something in the worker and it will show up in the web UI inspecttap> / js/console.log or whatever.
Thanks for the help.tap> for the worker context. It’s not that bad of a tradeoff, still a nice workflow.npx shadow-cljs compile step + archive_artifacts<html><head></head><body><input type="text" name="history_state1" id="history_state1" style="display:none"></body></html>why isn’t it at a very minimum using the static html page i have for the react container?
lein deps :tree or similarshadow-cljs info:karma-test under :build which is like this:
:karma-test {:target :karma
:ns-regexp "-test$"
:output-to "target/karma-test.js"}
What I understand is that Shadow is going to compile all my cljs files, from src/ and test/ into that target/karma-test.js file.
I'd like to report test coverage using karma's coverage plugin but for that, I need to have the sources and the test in separate files, right?
If I add this to my karma config file, it runs into a loop:
preprocessors: {
'target/karma-test.js': ['coverage']
},
Was anyone successful at running coverage report?
(FYI I'm quite new at using clojure/clojurescript/shadow-cljs)<--- Last few GCs --->
[743:0x2e177e0] 27020 ms: Scavenge 1365.5 (1423.5) -> 1364.7 (1424.0) MB, 2.0 / 0.0 ms (average mu = 0.300, current mu = 0.273) allocation failure
[743:0x2e177e0] 28513 ms: Mark-sweep 1365.6 (1424.0) -> 1362.4 (1423.5) MB, 1490.8 / 0.0 ms (average mu = 0.392, current mu = 0.459) allocation failure scavenge might not succeed
[743:0x2e177e0] 28518 ms: Scavenge 1363.3 (1423.5) -> 1362.5 (1424.0) MB, 2.6 / 0.0 ms (average mu = 0.392, current mu = 0.459) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x1246665bf1d]
1: StubFrame [pc: 0x1246661b535]
Security context: 0x0e367139e6c1 <JSObject>
2: builder(aka builder) [0x3a525ca3dcf1] [/app/node_modules/@babel/types/lib/builders/builder.js:~16] [pc=0x12466a63ad1](this=0x287b09c026f1 <undefined>,/* anonymous */=0x3841126a8a69 <String[14]: ObjectProperty>)
3: arguments adaptor frame: 3->1
4: valueToNode(aka valueToNode) [0x358fe6fb6809] [/app/node_modul...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8fb090 node::Abort() [node]
2: 0x8fb0dc [node]
3: 0xb031be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb033f4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xef7452 [node]
6: 0xef7558 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
7: 0xf03632 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
8: 0xf03f64 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
9: 0xf06bd1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xed0054 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
11: 0x117012e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x1246665bf1d
Aborted (core dumped)coverage can run is to have the sources separated from the tests. Right now they are regrouped in the same file kamra-test.js.
I would really appreciate if you could help me figuring out how to separate them please?preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'src/**/*.js': ['coverage']
},
We want the source files to be separate from the test files.:npm-module build but I have my doubts that changes much:browser-test target generating 2 js files?
- one with only the namespaces from the sources
- one with the tests and all the rest
Having this, it would be extremely easy to run test coverage.:karma target dumps all the js code into a single file which makes it impossible to run the coverage module with any accuracy.:npm-module if you want one file per namespace. that is the best I can offer?:cli or :create-cli builds are my best bet?:cli or :create-cli?shadow/repl-runtime-selectto help me switch between repl environments, but the selection is brittle (it depends on the order they start in to know which one I'm picking) and as the runtimes come and go (eg page reload) it doesn't seem like the connection gets maintained consistently, though I could be wrong.:cli is the code for the shadow-cljs command yes. I do not understand what you mean by "way to load up and interact with the library code directly?"repl-runtime-select thing is pretty much dead and gone. it doesn't do anything at all anymore these days.:browser, :script or :library builds. sometimes just a browser-repl or node-repl. started like https://github.com/thheller/shadow-cljs/blob/master/CONTRIBUTING.md#starting-a-replsrc/repl that may look like tests but arent. each deftest is just an isolated snippet of code I can run via keypress so experiment with specific thingsshadow.remote https://github.com/thheller/shadow-cljs/blob/master/doc/remote.md(shadow/repl :dev-android) To quit, type: :cljs/quit => [:selected :dev-android] (def one 1) => #object[TypeError TypeError: undefined is not an object (evaluating 'cljs.user.one = (1)')]I’m pretty certain it was working before, so I don’t quite understand what went wrong and why
cljs.user is undefined. do you get the same error for (ns cljs.user) or so?(ns cljs.user) before anything else - it starts working"shadow-cljs": "^2.11.4"target/index.js gets rewritten every time - so at first Metro reacts correctly and tries to do a fast refresh, but then, when entry point file gets updated - it just reloads the whole thing.
Although I finally got it to work as you suggested, I’m wondering whether it would be possible to prevent the entry point from getting recompiled every time.(defn f
[]
(.-foo (clj->js {"foo" 42})))
;; WARNING: :infer-warning
(defn f
[]
(.-foo ^js (clj->js {"foo" 42})))
;; no warning
(defn f
[]
(clojure.core.async/go (.-foo ^js (clj->js {"foo" 42}))))
;; WARNING again :infer-warningclj->js and then access a property that doesn't make sense at all?go blocks so ideally you never get to code that has to do thisgo(go
(let [url (.getParameterValue parsed-href "url")]
(<! (fetch-ch url))
;; other stuff
))(.getParameterValue parsed-href "url") will. access(let [url (get-parameter-value parsed-href "url")] ...)(set! *warn-on-infer* false) in that file(:refer-clojure :exclude [map]) is more appropriate
https://stackoverflow.com/questions/51511643/disable-compiler-warnings-for-a-specific-file-in-clojurescript:chunks {:foo your.components.foo/some-var :bar your.components.bar/some-var} in your :react-native build configfoo.js and bar.js in the :output-dir:modules under the hood(js/require "./foo.js") somewhere and the result of that should be some-var:chunks. I could never quite get it to work with react-native to actually lazy load it:chunks:chunks@yenda about :chunks:require [react-diff-view :refer [parse Diff Hunk]]) that shows up as empty (i.e. (js/console.log react-diff-view parse Diff Hunk) gives me {__esModule: true} undefined undefined undefined). Any idea what's causing this or what could be done about it?cljs.core.js).
Looking at the first example in a diff, the differences can be something so trivial as: var p=$CLJS.zh;this.ri=p instead of this.ri=$CLJS.zh 😕
So I'm wondering where the extra entropy in my builds is coming from!github:foo/bar#commit instead of a version number. whether that works entirely depends on the npm package though. most of them require a build step so using them from source-only usually doesn't work.cljs.core staying alive or being removed. :advanced output must be used as one contained unit and cannot be mixed with output from other builds.shadow-cljs release npm twice in a row produces different output each time, so it's definitely not (only) a DCE thing.
It would be nice to have IMO, but if reproducible builds isn't a design goal for shadow-cljs then I can stop concerning myself with it!gensym quite frequently so thats also not deterministic.:dev or :release and as such is not supported--config-merge to override stuff if you want though which sort of gets you whatever you might need with regards to :closure-defines etcshadow-cljs is the one one I understand best…) Many thanks for your swift help on this occasion (and previous ones)…The required JS dependency "<npm-package>" is not available, it was required by ..., I’m porting pretty large js codebase and they seem to be not having using the code in <npm-package> ...yarn did the right job and installed all npm packages from transitive dependencies, not sure why npm didn’t do thatThe required JS dependency "use-cannon" is not available but I’m sure it is in node_modules/use-cannon, and package.json there properly points to compiled index.js filemodule key and has no main key[1]. I renamed module to main and shadow-cljs started working as expected. Quickly googled this[2] Maybe shadow-cljs should warn and fallback to module?
[1] https://github.com/pmndrs/use-cannon/blob/cf8a7482ed9eb8dfc2f39a58bec5b8027caee542/package.json#L16
[2] https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for:js-options {:entry-keys ["module" "browser" "main"]} to make it use module by default. it isn't in the list by default since mixing commonjs and ESM is PITA. in the next release it'll use module last just in case neither browser or main are set.use-cannon uses react’s lazy to lazy-load another file relatively from the same package[1]
2. when my app tells react to render component tree, it eventually starts lazy loading that code
3. it ends up calling shadow.js.jsRequire where it fails to resolve module Module not provided using relative name “./Provider-480a0e71.js”, at that point shadow.js.nativeRequires is empty, shadow$provide is empty, shadow.js.files contains 67 items, but does not match the name, there are some use_cannon related items, but not the provider[2]
[1] https://github.com/pmndrs/use-cannon/blob/cf8a7482ed9eb8dfc2f39a58bec5b8027caee542/src/index.tsx#L28
[2] https://gist.github.com/darwin/788f7799398b3fd92d77c685d2ae51eaimport is not supported by the closure compiler currently and won't be for the forseeable future. only option is to use a JS packaging tool that does (eg. webpack) via :js-provider :external https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-externalloader/load "module" fetches /js/module.js, however if I load any other page (say /foo/bar) loader/load "module" tries to fetch /foo/js/module.js. How can I ensure that the asset path remains consistent regardless of the url?:asset-path "/js" in your build config. looks like you have :asset-path "js"?yarn link to create a symlink between my cljs project and a js library but shadow is not picking up the new changes to the js library when it recompilestouch the package.json of the package to trigger a recompile thoughwindowimport { ProviderProps } from './Provider' and then import('./Provider')ProviderProps is just a type so probably a misplaced import that should be in the import type further up{:nrepl {:port 8777},
:dev-http {8280 {:root "resources/public",
:proxy-predicate foo.bar/proxy-predicate,
:push-state/index "baz/index.html",
:proxy-url (or (System/getenv "FOO_BAR_URL") "")}},
...
}
#shadow/env ["FOO_BAR_URL" ""] second value is default if env var is not set :closure-defines {https://your.app/URL #shadow/env "APP_URL"}`:closure-defines:libs ["../path/to/lib"] and then requiring it as a namespace doesn't seem to work.(:require ["sjcl/hmac" :as hmac]) I'm getting:
Execution error (AssertionError) at shadow.build.data/add-string-lookup (data.clj:119). Assert failed: (symbol? sym)
src/sjcl/hmac.js existsgoog.provide?(:require [sjcl.hmac :as hmac])goog.provide("foo.bar.baz") need to be in src/foo/bar/baz.js or similar?shadow.markup (https://github.com/thheller/shadow/wiki/shadow.markup) and thought it looked interesting but it hasn't been updated in 2 years. Is anyone here using it in production and would like to share their experience?:node-test target. Should releases using :node-test be minified the same way as :node-script? There’s a bug I’m getting when I run my tests if the code is generated using release . This is the issue for some more context (https://github.com/henryw374/cljs.java-time/issues/8):compiler-options {:externs ["cljsjs/js-joda/common/js-joda-dup.ext.js"]} in your build config to include the externs it seems to require. not sure why node-script works but node-test does not.compile instead of release . Thanks!compile doesn't go through :advanced so it will never have any externs related issues.PersistentArrayMap where each keyword appears to be mapped to itself. So when I start with
{:a :b :foo :bar}
the compiler produces
new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);Seems like a bug, but I am new to shadow. Version used is 2.11.7.
(ns shadow-compile-map.core)
(def ^:private example-map
{:a :b
:foo :bar})
(defn demo [k]
(get example-map k))
Main output:
import "./cljs_env.js";
goog.provide('shadow_compile_map.core');
shadow_compile_map.core.example_map = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);
shadow_compile_map.core.demo = (function shadow_compile_map$core$demo(k){
return cljs.core.get.cljs$core$IFn$_invoke$arity$2(shadow_compile_map.core.example_map,k);
});
I happened to be testing the output in browser, so I have this index.html:
<script type="module">
import { demo } from "./compiled/demo.js";
const result = demo("foo");
console.assert("bar" === result, "The result is %s", result);
</script>
“bar” I get null .(= :foo "foo") will be false:ns-runner for the :browser-test target (https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test).
I tried to make my own but it didn't work:
Uncaught TypeError: Cannot read property 'init' of undefined
at (index):2
My custom runner is a copy of shadow.test.browser and I located it in my test directory. Please can someone help me making this work?test-dir "index.html" already existed and contained the call to the previous init (`shadow.test.browser`). I deleted it and recompiled. This is now ok.
Too bad this file is not cleaned up on a config change.(ns app.chroma (:require ["chroma-js" :as cm]))After compilation, refresh the browser and the console gives two errors as shown in the attached picture:
main.js:1672 An error occurred when loading app.chroma.js env.evalLoad @ main.js:1672 (anonymous) @ main.js:1886 main.js:1673 undefined env.evalLoad @ main.js:1673 (anonymous) @ main.js:1886
cm actually used?:npm-deps in deps.cljs, eg. https://github.com/reagent-project/reagent/blob/master/src/deps.cljs:entries vector:build-options {:ns-aliases {my.app.foo my.app.bar}}. that will make it use .bar whenever .foo is required in the buildmathjax package seems to be targetted for node onlyL variable that is traditionally exposed by leaflet. The NPM version of leaflet does not expose the global. In another lein project I fixed this by running webpack, with the following tweak:
new webpack.ProvidePlugin({
// Leaflet markercluster plugin requires global L object.
L: 'leaflet'
}),
Is there some way of solving this naturally in shadow-cljs? Seems like I could change my :js-provider, but that would kind of remove the point of moving to shadow-cljs.
Maybe create my own cheat where I make a new module that requires leaflet and exposes the global?:js-options {:resolve {"leaflet" {:exports-globals ["L"]}}} in the build config might do the trick. or just (js/goog.exportSymbol "L" L) with (:require ["leaflet" :as L]) somewhere before the plugin is loadedexport-globals thing. Tried to find it in the docs, seems undocumented for now?? any idea on how to fix that?shadow-cljs cljs-repl app directly and check if it happens there too? if so it is your connection to the other REPL{:app
{:target :node-script
:output-to "out/server.js"
:main com.disney.rant-lsp/main
:compiler-options {:infer-externs true}}
:test
{:target :node-test
:output-to "out/node-tests.js"
:compiler-options {:infer-externs false}
;;:ns-regexp "-spec$"
:autorun true}}
I do npx shadow-cljs compile app. The app runs fine, until I package it (it’s a VS Code extension). The packaging doesn’t include the .shadow-cljs directory. This used to work, but recently I started getting this:
Error: ENOENT: no such file or directory, open '/Users/wisej041/.vscode/extensions/wdi.rant-1.0.2/server/.shadow-cljs/builds/app/dev/out/cljs-runtime/goog.debug.error.js'
.shadow-cljs; is that correct?shadow-cljs release app if you want to publish something. compile and watch are development builds only meant to run on the machine they were compiled onTypeError: $jscomp.inherits is not a function when I am using a third party dependency (helix), one particular macro from it does it. I already tried to update and restart everything, I also added :output-feature-set :es8 to compiler options and I really wish I could do something that's not just guesswork but actual diagnostic and work. Any ideas?shadow-cljs - server version: <version> running at shadow-cljs info also works but only in limited ways if you use deps.edn or project.clj.shadow-cljs/server.stderr.log or .shadow-cljs/server.stdout.log$jscomp related issues that I fixed recently but they should definitely be fixed in 2.11.7:output-feature-set :es8 is only in the :release config. I'm assuming the problem you mentioned appears in watch/compile?shadow.remote.runtime.cljs.browser in :preloads. you can just remove it.:release the :modules and :output-dir are exactly the same as outside so you can remove it$ clojure -Sdescribe
{:version "1.10.1.716"
:config-files ["/usr/local/Cellar/clojure/1.10.1.716/deps.edn" "/Users/rick/.clojure/deps.edn" ]
:config-user "/Users/rick/.clojure/deps.edn"
:config-project "deps.edn"
:install-dir "/usr/local/Cellar/clojure/1.10.1.716"
:config-dir "/Users/rick/.clojure"
:cache-dir "/Users/rick/.clojure/.cpcache"
:force false
:repro false
:main-aliases ""
:repl-aliases ""}
clojure.main with clojure -M -m clojure.mainclojure -m shadow.cljs.devtools.cli --npm ...clojure -M -m shadow.cljs.devtools.cli ...:exec-fn and :exec-args stuff; which is pretty awesome actually… It could be interesting thinking about what it might mean for shadow-cljs…
Though I imagine it’s a lot easier to just carry on with shadow-cljs.edn as it is 🙂lein for metools.build:exec-fn stuff at least now provides a way to integrate tooling to build a library and deploy itlein to do this bit.project.clj + lein deploy clojars I might support it 😉:exec-fn makes things much better and feels like it could well be a decent foundation for new tooling:exec-fn anytime soon:exec-fn is still relevant for shadow-cljs.
i.e. if the shadow-cljs api defines entry point tooling functions to just be a single map of data, then they can work with :exec-fn, so users have more options for integration.tools.deps and :exec-fn; but it could still be an option for users. Providing perhaps a few reasonable constraints are maintainedlein repl :connect 9876 Connecting to nREPL at 127.0.0.1:9876 REPL-y 0.4.4, nREPL 0.7.0 Clojure 1.10.1 OpenJDK 64-Bit Server VM 1.8.0_265-bre_2020_10_20_12_24-b00 ... shadow.user=> (println "Smørrebrød") Smørrebrød nil shadow.user=> (shadow/repl :app) To quit, type: :cljs/quit [:selected :app] cljs.user=> (println "Smørrebrød") Sm??rrebr??d nilIn the "Java REPL" encoding is okay, in the "JS REPL" it is broken... any ideas on how to fix that?
lein repl :connect 9876 shadow.user=> (System/getProperty "file.encoding") "US-ASCII"despite the fact that
-Dfile.encoding=UTF-8 is in the arguments of the java process of lein?shadow-cljs watch app
-Dfile.encoding=UTF8:lein true or something in shadow-cljs.edn?tools.depsis in the arguments of the java process of lein`? `?:jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn:jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn fixed the problem.US-ASCII bei default? When I launch clj I get:
% clj Clojure 1.10.1 user=> (System/getProperty "file.encoding") "UTF-8"
UTF8 works, I guess it should be UTF-8.[[titonbarua/shadow-cljs-gjs-target "0.1.0"] -> [[ shadow-cljs-gjs-target "0.2.0-gnome-extension-patch"]]
I can build the patch locallylein install to install it locally:source-paths you can just direclty include the code via "../../src" and no :dependencies[2020-11-20 20:08:05.240 - INFO] duplicate resource com/fulcrologic/fulcro/mutations.cljc on classpath, using jar:file:/home/buidler/.m2/repository/com/fulcrologic/fulcro/3.4.3/fulcro-3.4.3.jar!/com/fulcrologic/fulcro/mutations.cljc over file:/home/buidler/project/src/app/com/fulcrologic/fulcro/mutations.cljcBut I don't understand why. I want to use my file, not the version in the jar file. Looking at these instructions https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries
thheller/shadow-cljs {:mvn/version "2.8.107"}2.11.7:paths ["src/app" "resources" "src/test"]:optimizations :simple . That doesn’t work either.app and bootstrap-support separately in dev mode, it works. i.e shadow-cljs compile app bootstrap-support .:compiler-options {:optimizations :simple}goog is not defined is what you get when it is :advanced and not :simple/js/compiled/app.js in your HTML? I mean where exactly do you get that error?:output-wrapper false in the compiler optionsapp or bootstrap-support?boot/init to refresh every time?foo was defined with the previous eval, calling (foo) with a new eval shouldn’t work.(defn foo [] ...) will create cljs.user.foo = function() ... . resetting the compiler state will remove the definition from the analyzer(foo) will then result in a warning but it eval'd will call the old cljs.user.foocljs.user I guess:modules functionality is meant for on big webapp that would be splitted into various chunks.
Is it possible instead to have many entry points that would share a common set of namespaces?
Thanks.:modules; the difference is in how you decide to load code via script tags (one for a big app, or different ones on different pages for lots of apps) / loading GClosure modules on demand (in your big app):modules allows you to split the code so you only load whatever is needed. if you instead want everything in one file and just use whatever from it you can use (defn ^:export foo []) and then call <script>your.ns.foo();</script> from the HTML;; shadow-cljs.edn
{:deps true
:builds {:app {:target :browser
:output-dir "resources/public/cljs"
:asset-path "/cljs"
:release {:output-dir "resources/public/cljs"
:module-hash-names 12
:build-options {:manifest-name "assets.edn"}}
:modules {:shared-deps {:entries [myapp.front.shared-deps]}
:entry-point-a {:init-fn myapp.front.entry-point-a/main!
:depends-on #{:shared-deps}}
:entry-point-b {:init-fn myapp.front.entry-point-b/main!
:depends-on #{:shared-deps}}
:entry-point-c {:init-fn myapp.front.entry-point-c/main!
:depends-on #{:shared-deps}}
}}}}
;; myapp/front/shared_deps.cljs
(ns myapp.front.shared-deps)
(defn foo [])
;; myapp/lib/compile_time_util.clj
(ns myapp.lib.compile-time-util
(:require [clojure.edn :as edn]
[ :as io]))
(defmacro inject-cljs-resource [resource-id]
(let [env (System/getenv "MYAPP_ENV")
cljs-dir "public/cljs"
asset-path "/cljs"]
(if (contains? #{"prod" "testing"} env)
(->> (str cljs-dir "/assets.edn")
io/resource
slurp
edn/read-string
(some (fn [entry]
(when (= (:name entry) resource-id)
entry)))
:output-name
(str asset-path "/"))
(str asset-path "/" (name resource-id) ".js"))))
;; myapp/server/views/mypage.clj
(defn render-page [req]
(layouts/render-layout
(assoc req
::vutil/extra-js-deps [(ct-util/inject-cljs-resource :shared-deps)
(ct-util/inject-cljs-resource :entry-point-a)])
[:div
[:h1 "Title"]
...]))
npm i --save firebase, and it updates my package.json fine.
The firebase docs say to require it in a normal js app using import firebase from "firebase/app"; so as per https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I've imported it using ["firebase/app" :default firebase]. But if I try to use that import with (firebase/initializeApp #js{ ... }) I get the following error:
`No such namespace: firebase, could not locate firebase.cljs, firebase.cljc, or JavaScript source providing "firebase"`
If I try to require it instead by using ["firebase/app" :as firebase] then if I try to use it with (firebase/initializeApp #js{ ... }) I get the following error instead:
#object[TypeError TypeError: module$node_modules$firebase$app$dist$index_esm.initializeApp is not a function]
If I look at node_modules/firebase/app/dist/index.esm.js it looked like it was just loading from @firebase. So I try ["@firebase/app" :as firebase] and I get #object[TypeError TypeError: module$node_modules$$firebase$app$dist$index_esm.initializeApp is not a function].
But if I look at node_modules/@firebase/app/dist/index.esm.js it seems like the function would be there.
For the heck of it, and to see if I'm understanding how to do this properly, I try installing underscore and importing it as ["underscore" :as underscore] and that totally works. I can go into the REPL and run > (.entries js/Object underscore) and I'll get something that makes sense. But if I try > (.entries js/Object firebase) then I get something a little hard for me to explain:
The result object failed to print. It is available via *1 if you want to interact with it. The exception was: RangeError: Maximum call stack size exceeded :shadow.cljs/print-error!I think I've probably just made a silly error somewhere, but I don't seem quite capable of figuring it out - does anyone know what I've done wrong in installing and requiring firebase? Also I think this is a shadow-cljs thing but let me know if I'm wrong and this is totally the wrong place to ask...
:as sets up a namespace alias so you can do firebase/doX. :default does not setup up an alias but instead acts like :refer. so you can do (.initializeApp firebase) with :default firebase:devtools {:devtools-url ""
and I’m using an nginx proxy configured as shown here https://www.nginx.com/blog/websocket-nginx/?server-token=<uuid>location /shadow-cljs/ {
rewrite ^/shadow-cljs/(.*) /$1 break;
proxy_pass ;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
in nginx, and it turns out putting the $1 on the proxy_pass was wrong…changing it to this fixed it:
location /shadow-cljs/ {
rewrite ^/shadow-cljs/(.*) /$1 break;
proxy_pass ;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
shadow-cljs compile? or just :compiler-options {:optimizations :simple}?:repl {:runtime-select :latest} in our project and like it. Now I’ve added an iframe that also runs a cljs target that’s built with shadow. Is there a way to opt out of shadow considering this iframe for the repl? I’d like shadow to use the latest main window for the repl…shadow.cljs.devtools.api I noticed that my repl-runtimes are missing the :runtime-id key that’s needed for me to switch this or am I misunderstanding the api?
(repl-runtimes :website)
;; => [{:since #inst "2020-11-25T07:44:05.319-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 45, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true} {:since #inst "2020-11-25T07:44:07.842-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 46, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true}]2.11.8 you can set <script>var SHADOW_CONFIG = { repl: false };</script> in the HTML (before the actual script) to opt-out of the REPL for that pagecljsjs because shadow-clj doesn't support that, so I think I have to install the library via npm install cytoscape-cola(:require ["cytoscape-cola" :as cyto])opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1(:require ["uuid" :as uuid-js])
{:target :node-test
:compiler-options {:optimizations :none}
:js-options {:entry-keys ["module" "main"]} ; using esm modules (for uuid npm dep) see
:output-to "cljs-out/test/node-tests.js"
:ns-regexp "-test$"
; autorun does not return an exit code suitable for CI. CI tests are runs from node cli instead
:autorun false}
opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1 is not an error. that is a filename. what is the actual error?+ node cljs-out/test/node-tests.js
SHADOW import error /opt/atlassian/pipelines/agent/build/.shadow-cljs/builds/test-ci/dev/out/cljs-runtime/shadow.js.shim.module$uuid.js
/opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1
export { default as v1 } from './v1.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1043:16)
at Module._compile (internal/modules/cjs/loader.js:1091:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at /opt/atlassian/pipelines/agent/build/.shadow-cljs/builds/test-ci/dev/out/cljs-runtime/shadow.js.shim.module$uuid.js:3:30
at global.SHADOW_IMPORT (/opt/atlassian/pipelines/agent/build/cljs-out/test/node-tests.js:64:44)
at /opt/atlassian/pipelines/agent/build/cljs-out/test/node-tests.js:1839:1module entry? it should be using main?:js-options have no effect hererequire("uuid"). nothing else.node manually and then require("uuid")node as above?require.resolve("uuid") to see--esm flag or sojs-options will do anything since node is responsible for picking the JS dependency. which you can see from the stacktrace.As of Node.js 12.17.0, the --experimental-modules flag is no longer necessary to use ECMAScript modules (ESM).node and require("uuid") works then :node-test output fill work toonode -e "require('uuid')"module entry but then doesn't understand modules 😛@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integrationThanks, will try that first
@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integrationThanks, will try that first
Clojure and Clojurescript projects, with Shadow ?.js files. The use the import/export syntax as required, but they make use of a class with static fields, which for some reason is giving me a syntax error of “expecting a (“ after the field name. Is it possible that I need to tweak the closure compiler's input language setting? Commenting out all static fields allows compilation to succeed...:language-in compiler option to no avail. class Foo {} and Foo.field = 1; or whatever:dev-http {9000 "classpath:www"}:public/index.html from a dependency, instead of in resources/public/index.html. I suspect this is because of the hardcoded special-casing of folders named *resources, because it behaves correctly, when public/index.html is in different :paths directoryindex.html necessary for client-routing, doesn't work as described in https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http.(ns cljsjs.rrule (:require ["rrule" :as rrule])) (js/goog.exportSymbol "RRule" rrule)
#object[TypeError TypeError: Cannot read property 'call' of undefined]deps.edn:dev-http. it just uses the classpath as constructed by clojure:paths first for a while so the ordering was more or less randomrrule actually is in the REPL or so.(type r/rrule) => nilcljs.core and other core libs from a CDN ?
I'm aware that I would lose tree-shaking capabilities, but since core libs are really stable, clojurescript is getting more and more popular and my project grows, using a CDN and client cache may be a good fit.
Have anyone tried to setup this ?index.html file?
The User Guide states:
> The https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifest can help with that.
How is the Output Manifest commonly used to do this task?index.src.html and modifies the <script src="/js/main.js"> (or whatever your modules and paths are)shadow-cljs to pass arguments to clojure? Like clj -Sdeps '{:mvn/local-repo "foo"}' . Reason being that I want to use a different local maven repo when building in a CI pipeline (gitlab).clj directly. doesn't matter from shadow-cljs perspective. just use clj -m shadow.cljs.devtools.cli release app or so. that would be identical to shadow-cljs release app(cider-offer-to-open-cljs-app-in-browser . nil)(shadow/stop-worker :node-repl)shadow-cljs node-repl — when evaluating via Conjure/Vim they are not shown(defn foo ^ReturnType [a b] ...)undeclared-var warnings from something like this:
(:require #?(:node
["@sentry/node" :as sentry]
:browser
["@sentry/browser" :as sentry])
(.configureScope sentry (fn [^sentry.Scope scope] ....
^sentry.Scope has no meaning in shadow-cljs whatsoever. just make your life easier and use ^jsshadow node-repl , just not when evaluating through my editor (so probably not shadow’s fault)undeclared-var warning and less about inferenceUse of undeclared Var icebreaker.util.sentry/sentry^sentry.Scope probably. should be either ^js or sentry/Scope given that its an alias not a var:as something you should probably always be treating that as a proper namespace alias(.configureScope sentry ...) is valid (sentry/configureScope ...)would be betterNo such namespace: sentry, could not locate sentry.cljs, sentry.cljc, or JavaScript source providing "sentry"
:cljs default branch for sentry. node-repl doesn't use any custom reader conditionals so it only uses :cljs which is missing.(shadow/node-repl {:config-merge [{:compiler-options {:reader-features #{:node}}}]}) but you’re right that when I tried to reduce the repro I skipped that:target-defaults {:node-script {:compiler-options {:reader-features ...}}}. that should apply to node-repl:infer-externs flag?
E/unknown:ReactNative: MyAppImpl caught native exception
com.facebook.react.common.JavascriptException: TypeError: u(BY).Il is not a function. (In 'u(BY).Il(q.a(n))', 'u(BY).Il' is undefined), stack::infer-externs to false!?^js typehints where required. :infer-externs false just turns of the warnings. see https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs:target :react-native where would I put files to load on demand via (js/require "data.json")? Is there some assets/resource path to configure?js/require the file with a relative path to the output fileexport ... format instead of Object.defineProperty(module.exports, ...)?:npm-module targetnode_modules folder wherever you are running or post-processing a release build with ncc{:source-paths ["src" "test"]
:dependencies [[com.taoensso/timbre "4.10.0"]
[macchiato/core "0.2.16"]]
:builds {:app {:devtools {:repl-init-ns backend.core
:repl-pprint true}
:main backend.core/server
:target :node-script
:source-map true
:exports {:server backend.core/server}
:output-dir "target"
:output-to "target/main.js"
:compiler-options {:optimizations :simple}}}
:nrepl {:init-ns backend.core}}
^ My edn file looks like this but where do I put development dependencies. Can’t see example from the official doc. I want to include [binaryage/devtools "1.0.2"]:profiles {:dev {:source-paths ["dev"]
:repl-options {:init-ns user}
:dependencies [[midje "1.9.9"]
[ring/ring-mock "0.4.0"]]
:aliases {"test-ancient" "midje"
"upgrade-deps" ["ancient" "upgrade" ":all" ":check-clojure"]}
:bikeshed {:max-line-length 120
:docstrings false}}
^ Would using dev profile work? (This is from my leiningen project.clj )@aws-amplify/ui-react npm packages, but I'm getting the following compilation warning:
[2020-12-05 22:23:46.005 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-1f3b9bdc.js", :requires [{:line 1628, :column 73}]}
The referenced code looks like it's doing some weird webpack magic to require files:
return Promise.resolve().then(function () { return _interopNamespace(require(
/* webpackInclude: /\.entry\.js$/ */
/* webpackExclude: /\.system\.entry\.js$/ */
/* webpackMode: "lazy" */
`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {
{
cmpModules.set(bundleId, importedModule);
}
return importedModule[exportName];
}, consoleError);
I'm not exactly sure what's going on, but it seems like the @aws-amplify/ui-components package may be requiring webpack to function?
Anyway the end result in the UI is that when I try to use the Amplify UI components I get errors like these in the console:
Module not provided: ./amplify-authenticator.cjs.entry.js Module not provided: ./amplify-nav_2.cjs.entry.jsThese
*.entry.js files exist in the node_modules/@aws-amplify/ui-components/dist/cjs/ directory but it looks like because of the aforementioned error they are not properly getting loaded.
Does anyone know of any workaround to get this working?package.json:external. that way you can let webpack process all the npm dependencies together@aws-amplify/ui-react": "0.2.24 with no problem using the defaults for the :browser target. Havent tried the latest version which seems to be https://github.com/aws-amplify/amplify-js/releases/tag/%40aws-amplify%2Fui-react%400.2.31watch command. The compilation still works, but that’s making the console unusable.
[:failed-to-compare "^7.8.7" "7.12.5" #error {
:cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:via
[{:type java.lang.NullPointerException
:message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
:trace
[[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]
[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]
[shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]
[shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17482 invoke "npm_deps.clj" 46]
[clojure.lang.Delay deref "Delay.java" 42]
[clojure.core$deref invokeStatic "core.clj" 2320]
[clojure.core$deref invoke "core.clj" 2306]
[shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17484 invoke "npm_deps.clj" 52]
[shadow.build.targets.browser$check_npm_versions$fn__18133$fn__18134 invoke "browser.clj" 826]
[clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]
[clojure.core.protocols$fn__8138 invokeStatic "protocols.clj" 75]
[clojure.core.protocols$fn__8138 invoke "protocols.clj" 75]
[clojure.core.protocols$fn__8088$G__8083__8101 invoke "protocols.clj" 13]
[clojure.core$reduce invokeStatic "core.clj" 6828]
[clojure.core$reduce invoke "core.clj" 6810]
[shadow.build.targets.browser$check_npm_versions$fn__18133 invoke "browser.clj" 818]
[shadow.build.targets.browser$check_npm_versions invokeStatic "browser.clj" 817]
[shadow.build.targets.browser$check_npm_versions invoke "browser.clj" 799]
[shadow.build.targets.browser$process invokeStatic "browser.clj" 854]
[shadow.build.targets.browser$process invoke "browser.clj" 838]
[clojure.lang.Var invoke "Var.java" 384]
[shadow.build$process_stage$fn__14212 invoke "build.clj" 148]
[shadow.build$process_stage invokeStatic "build.clj" 145]
[shadow.build$process_stage invoke "build.clj" 137]
[shadow.build$compile invokeStatic "build.clj" 408]
[shadow.build$compile invoke "build.clj" 397]
[shadow.cljs.devtools.api$release_STAR_ invokeStatic "api.clj" 353]
[shadow.cljs.devtools.api$release_STAR_ invoke "api.clj" 340]
[shadow.cljs.devtools.cli$do_build_command invokeStatic "cli.clj" 29]
[shadow.cljs.devtools.cli$do_build_command invoke "cli.clj" 26]
[shadow.cljs.devtools.cli$do_build_commands invokeStatic "cli.clj" 51]
[shadow.cljs.devtools.cli$do_build_commands invoke "cli.clj" 40]
[shadow.cljs.devtools.cli$main$body_fn__17101__auto____17691 invoke "cli.clj" 168]
[shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 167]
[shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$apply invoke "core.clj" 660]
[shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]
[shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 665]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}]
I google for hours and no result, I’m curious is there a way for me to debug the process of compilation. Thanks very much.{:paths ["src/main"]
:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
rum/rum {:mvn/version "0.12.3"}
;; rum {:local/root "/home/tienson/codes/source/clj/rum"}
;; persistent-sorted-set {:mvn/version "0.1.2"}
;; FIXME: doesn't work on my archlinux laptop (tienson)
;; The required namespace "datascript.core" is not available, it was required by "frontend/db.cljs".
datascript/datascript {:git/url "",
:sha "7c2822565d9a114c7d8604c335af89de4640e2e5"}
;; datascript {:mvn/version "1.0.1"}
datascript-transit/datascript-transit
{:mvn/version "0.3.0"
:exclusions [datascript]}
funcool/promesa {:mvn/version "4.0.2"}
medley/medley {:mvn/version "1.2.0"}
metosin/reitit-frontend {:mvn/version "0.3.10"}
cljs-bean/cljs-bean {:mvn/version "1.5.0"}
prismatic/dommy {:mvn/version "1.1.0"}
org.clojure/core.match {:mvn/version "1.0.0"}
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
cljs-drag-n-drop/cljs-drag-n-drop
{:mvn/version "0.1.0"}
borkdude/sci {:mvn/version "0.1.1-alpha.6"}
hickory/hickory {:mvn/version "0.7.1"}
hiccups/hiccups {:mvn/version "0.3.0"}
tongue/tongue {:mvn/version "0.2.9"}
org.clojure/core.async {:mvn/version "1.3.610"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
expound/expound {:mvn/version "0.8.6"}
lambdaisland/glogi {:mvn/version "1.0.74"}}
:aliases {:cljs {:extra-paths ["src/dev-cljs/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.597"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
binaryage/devtools {:mvn/version "0.9.10"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cider/cider-nrepl {:mvn/version "0.23.0-SNAPSHOT"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:test
{:extra-paths ["src/test/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
org.clojure/test.check {:mvn/version "RELEASE"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:runner
{:extra-deps
{com.cognitect/test-runner
{:git/url "",
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
:main-opts ["-m" "cognitect.test-runner" "-d" "test"]}}}
and the shadow-cljs.
{:deps true
:nrepl {:port 8701}
:builds
{:app
{:target :browser
:module-loader true
:modules {:main {:init-fn frontend.core/init}
:code-editor
{:entries [frontend.extensions.code]
:depends-on #{:main}}}
:output-dir "./static/js"
:asset-path "/static/js"
:release {:asset-path ""}
:compiler-options {:infer-externs :auto
:output-feature-set :es6
:externs ["datascript/externs.js"
"externs.js"]}
:closure-defines {goog.debug.LOGGING_ENABLED true
frontend.config/GITHUB_APP_NAME #shadow/env "GITHUB_APP2_NAME"}
:devtools
;; before live-reloading any code call this function
{:before-load frontend.core/stop
;; after live-reloading finishes call this function
:after-load frontend.core/start
:preloads [devtools.preload]}}
:test
{:target :node-test
:output-to "static/tests.js"}
:publishing
{:target :browser
:module-loader true
:modules {:main {:init-fn frontend.publishing/init}
:code-editor
{:entries [frontend.extensions.code]
:depends-on #{:main}}}
:output-dir "./static/js/publishing"
:asset-path "/static/js"
:closure-defines {frontend.config/PUBLISHING true
goog.debug.LOGGING_ENABLED true}
:compiler-options {:infer-externs :auto
:output-feature-set :es6
:externs ["datascript/externs.js"
"externs.js"]}
:devtools
;; before live-reloading any code call this function
{:before-load frontend.core/stop
;; after live-reloading finishes call this function
:after-load frontend.core/start
:preloads [devtools.preload]}}}}app target is :browsernode ?clojure -M:cljs watch app , I use this command. Thank you all the same, Your help may lead me to find a solution : )brew upgrade unconsciously yesterday 😭thheller/shadow-cljs {:mvn/version "2.8.81"} is ancient history by noworg.clojure/clojurescript {:mvn/version "1.10.520"}ReferenceError: $jscomp is not defined in a release build points towards an issue with polyfills?$jscomp is polyfills. thought I fixed all the issues though?2.11.5 in this project, let me try upgrading first:output-feature-set is always the best option:output-feature-set :es8:node reader conditional but the issue with that is that that forces the namespace to be .cljc and our code isn’t necessarily valid Clojure (it uses js/ etc):external an let that file be processed by browserify as usual https://shadow-cljs.github.io/docs/UsersGuide.html#js-providerfunction onChange(value) {
console.log("Captcha value:", value);
}
ReactDOM.render(
<ReCAPTCHA
sitekey="Your client site key"
onChange={onChange}
/>,
document.body
);
But I try this in ClojureScript and I am getting nothing in the console
(defn onChange [value]
(println value)
)
($ ReCAPTCHA
{ :sitekey "Your client site key"
:onChange #(onChange) })
(note $ is helix lib)
it tell me that wrong number of args (0) passed to onChange
Can someone please tell where am I wrong?onChange expects an argument .`onChange={onChange}` means call the function onChange with the event. #(onchange) means is a shorthand for (fn [event] (onchange)) where you are not sending the event through. just do :onChange onChange which is exactly what the js version is doing(fn [event] (onchange)) anonymous function?#(onchange) expands to in essence. and its calling a 1 arity function with no args. which is what your error isNamespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import d3 from 'goog:module$node_modules$d3$dist$d3_node';? Any idea why? The line it points out have this: import * as d3 from "d3";import d3 from "d3", unfortunately the closure folks made that change in a strict way. cant' cheat anymore:target :browser
:compiler-options {:output-feature-set :es6}
:js-options {:babel-preset-config {:modules "commonjs"
:targets "chrome > 70"}}
there's always this small JS block in the result (after formatting it):
if ("undefined" !== typeof Symbol) {
var c = Symbol;
"object" != typeof c || !c || c instanceof Array || c instanceof Object || Object.prototype.toString.call(c)
}
It doesn't seem to have any effect and I couldn't find where it comes from.
Do you have any idea?cljs.core. look for js/Symbol dunno why its not removed either.js/Symbol usage and none of them seems to be the culprit.Assert failed: Component must not be nilI'm importing as such
(ns goodstats.stats
(:require [reagent.ratom :as ratom]
[reagent.core :as reagent]
[ajax.core :as ajax]
[clojure.edn :as edn]
["@weknow/react-bubble-chart-d3" :refer (BubbleChart)]
["recharts" :as recharts]))
(def BubbleChart (reagent/adapt-react-class BubbleChart))
In the README they say that one needs to import React as the component does not import it, but I assumed Reagent already imported react (since I'm using other react components). Does anyone know what I'm doing wrong?The required JS dependency "core-js/es6/math" is not available, it was required by "node_modules/recharts/lib/polyfill.js".
Dependency Trace:
goodstats/index.cljs
goodstats/stats.cljs
node_modules/recharts/lib/index.js
node_modules/recharts/lib/polyfill.js
index.cljs imports all others so I'm able to fix the missing dependency on all but index.cljs by adding the following to index.cljs
(:require ["core-js/es6/math"])Resulting in this. And now I don't know how to proceed.
The required JS dependency "core-js/es6/math" is not available, it was required by "goodstats/index.cljs".
Dependency Trace:
goodstats/index.cljs
node_modules/recharts/package.json matches the actual node_modules/core-js/package.json version["@weknow/react-bubble-chart-d3" :refer (BubbleChart)] should be ["@weknow/react-bubble-chart-d3" :as BubbleChart]["@weknow/react-bubble-chart-d3" :default BubbleChart] see the translation table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packagesWARNING: When invoking clojure.main, use -M
$ npx karma start --single-run
13 12 2020 20:36:56.964:WARN [filelist]: Pattern "/builds/buidler/prj/target/ci.js" does not match any file.
13 12 2020 20:36:56.975:INFO [karma-server]: Karma v5.2.3 server started at
13 12 2020 20:36:56.976:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
13 12 2020 20:36:56.983:INFO [launcher]: Starting browser ChromeHeadless
13 12 2020 20:36:58.523:INFO [Chrome Headless 87.0.4280.66 (Linux x86_64)]: Connected on socket tCMp7MAbveBvUWK6AAAA with id 26441006
Chrome Headless 87.0.4280.66 (Linux x86_64) ERROR
ReferenceError: shadow is not defined
at eval (eval at <anonymous> (/builds/buidler/prj/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)
at ContextKarma.start (/builds/buidler/prj/node_modules/karma-cljs-test/adapter.js:6:7)
at ContextKarma.loaded ()
at
Cleaning up file based variables
ERROR: Job failed: exit code 1
It just randomly started happening without any related changes. Now if I go back to the last passing build and try to rebuild it, that fails too.13 12 2020 20:36:56.964:WARN [filelist]: Pattern "/builds/buidler/prj/target/ci.js" does not match any file.tap> function. I tried to add it as middleware, but taps are not communicated to the JVM (I think this is basic cljs vs clj repl). Anyone has an idea how we can solve this "easily"? Maybe create a server listening to the same websocket as shadow-cljs and forwarding this to reveal?remote-prepl at https://vlaaad.github.io/revealrc/incline from JavaScript?
https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745rc/inline to get a binary blob?(clojure.string/join ["ab" "cd"]) Timeout while waiting for result.
[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)(require '[orgpad.client.db.get :as db-get]) => nilI can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------ Resource: <eval>:1:2 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name) -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var db-get/latest-editor --------------------------------------------------------------------------------
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? NPM dependency "react" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.8 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :clientBut I updated anyway using
npm install -g shadow-cljs where I got
+
server version: 2.11.8 looks fine yeahclj -m shadow.nrepl-debug 3000 3001clj -m shadow.nrepl-debug 9001 9000 would work if you then connect your editor to 9001 instead of 9000Connecting to remote nREPL server... Clojure 1.10.1 (shadow/repl :client) To quit, type: :cljs/quit => [:selected :client] (+ 1 2) Timeout while waiting for result. (+ 1 2) Timeout while waiting for result. (+ 1 2) Timeout while waiting for result.
cljs/user.cljs file on the classpath?clj -A:shadow-cljs-dev watch appcommand I get a server up and running and things are great. But after I quit it with "ctrl + z" the server lingers forever. I can go to localhost:8700 and still see my app running there. If I restart the watch app then it will says that my build is stale and was not produced by the current watcher. Only workaround is to change the port. Anyone know how to fix this? Reboot doesn't help either. So something is cached somewhere? My deps.edn alias:
:shadow-cljs-dev
{:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
re-frame/re-frame {:mvn/version "1.1.2"}
binaryage/devtools {:mvn/version "1.0.2"}
re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305
re-frame/re-frame]}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
I have manually killed all the processes, rebooted the pc etc. But when I go to localhost:8700, the app is still being served there. And in the corner it says "shadow-cljs reconnecting...". If I try to start a new watch on that same port it will say that it is stale.:/mnt/c/bec-core$ fg -bash: fg: current: no such job :/mnt/c/bec-core$ npx shadow-cljs fg shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn shadow-cljs - starting via "clojure" Invalid action "fg"
fg only works after you ctrl+z a process. it is not a shadow-cljs command, its a linux thing$ clj -M:run Syntax error (FileNotFoundException) compiling at (vorstellung/middleware.clj:1:1). Could not locate vorstellung/env__init.class, vorstellung/env.clj or vorstellung/env.cljc on classpath. Full report at: /tmp/clojure-14799446093176938932.edn
shadow-cljs folderdeps.edn using :resource-paths. that is not a thing in deps.ednjustify-content: center; css rule on one element which causes everything to center.MuiButtonBase-rootlein run doesn't work at all for me I get some swagger stuff:dev-http static webserver? the server parts are the confusing bits for melein-shadow to 2.11.10 so both variants use the same version:js-options {:entry-keys ["browser" "main"]} to your build config which appears to make it work:js-options {:entry-keys ["browser" "main"]} solve this issue. That’s great!esm path to all requires["@material-ui/icons/Build" :default Build] you use ["@material-ui/icons/esm/Build" :default Build]:js-options {:entry-keys ["browser" "main"]} this way is fine now. Thank you for your time. It helps a lot.shadow.cljs.devtools.client.websocket.js:sourcemap:4 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
shadow$cljs$devtools$client$websocket$start @ shadow.cljs.devtools.client.websocket.js:sourcemap:4
eval @ shadow.cljs.devtools.client.shared.js:sourcemap:467
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shadow.cljs.devtools.client.shared.js:sourcemap:929
eval @ shadow.cljs.devtools.client.browser.js:sourcemap:952
goog.globalEval @ app.js:577
env.evalLoad @ app.js:1670
(anonymous) @ app.js:1945
shadow.cljs.devtools.client.shared.js:sourcemap:651 shadow-cljs - remote-error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
This wouldn't be a problem if I could run the watch command again and just be able to continue developement from the same port again, but I instead get this message:
"Shadow-cljs - stale output! Your loaded js was not produced by the running shadow-cjs instance. Is the watch running?"
Even if I try to delete the .shadow-cljs folder, the .cpcache folder and remove the app.js files, it will still say this as long as I use the same port.jps or so{
"name": "bec-core",
"version": "0.0.1",
"private": true,
"scripts": {
"watch-app": "clj -A:shadow-cljs-dev watch app",
"release-app": "clj -A:shadow-cljs-prod release app",
"cljs-repl": "clj -A:shadow-cljs-dev cljs-repl app"
},
"dependencies": {
"react": "16.13.0",
"react-dom": "16.13.0"
}
}
That is my package.json and I run
npm run watch-appIt builds etc just fine and then I press "ctrl + c"
shako$ npm run watch-app >
jps to see if there is a running java processshako$ jps 7582 Jps shako$ jps -l 7600 jdk.jcmd/sun.tools.jps.JpsI haven't used jps before. I am not exactly sure what to expect. :x
C:>jps 12576 RemoteMavenServer36 18528 Jps 17028 RemoteMavenServer36 3204 RemoteMavenServer36 5796 RemoteMavenServer36 6472 RemoteMavenServer36 12908 RemoteMavenServer36 14380 RemoteMavenServer36 12592 RemoteMavenServer36 16336 3408 RemoteMavenServer36 8592 RemoteMavenServer36 11316 RemoteMavenServer36 10552 RemoteMavenServer36 3672 RemoteMavenServer36 13212 RemoteMavenServer36
C:>jps -l 12576 org.jetbrains.idea.maven.server.RemoteMavenServer36 17028 org.jetbrains.idea.maven.server.RemoteMavenServer36 3204 org.jetbrains.idea.maven.server.RemoteMavenServer36 5796 org.jetbrains.idea.maven.server.RemoteMavenServer36 6472 org.jetbrains.idea.maven.server.RemoteMavenServer36 12908 org.jetbrains.idea.maven.server.RemoteMavenServer36 14380 org.jetbrains.idea.maven.server.RemoteMavenServer36 12592 org.jetbrains.idea.maven.server.RemoteMavenServer36 16336 3408 org.jetbrains.idea.maven.server.RemoteMavenServer36 8592 org.jetbrains.idea.maven.server.RemoteMavenServer36 11316 org.jetbrains.idea.maven.server.RemoteMavenServer36 22100 jdk.jcmd/sun.tools.jps.Jps 10552 org.jetbrains.idea.maven.server.RemoteMavenServer36 3672 org.jetbrains.idea.maven.server.RemoteMavenServer36 13212 org.jetbrains.idea.maven.server.RemoteMavenServer36
ps or sonpm and clj and either of those may be causing the server to linger. I can't say. I can only help with actual running shadow-cljs commandsshadow-cljs command?Running with clj directly.
{:paths [...]
:deps {...}
:aliases
{:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
clj -A:shadow-cljs watch app
Is what I followed in the documentation. Perhaps I am just too noob to know how to properly setup and run with deps.edn :sshadow-cljs watch app and so on{:paths ["src" "resources" "target"]
:deps
{org.clojure/clojure {:mvn/version "1.10.1"}}
:aliases
{:cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
re-frame/re-frame {:mvn/version "1.1.2"}
binaryage/devtools {:mvn/version "1.0.2"}
re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305
re-frame/re-frame]}}}}}
shadow-cljs.edn
{:deps {:aliases [:cljs]}
:builds
{:app
{:target :browser
:output-dir "resources/public/js"
:modules {:app {:entries [bec-core.cljs.core]}}
:js-options {:js-package-dirs ["node_modules"]}
:compiler-options {:infer-externs :auto}
:dev {:closure-defines {goog.DEBUG true}}
:devtools
{:before-load bec-core.cljs.core/stop
:after-load bec-core.cljs.core/start
:http-root "resources/public"
:http-port 8711
:preloads [devtools.preload
re-frisk.preload]}}}}
Running it like this:
$ npx shadow-cljs watch app shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn shadow-cljs - starting via "clojure" shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.8 running at shadow-cljs - nREPL server started on port 60273 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (270 files, 59 compiled, 0 warnings, 24.61s) ^C $ Worker shutdown. npx shadow-cljs stop app shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn shadow-cljs - server not runningI don't know how to exlude refrisk and dev-tools dependancies from the release version of the app. Also even when I run shadow-cljs through npx it still has the same issue. I can't stop the server with ctrl + c. The browser still shows the old app running and a new watch on the same port won't update anymore. It will just ocmplain about a stale build.. 😕
:js-options {:js-package-dirs ["node_modules"]}
:compiler-options {:infer-externs :auto}
:dev {:closure-defines {goog.DEBUG true}}clojure version?$ clj --help Version: 1.10.1.561
shadow-cljs server and ctrl+c that the process still lingers?$ npx shadow-cljs server shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn shadow-cljs - starting via "clojure" shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.8 running at shadow-cljs - nREPL server started on port 50490 ^CTHe page at http://localhost:9630 dissappears when I reload it. So it works as expected when I ctrl + c. But http://localhost:8712 is still there. "Shadow-cljs - reconnecting..." And when I start the server the message just becomes "Shadow-cljs stale build etc."
C:\bec-core>jps -l 10088 jdk.jcmd/sun.tools.jps.Jps 1980Ubuntu terminal result:
bec-core$ jps -l 9068 jdk.jcmd/sun.tools.jps.Jps
serves nothing(try
(-> (. js/navigator.serviceWorker (register "/service-worker.js"))
(.then (fn [] (js/console.log "service worker registered"))))
(catch js/Object err (js/console.error "Failed to register service worker" err)))
And now the browser is properly letting go. So it is probably a chrome issue. I wonder how to fix it...watch build ever. just disable that in the worker.:release {:output-dir "somewhere/else"}:default on vanilla CLJS.
https://clojure.atlassian.net/browse/CLJS-2376(:require ["foo$default" :as x]) will be the default solution but I don't think it is released yet(:require ["foo" :default x]). you can also always do (:require ["foo" :as x]) and then x/default(ns
(:require
[shadow.react-native :refer (render-root)]
["react-native" :as rn]
["react" :as react]
[reagent.core :as r]
["react-native-alarm-clock" :default AlarmClock]))
(defn create []
(let [date (.toISOString (js/Date.))]
(.createAlarm AlarmClock date "Alarm test")))["react-native-alarm-clock" :as AlarmClock]?_default"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
const {
AlarmClock
} = _reactNative.NativeModules;
var _default = AlarmClock;
exports.default = _default;
//# sourceMappingURL=index.js.mapmaster. just not in any official release I think.foo.bar somewhere in your codefoo/bar.cljs or foo/bar.cljc( "foo/bar.cljc"):ns-runner but beyond that it's hazy...npx create-cljs-project web-syntax-highligh and got
web-syntax-highlight
├── node_modules
|-- REDACTED
├── package.json
├── package-lock.json
├── shadow-cljs.edn
└── src
├── main
└── test
It is a bit surprising - no files are present?
Is this expected?;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:builds
{}} import "some_node_module/some.css"Is something similar possible with Shadow? I could
cp node_modules/some_node_module/some.css public every time before I deploy but ☝️ is even less effort.(ns app.monaco
(:require [reagent.core :as r]
["@monaco-editor/react" :as Editor]))
(defn editor []
[:<>
[:p "Hello, hledger-web-demo is running!"]
[:p "Here's an example of using a component with state:"]
[(r/adapt-react-class Editor/default) {:height "90vh" :languge "javascript"}]])
[:> Editor/default ,,,] instead of r/adapt-react-class.)(ns app.monaco
(:require [reagent.core :as r]
["react-monaco-editor" :default monaco]))
----
Failed to inspect file
/home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css
it was required from
/home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js
Errors encountered while trying to parse file
/home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css
{:line 8, :column 1, :message "primary expression expected"}
Object.assign and I want shadow-cljs handle polyfills for me such that the resulting JS bundle works with IE11, I just need to add :js-options {:babel-preset-config {:targets {:ie 11}}} into my shadow-cljs.edn. That doesn't appear to work, though: I still get Object doesn't support property or method 'assign'. Should that work, or should I take another approach?
FWIW:
λ du -hs .shadow-cljs/babel-worker/babel-worker.js 2.8M .shadow-cljs/babel-worker/babel-worker.js
$jscomp error? I'm seeing this on the console of my release build occasionally.
shadow-cljs - failed to load 973
jLb @ main.js:14558
CZ @ main.js:14559
(anonymous) @ main.js:15924
(anonymous) @ main.js:18690
main.js:6386 Uncaught ReferenceError: $jscomp is not defined
at main.js:6386
at main.js:6028
at Object.shadow$provide.<computed> (main.js:6028)
at jLb (main.js:14558)
at main.js:6630
at Object.shadow$provide.<computed> (main.js:6630)
at jLb (main.js:14558)
at Object.shadow$provide.<computed> (main.js:6770)
at jLb (main.js:14558)
at Object.shadow$provide.<computed> (main.js:6771)
This is reproducible with the same code. However, I cannot find what in the code is inducing this behavior.$jscomp is for polyfills. which version do you use? I thought I had fixed those issues. if you can afford it the best option is setting :compiler-options {:output-feature-set :es6} or higher if you can (:es7, :es8, ...)2.11.8:compiler-options {:force-library-injection #{"es6/object/assign"}}:force-library-injection if I need polyfills for other things?Symbol.for, so I need to figure out a way to add one myself.shadow$umd$export = {MyName:MyName}
instead of
shadow$umd$export = {MyName:kA}
I want the meaningful name to be available for debugging when logging this object in the consoleMyName to externs it won't be renamed. https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externsns/var or ns$var ?(defnc my-component []
{:helix/features {:fast-refresh true}} ;; turn on compile-time processing for react-refresh
)
I'm trying to figure out an easy way for consumers to enable this globally w/o wrapping the defnc macro. wdyt?:closure-defines but I don't think that would work here, since I don't think I can get at those during compile-time to know whether I should do the processingcommit 4a9ea2d9e07c6f87364ef9f613b31751e935be8f (HEAD -> strip-secure-2.10-backport, refs/patches/strip-secure-2.10-backport/dev-http-strip-secure-cookies) Author: Greg Haskins <
cannot instantiate non-constructor when I run shadow-cljs check buildName despite trying simple externs ConstructorThing and manual externs
/**
* @constructor
*/
constructorThing = function() {};^js/ to the namecheck is not reliable. thats why it is not documented. it will always give you a lot of false positivescommit 836ec3dfe35bc3342f76e5ed0373163e8f8b47c5 (HEAD -> strip-secure-2.10-backport) Author: Greg Haskins <
(shadow/browser-repl)?(shadow/browser-repl {:devtools {:repl-timeout 3000000}})#{...} generates a twice as large code than (set #js [...]) which generates the set at the start. Why is that?:advanced? that usually takes care of that?shadow-cljs run shadow.cljs.build-report app report.html
(set #js [...]) looks:
var oRa = $APP.Cj("aaa aarp abarth abb abbott abbvie ... [a lot more] ... yoga yokohama you youtube yt yun za zappos zara zero zip zm zone zuerich zw".split(" "));
Which looks like a clever Google Closure optimization.
And this is how #{...} looks:
var oRa = new $APP.yj(null,new $APP.m(null,1504,["studio", null, "etisalat", null, "mortgage", null, "xn--gecrj9c", null, "technology", null, "nl", null, "lilly", null, "wolterskluwer", null, "schmidt", null, "hisamitsu", null, "total", null, "blue", null, "aw", null, "zw", null, "properties", null, "amex", null, "linde", null, "arpa", null, "ieee", null, ... [a lot more] ... , "fairwinds", null, "lk", null, "itau", null],null),null);Not sure why set constructor has alternating strings with nulls.
orgpad.common.util.tld.all_tlds = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1504, ["studio",null,"etisalat",null,"mortgage",null,"xn--gecrj9c",null,"technology",null,"nl",null,"lilly",null,"wolterskluwer",null,"schmidt",null,"hisamitsu",null,"total",null,"blue",null,"aw",null,"zw",null,"properties",null,"amex",null,"linde",null,"arpa",null,"ieee",null, ... [a lot more] ...,"fairwinds",null,"lk",null,"itau",null], null), null);No idea why inner PersistentArrayMap is created. The former corresponds to this:
orgpad.common.util.tld.all_tlds = cljs.core.set(["aaa","aarp","abarth","abb","abbott","abbvie", ... [a lot more] ...,"yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"]);
npx shadow-cljs watch …ws npm package.:require "ws" it isn't in a spot where sente expectsgoog/global obj (this what I am planning right now), should I issue some kind of PR to sente, or does Shadow have some cool workaround in the config I can setup?websocket package, not ws? it certainly tries to hide that require as much as possible 😛ws is the npm websocket package complicating this all the more 😂ws package. there is an actual websocket package they expect. at no point do I see any reference to ws?ws package for node so you'll need both but as far as sente is concerned that expects websocket(clojure.string/join ["ab" "cd"]) Timeout while waiting for result.[4:10 PM] And shadow-cljs outputs this into console:
[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
[4:10 PM] Any idea what could be causing this or how I could debug where is the problem?
[4:12 PM] Also, all previous requires are lost when this happens. So for instance, I run the following code before:
(require '[orgpad.client.db.get :as db-get]) => nilI can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------ Resource: <eval>:1:2 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name) -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var db-get/latest-editor --------------------------------------------------------------------------------
shadow-cljs release should I be able to serve the app just from my browser by opening index.html or will I always need a webserver?#?(:cljs ["@kunukn/react-collapse" :default Collapse]) but when it's rendered this happens:ERROR [com.fulcrologic.fulcro.react.error-boundaries:31] - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.first time I've run into an error like this, not sure if there's something special about importing this module into shadow-cljs?
Collapse is nil. might be :as Collapse or :refer (Collapse):as Collapsensexport default Collapse in the library, so I thought it'd be a default exportWarning :infer-warning in rocks/mygiftlist/http_remote.cljs at 106:8
Cannot infer target type in expression (. inst_93897 (setResponseType inst_93951))
103 | (fn transmit! [{:keys [active-requests]}
104 | {::txn/keys [ast result-handler update-handler]
105 | :as send-node}]
106 | (go (let [edn (eql/ast->query ast)
107 | ok-handler (fn [result]
108 | (try
109 | (result-handler result)
110 | (catch :default e
Full source is at https://github.com/codonnell/mygiftlist-blog/blob/dokku-deploy/src/cljs/rocks/mygiftlist/http_remote.cljs
The error message seems to reference https://github.com/codonnell/mygiftlist-blog/blob/dokku-deploy/src/cljs/rocks/mygiftlist/http_remote.cljs#L150, which is already hinted.closure-defines for this kind of configuration. https://clojurescript.org/reference/compiler-options#closure-defines & goog-define https://cljs.github.io/api/cljs.core/goog-define where the second argument would be your default localhost addressshadow-cljs.edn config I have my cljs worker build configured like this;
{:builds {:cljs-worker {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:optimizations :simple}
:modules {:cljs-worker-base {:entries [shadow.cljs.bootstrap.env]}
:cljs-worker {:init-fn workers.cljs.core/init!
:depends-on #{:cljs-worker-base}
:web-worker true}}}
In workers.cljs.core i’ve got;
(ns workers.cljs.core
(:require [cljs.env :as env]
[cljs.js :as cljs]
[shadow.cljs.bootstrap.browser :as boot]))
(defn- process-response
[{:keys [error value] :as result}]
(when (some? error)
(js/console.log "ERROR")
(js/console.error error))
(when (some? value)
(js/console.log "VALUE")
(js/console.log value))
result)
(defonce compile-state-ref (env/default-compiler-env))
(defn evaluate [code]
(cljs/eval-str
compile-state-ref
code
nil
{:eval cljs/js-eval
:load (partial boot/load compile-state-ref)}
process-response))
(defn init! []
(boot/init compile-state-ref {:path "/js"} #(evaluate "(+ 1 1)")))
which was inspired by https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html - Configured this way results in the following error;
failed to download boostrap file:/js/index.transit.json It seems this file is only generated when setting the target to bootstrap?
Changing my config to more closely match the blog post generates index.transit.json but does not build modules.
:cljs-worker
{:target :bootstrap
:output-dir "resources/public/js"
:asset-path "/js"
:compiler-options {:optimizations :simple}
:modules {:cljs-worker-base {:entries [shadow.cljs.bootstrap.env]}
:cljs-worker {:entries [cljs.js]
:exclude #{cljs.js}
:macros []
:init-fn workers.cljs.core/init!
:depends-on #{:cljs-worker-base}
:web-worker true}}}
Is there a configuration that will allow me to build a worker supporting self-hosted cljs?failed to download boostrap file:/js/index.transit.json looks like you are trying to do this directly from the filesystem? that won't work, you need a http server. you can use :dev-http:modules does nothing in :bootstrapindex.transit.json is loaded directly in shadow.cljs.bootstrap.browser/init.
I’m running a dev server using;
:devtools {:http-root "resources/public"
:http-port 9000
:preloads [shadow.remote.runtime.cljs.browser]}
I changed my bootstrap build to
:cljs-worker
{:target :bootstrap
:output-dir "resources/public/js/workers/cljs"
:compiler-options {:optimizations :simple}
:entries [cljs.js workers.cljs.core]
:exclude #{cljs.js}
:macros []}
and that is compiling everything under the output-dir but I’m not sure what js file I’m supposed to load into my web worker?
Taking a looking at the bootstrap-support build in shadow-cljs ’s shadow-cljs.edn config, it outputs to out/demo-selfhost/public/bootstrap. The index file in that dir loads <script src="/worker/js/base.js"></script> - Is there supposed to be a base.js file in the output?:modules control that in your case will be cljs-worker.js in the :output-dirfailed to download boostrap file:/js/index.transit.json this error suggests that you just loaded the index.html directly from the filesystem in the browser instead of cause one line to preserve it[12:02 AM] import React, { Component } from 'react'
import QrReader from 'react-qr-scanner'
class Example extends Component {
constructor(props){
super(props)
this.state = {
delay: 500,
result: 'No result',
}
this.handleScan = this.handleScan.bind(this)
}
handleScan(result){
if(result){
this.setState({ result })
}
}
handleError(err){
console.error(err)
}
render(){
const previewStyle = {
height: 240,
width: 320,
}
return(
<div>
<QrReader
delay={this.state.delay}
style={previewStyle}
onError={this.handleError}
onScan={this.handleScan}
/>
<p>{this.state.result}</p>
</div>
)
}
}
[12:04 AM] I converted it from class to functional in react then converted it to cljs:
(defn example
[]
(let [state (r/atom {})
preview-style {:height "240" :width "320"}]
[:<>
(fn []
[:div
[:> QrReader {:name "qr-reader"
:delay (:qr-reader @state)
:style preview-style
:on-error (fn [e]
(prn "You have an Error Bitch!"))
:on-scan (fn [e]
(swap! state assoc :qr-reader
(-> e .-target .-value)))}]])]))
I had made a few variations of the above and keep running into issues, any suggestions would be most welcome. Thankyou.I ran shadow-cljs server and then connected with a cljs-repl. Using the latest version of shadow-cljs and using the following config: {:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn app.client/init
:entries [com.kymetis.rav.app.client]}}
:devtools {:after-load app.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload
com.fulcrologic.fulcro.inspect.dom-picker-preload]}}}
:nrepl {:port 8777}
:open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}
server-token (in order to connect to api/remote-relay myself manually) to stdout when running shadow-cljs server ?.shadow-cljs/server.token has the token I need.shadow-cljs/shadow.user namespace.
However, after typing in the (shadow/repl :main) command to switch to a cljs repl, my namespace becomes nil and loading/switiching to other namespaces doesn't seem to work; they also return nil.
does anyone recognize what I might be doing wrong? I haven't had this problem before, and I don't recall making any changes that may have caused this.nil? You a switching with shadow/repl that turns the CLJ REPL into CLJS so you should start out at cljs.ujser?*ns* return nil when I make the switch. Although, it does seem to think i'm in cljs.user .
so here's what i'm seeing directly :*ns* is not a thing in CLJS. you can see the ns in the bottom right corner::foo or so*ns* worked in both versions. I must be losing my mind. Sorry for the trouble and thank you!cljs.pprint is in the report, but I don’t use it in my project. Also pathom which is only used in my .clj files.
I am asking myself if maybe fulcro (or another dependency) is pulling them in.(shadow/repl :build-id) to create a cljs repl, but I'm not getting it to work. I guess it's supposed to change the ns for me, but getting nothing. Works when running via lein repl :connect , changes the ns properly and drops my into a cljs repl, but no dice when manually connecting via sockets. Any ideas what I'm missing?lein one?shadow/repl expects my nrepl session to do? I'm assuming it'll return me a ns that I should switch to, while retaining the same session, or something like that but haven't quite figured it out yetshadow/repl switches the current session to CLJS. don't know if thats supposed to return something.{:op :hello} and then get the client id of the CLJS runtime you want to eval in{:op :cljs-eval
:to client-id
:input {:code "(+ 1 2)"
:ns 'cljs.user
:repl true}}:repl true is optional. if you don't care about *1 *2 and so on you can leave it out:call-id 123 with the request and the server will reply with that id in the message:node-library is there any way to do dynamic module loading? I’m working on a hybrid client / server ssr tool for cljs akin to next js. I have library code that I want to require client modules and for this to work on both the client and the server. The main issue I can forsee is if I try to have multiple entry points on the server. Any comments?
For more context:
• The tool is called clam.
• I have a node cli with a clam dev command that spawns a clj process, which then starts a shadow server and call watch* with 2 generated build configs.
• I generate 2 builds, a client and a server. :target :browser and target :node-library , currently these both import client react trees, with the server one adding http handlers and ssr.
• I want to augment this to support dynamic module loading on the client and control the loading experience. The issue I can see is that since its no longer a single require tree, I dont know how that will play with node-library:node-library cannot do this and isn't meant to no.:target :esm maybe that fits your needs.js files on diskshadow.loader which only works in :browser builds. you do not have to use that though. you can completely roll your own that works in both browser and node.js files outputted assumed a browser environment. Or that the files outputted with other builds don’t work without entries, etc.:browser target for use in an iOS / Android web view. On iOS I have it working. On Android there’s the issue however that Android has 10.0.2.2 as IP address of the host running the development environment, not localhost. So what I’m observing is that the initial load of my compiles JS bundle is working (because I load it from 10.0.2.2, but then ShadowCLJS tries to connect to localhost. I’ve tried setting :devtools-url` to , but then the websockets upgrade doesn’t work (“error during websocket handshake: unexpected response code: 200”). I have the feeling that it should be possible somehow, but how…? Thanks for any help / pointers!:devtools-url should point to the primary server. So it should have been . After changing that it worked. 🎉:browser but not by :esm ?goog.provide ?:esm currently but a little cleaner I guess. goog.provide is never part of an optimized build so I'm not sure what you mean. CLJS will continue to use that for a while.(System/getProperty "attribute-service.version")`npm install with the dependency in my project package.json file of `"@ndn/packet": "http://localhost:8000/packet.tgz"`. The package installs properly but fails when I run shadow-cljs to compile. I have tested using this package with webpack and node.js so I am confident that the Javascript stuff is working properly. Is there something I need to do with shadow-cljs to get this to work?
The compile fails with the following error:
(parallels) (27)# shadow-cljs compile app
shadow-cljs - config: /media/psf/DataPartition/lastmile/ttncore/shadow-cljs.edn
[:app] Compiling ...
npm package "@ndn/packet" expected version "@ndn/
[:app] Build completed. (225 files, 6 compiled, 0 warnings, 11.57s)
npm ls reports the following:
(parallels) (28)# npm ls | more
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f581819b969a8790b5c5dbc5dbc4"}, :content ("[email protected]")}
├─┬ @babel/
│ └──
├─┬ @ndn/
│ ├─┬ @ndn/
And here's a snippet from my package.json file:
"dependencies": {
"@babel/runtime": "^7.12.5",
"@ndn/packet": "",[:app] Build completed. (225 files, 6 compiled, 0 warnings, 11.57s) the build succeeded? the "expected version" thing is just a warning?deps.cljs which you don't really need?:dependencies
[
[cljsjs/hash "1.1.3-0"]
[cljsjs/msgpack-lite "0.1.26-0"]
[reagent "1.0.0-alpha2"]
[reagent-utils "0.3.3"]
]cljsjs deps since shadow-cljs will not use them anyways:npm-deps {:install false}. then it won't warn or attempt to install npm dependencies from deps.cljs. something in your dependencies or you project has a deps.cljs file which declares a :npm-deps dependency on "@ndn/packet" with version "@ndn/:npm-deps statement go?:npm-deps statement. Do I put it in my main.cljs file or create a deps.cljs file?shadow-cljs.edn at the top levelfind starting from root and grep to search the source tree).
Thanks.(parallels) (157)# shadow-cljs info shadow-cljs - config: /media/psf/DataPartition/lastmile/ttncore/shadow-cljs.edn === Version jar: 2.11.11 cli: 2.11.11 deps: 1.3.2 config-version: 2.11.11 === Java openjdk version "11.0.9.1" 2020-11-04 OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
"devDependencies": {
"onchange": "^7.1.0",
"shadow-cljs": "^2.11.11",
"tailwindcss": "^1.9.6"
},
2.11.12 which should get rid of the warning you asked about. it doesn't compare versions using http: etc anymore:js-options {:check-versions false} to turn the check off completely (true by default)build-state and made the mistake of printing its content 😛css macro or so that collects these things during compilation. much easier to extract but slightly more verbose in the code
(def button-style (css :border :p-2 :shadow :lg/p-4))or so
(tap> build-state) and look at it in the inspect UI:sources has all the sources:output has all the outputs of those sources (in :flush) stage, otherwise might still be empty[:compiler-env :cljs.analyzer/namespaces your.ns :your.thing/key] or so(tap> (get-in build-state
[:compiler-env
:cljs.analyzer/namespaces
'
:defs
'my-fn
:css]))
Big thank you !src path.
I have a deps.edn file with :paths ["src", "resources", ".x/resources"] and :deps true in shadow. File watching, recompile and hot-reload work if I have the file in src but not if the file is instead in resources or .x/resources . How do I fix that?
I’m starting the server and watch process in clojure using shadow.cljs.devtools.server/start! and shadow.cljs.devtools.api/watch* .".clam/src" What alternative paths are allowed.clam/src should be fine unless the dir is hidden:dev/always in the ns forces a recompile every time but what do you mean by "further up the tree"?x -requires-> y -requires-> z . When z changes I need to compute data with clojure and inject it into x . Currently the way I’m doing it is, y defs a var that evals a macro (which computes the data). Then x has a :dev/after-load hook which renders component defined in z, computed in macro in y . However, the require of yin x is stale when :dev/after-load is called (I assume because of hot reloading doesnt traverse up the tree like figwheel), so I need to do some stuff where I defer using var via wrapped function.
I realise this is probably super confusing.
But I was asking whether when z changes, which triggers y to be reevaluated, I could make x do the same, because I ’m assuming this would fix my issue?
It’s not super important since I got things working by creating a function that returns the function I want (in x), its just a bit unclear why this is needed.:dev/always fixes it!shadow/watch to compile + hot reload a bundle w/ a browser target and want a hook to run a shell script after the initial build. what’s the idiomatic way to do that in shadow?:build-hooks https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks(assoc build-state ::work-done true) and then check (::work-done build-state) if you did what you intended to dowatch so you can store stuff in it between each cycleshadow-cljs watch, and connecting to the REPL with Cider.
When I add a new dependency to shadow-cljs.edn, do I need to stop and restart the watch command in order to be able to use it, or is there something I can do via the REPL to install it and make it available right away?shadow-cljs watch, what should I do when I add a dependency?
Trying to restart the server by running shadow-cljs restart in another terminal seemed to break the connection with the browser and REPL.lein so that I can correctly compile the Java file I had in my project.
I'm also the kind of person who likes to write to learn, and I'm writing about the project setup. But to truly write something good I have to understand why I had to use lein (I honestly don't know, a friend simply said it would work if I did, and it worked). Is there any resource where I can understand if shadow-cljs can compile .java files, and if not, why it can't?appname maybe contain a -? Then the folder would need to be app_name:source-paths not :pathsimport './app/index.js';I get the error that it’s not registered
register-reload-comp iselement type is invalid: expected a string usually means that some component you are using was nil[:> something {:foo "bar"}] when something is nil you'll get this error{:name “Something”} maybe you want #js {:name “Something”}(defn init [] (rn/register-reload-comp "Something" root-comp))
(ns appname.core
(:require [steroid.rn.core :as rn]
["react-native" :refer (View AppRegistry SafeAreaView)]))
(defn root-comp []
[:> View "view"]
#_[rn/view
[rn/text "Hello CLojure! from CLJS"]])
(defn init []
(. AppRegistry registerComponent #js {:name "Something"} root-comp))
import './app/index.js';
{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[re-frame "0.12.0"]
[re-frame-steroid "0.1.1"]
[rn-shadow-steroid "0.2.1"]
[re-frisk-remote "1.3.3"]]
:builds {:dev
{:target :react-native
:init-fn appname.core/init
:output-dir "app"
:compiler-options {:closure-defines
{"re_frame.trace.trace_enabled_qmark_" true}}
:devtools {:after-load steroid.rn.core/reload
:build-notify steroid.rn.core/build-notify
:preloads [re-frisk-remote.preload]}}}}Root the name of your app? it needs to match whatever you have in app.json or so(defmacro test-page
[browser-types page-sym & body]
`(cljs.test/async done#
(cljs.core.async/go
(doseq [browser-type# ~browser-types]
(let [browser# (cljs.core.async.interop/<p! (.launch browser-type#))
page# (cljs.core.async.interop/<p! (.newPage browser#))
~page-sym page#]
And I call it like this:
(deftest smoke
(test-page [chromium] page
(<p! (.goto page ""))
(is (= "Nope" (<p! (.innerText page ".navbar__title"))))))
It works well, but I get a lot of inference warnings like this:
10 | (test-page [chromium] page ---------^---------------------------------------------------------------------- Cannot infer target type in expression (. inst_47307 (newPage))I'm not sure how to fix those warnings. Any ideas?
<script ...> to the html and use it via js/exportedThing ? Thank you!core.async loses ^js typehint information unfortunately so its kinda hard to typehint that stuff properly:compiler-options {:infer-externs true} (not :auto). that way you only get warnings if you (set! *warn-on-infer* true) in the nsgoog.module output it produces wasn't amenable for use with CLJSgoog.moduleshadow.cljs.devtools.api/watch programatically. Then, instead of running the watch task:
yarn shadow-cljs run dev/watchWhere
src/dev.clj has a watch function that does this(defn watch
{:shadow/requires-server true}
....git/index.lock. Not sure if it is worth it, just putting it out there.
Actually for the implementation, since shadow-cljs is already watching for file system changes to .cljs files, how about .git/index.lock as well?:deps true option?
https://shadow-cljs.github.io/docs/UsersGuide.html#deps-ednshadow-cljs.edn and deps.edn ?"1.10.597" which is the one shadow usesorg.clojure/clojurescript 1.10.773 might help:dependencies entry as the warning said.(reg-event-fx
:_id-persist
(fn [coeffects [_ id]]
(go
(try
(<p! (. AsyncStorage setItem "_id" id))
(catch js/Error e (prn "error is " e))))
{}
))["@react-native-async-storage/async-storage" :refer (AsyncStorage)]
:as AsyncStorage not :refer, or even :default AsyncStorage. see the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages:target implementations support this. what exactly do those files do? usually only files that are actually required by something will be included.import '@trendmicro/react-sidenav/dist/react-sidenav.css';
(ns react-sidenav
(:require [reagent.core :as r]
["@trendmicro/react-sidenav" :refer (Toggle Nav NavItem NavIcon NavText) :as lib]
["@trendmicro/react-sidenav/dist/react-sidenav.css"])):chrome-extension target and I’m wondering if the output also works in firefox since they both follow WebExtension standards.:chrome-extension target also works for firefox 🔥 :chrome-extension target also works for firefox 🔥 ^:dev/before-load and ^:dev/after-load are called, leading to a flash of unstyle page because the updated source code is using CSS classes which are defined in the CSS file which is not yet loaded in the front end.
What can I try to do to get things in this order instead?
1. ^:dev/before-load called
2. Source code and CSS reloaded in the front end
3. ^:dev/after-load called(shadow.cljs.devtools.api/nrepl-select :dev) I get the error:
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28). watch for build not runningI can see a shadow-cljs - server starting ....................................................................... ready! message in my console and everything else seems right. Any ideas as to what could be going wrong?
watch needs to be running. start only starts the server not the watch. you can either start the watch via the web UI at http://localhost:9630 or shadow-cljs watch <build-id>:dev/before-load-async has control over when the next step happensbuild-state in the compilation hook where the CSS is generated to mark the generated file as “updated” and hope that it would be sent to the front end in the same batch as the source code. Is this possible?:compile-finish , I collect every meta on every Clojure var from any namespace compiled.
Based on those informations, I generate some CSS content which I write into an output file, e.g. public/style/girouette.css, using spit. The file is not re-generated if its content is going to be the same.
During a shadow-cljs watch :front-end, when the front end developer changes his source and save it on the hard disk, Shadow-CLJS detects a change and recompile the source code. My compilation hook is triggered and a CSS file’s content may be updated.
In the browser, the source code is reloaded, front end hooks are called, and then afterward the new CSS (when it’s been regenerated) is reloaded in the browser.
My problem is that the CSS is reloaded separately from the source code, I am looking for a way to make Shadow-CLJS update the CSS file in the browser at the same time the source code is updated.(:require ["blah" :refer [blah]]) I'm getting this error TypeError: $jscomp.inherits is not a function. I'm currently using [org.clojure/clojurescript "1.10.773"] and [thheller/shadow-cljs "2.11.11"]. Has anyone seen anything like this and can point me to the right direction? Thanks.expound library to pretty-print spec failures. Here's how expound is supposed to work in cljs:
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.773"} expound {:mvn/version "0.8.7"}}}' -M -m cljs.main -re node
ClojureScript 1.10.773
cljs.user=> (require '[clojure.spec.test.alpha :as stest])
nil
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[expound.alpha :as expound])
nil
cljs.user=> (defn add1 [x] (+ 1 x))
#'cljs.user/add1
cljs.user=> (s/fdef add1 :args number?)
cljs.user/add1
cljs.user=> (stest/instrument `add1)
[cljs.user/add1]
cljs.user=> (set! s/*explain-out* expound/printer)
#object[expound$alpha$printer]
cljs.user=> (add1 nil)
Execution error - invalid arguments to cljs.user/add1 at (<cljs repl>:1).
<filename missing>:<line number missing>
-- Spec failed --------------------
Function arguments
(nil)
should satisfy
number?
-------------------------
Detected 1 error
However, when I do this in a repl controlled by shadow (both in CIDER and in the command line) I get instead some raw error object:
#error {:message "Call to #'cljs.user/add1 did not conform to spec.", :data {:cljs.spec.alpha/problems [{:path [], :pred cljs.core/number?, :val (nil), :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha30168], :cljs.spec.alpha/value (nil), :cljs.spec.alpha/fn cljs.user/add1, :cljs.spec.alpha/args (nil), :cljs.spec.alpha/failure :instrument}}
Is there a way to control how a failing spec is printed out in shadow-cljs?(shadow-api/release (:shadow/build testable))but this kinda crappy side effect of always starting a new shadow server even if one is running. Is there an easy way to mimic what the
shadow-cljs npm package does when starting a build by connecting to a running server or starting a new one?[:app] Build failure:
Failed to inspect file
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js
it was required from
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/geometry/projection.js
Errors encountered while trying to parse file
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js
{:line 5, :column 231, :message "'}' expected"}
Does this look familiar to anyone?
I'm new to both clojurescript and shadow-cljs and so I thought I'd ask if this might be caused by something a newbie like me would do that is obvious to veteran users.
if it's of any use, characters 220-240 of the pe.js file looks like this "t(((e,t)=>{import("./" , so it looks like it doesn't like something somewhere right at the { and import . Anyone have any ideas what I might be doing wrong?
I should mention the npm package is a beta package, its possible there's something wrong, I just doubt its them.no output for id error while using the repl?import() so shadow-cljs doesn't either# block I require a couple of clj namespaces, using :as to name them.
2. In that same CLJC file, in a #?(:clj form, I use those names to destructure keys on a map param.
I get this:{:deps true
:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[re-frame "0.12.0"]
[re-frame-steroid "0.1.1"]
[rn-shadow-steroid "0.2.1"]
[re-frisk-remote "1.3.3"]
[cljs-ajax/cljs-ajax "0.8.1"]
[day8.re-frame/http-fx "0.2.2"]]
:builds
{:test {:target :browser-test
:test-dir "test/humboi"
:runner-ns humboi.core
:devtools {:http-port 8021
:http-root "test/humboi"}
}
:dev
{:target :react-native
:init-fn humboi.core/init
:output-dir "app"
:compiler-options {:closure-defines
{"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:after-load steroid.rn.core/reload
:build-notify steroid.rn.core/build-notify
:preloads [re-frisk-remote.preload]}}}}cljs/user namespace. Basic types like 1 and 'this-is-a-keyword work fine, but defs & any function call fails(ns humboi.core-test
(:require [humboi.core :as sut]
["@testing-library/react-native" :refer [render fireEvent]]
[humboi.auth.core :refer [google-sign-in-comp]]
[cljs.test :as t :include-macros true]))
(defn mount! [component]
(render (r/as-element component)
#js {:container (testing-container)}))
(deftest google-login-test
(is (mount! [google-sign-in-comp])))
(defn start [] (cljs.test/run-tests))
(defn stop [done]
;; stopping the tests
(done))
(defn ^:export init []
(start)):browser-test or :node-testalter-var-root to redefine how defn and
defn-.
(ns patch.tufte
(:require
[taoensso.tufte :as tufte :refer [p]]
[taoensso.encore :as enc]
#?(:clj
[cljs.core]))
#?(:cljs (:require-macros [patch.tufte])) <- Here's the problem!
)
...
...
#?(:clj
(alter-var-root #'cljs.core/defn (constantly #'defnp)))
#?(:clj
(alter-var-root #'cljs.core/defn- (constantly #'defnp-)))
If the specified line is not commented out when launching shadow, it looks like
cljs.core is compiling with my new defn.
However, if I uncomment the line after compiling the project for the first time,
everything works.
Can it be solved somehow?force-compile in the dashboard it seems to me that this only compiles the latest changes.shadow-cljs/builds/<build-id>watch after that though since that still everything in memory$jscomp polyfill error again. Wondering if there’s anything I should keep for a reproduction before I nuke .shadow-cljs/ to make the error go away?$jscomp.asyncExecutePromiseGeneratorFunction is not a function$jscomp issues as well, I removed .shadow-cljs/ and $jscomp is back in the release build, thanks for the tip @mkvlr34 | (when bslayer 35 | (google.maps.event/addListener ----------^--------------------------------------------------------------------- No such namespace: google.maps.event, could not locate google/maps/event.cljs, google/maps/event.cljc, or JavaScript source providing "google.maps.event"my build:
{:frontend
{:target :browser
:compiler-options {:externs ["google_maps_api_v3_19.js"]}
; google_maps_api_v3_19.js is in the same dir as shadow-cljs.ednjs/google.maps.events.addListenergoogle.maps.event/addListener it expects that to be a CLJS namespace:node-test ❤️npx shadow-cljs watch app from the terminal, however. Any good hints on how to integrate this part of the workflow better into Intellij?npm run. It's what I'm using at the moment.2.11.13 and CLJS 1.10.773 and I keep getting this error when trying to eval my dev namesapce:
Execution error (ReferenceError) at (<cljs repl>:1). dev is not definedThis also happens when I run part of it, like this:
(defn sumation [a b] (+ a b))This appear to be a problem specially when I run a
def or defn:target :browser, marking my api fns with ^:export?:chrome-extension target:repl-init-ns option to my shadow-cljs.edn, I’ve been encountering the following error after leaving my browser repl idle:
[2021-01-05 13:26:03.677 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(test-client)", :ns client, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns client, :form (test-client), :source "(test-client)", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:524)
shadow.cljs.repl/process-read-result (repl.clj:498)
shadow.cljs.repl/process-input (repl.clj:682)
shadow.cljs.repl/process-input (repl.clj:660)
shadow.cljs.devtools.server.worker.impl/fn--15170 (impl.clj:755)
shadow.cljs.devtools.server.worker.impl/fn--15170 (impl.clj:745)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14833/fn--14834/fn--14842 (util.clj:285)
shadow.cljs.devtools.server.util/server-thread/fn--14833/fn--14834 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14833 (util.clj:257)
java.lang.Thread.run (Thread.java:834)
Caused by:
ExceptionInfo no source by provide: client {:provide client}
shadow.build.data/get-source-id-by-provide (data.clj:187)
shadow.build.data/get-source-id-by-provide (data.clj:184)
shadow.build.data/get-source-by-provide (data.clj:190)
shadow.build.data/get-source-by-provide (data.clj:189)
shadow.cljs.repl/repl-compile/fn--14400/fn--14401 (repl.clj:460)
my client.cljs file looks as follows:
(ns client
(:require [cljs.repl :refer [doc find-doc source apropos pst dir]]
[re-frame.core :as rf]
[re-frame.db :as rfdb]))
(defn test-client []
{:status "alive"})
(defn db []
@rfdb/app-db)
what does “no source by provide: xxx {:provide xxx}” mean? is there a way to to recover from this besides restarting my shadow-clj watch and my repl?shadow-cljs version 2.11.13client is not part of your usual build? try adding :preloads [client] :repl-init-ns clientclient.cljs is mostly used a scratch file for development:preloads [client] to my shadow-cljs.edn file:devtools {:repl-init-ns client
:http-root "resources/public"
:http-port 8280
:proxy-url ""
:preloads [client
sphere.cstools
devtools.preload
day8.re-frame-10x.preload]}}}}(defn- lazy-resolve
[symbol-k]
(let [symbol' (symbol symbol-k)
module' (-> (str symbol')
(s/replace #"/.*" "")
(s/split #"\.")
((partial s/join "-"))
keyword)]
`(conj [] ~module' (cond-> (fn [] (resolve (quote ~symbol')))
config.core/DEV?
(with-meta {:sym (quote ~symbol')})))))
....
From this we get [module-name, symbol] like ["core-reservation", "core.reservation/some-symbol"] . Then we combine that data with shadow.loader . Of course it works well.
The only issue I have is how greatly this pattern increase the build size. Those invocations are spread across whole application adding like 200kb for main bundle. The question is whether it can be somehow optimized? If you could share some insights with me I would be more than grateful.resolve. there is also https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841cljs.analyzer somewhere maybeshadow.lazy but if you build your own I do not know what that doesresolve adds a bunch of boilerplate "noise" yes. didn't expect it to get to 200kb though.(defn ^:deprecated my-fn [a b] (+ a b))• A namespace defining a value two times
(def a 1) (def a 2)@thheller Was there any change to Shadow from version
2.8.93 to verison 2.11.13 regarding this? I didn't find any in the notes of each release, but I may have not notice.:repl {:runtime-select :latest} in shadow-cljs.edn(shadow/repl :app {:runtime-id 123}):runtime-id works. Where is it generated? I don’t see anything that says runtime id when I run shadow-cljs watch app etc. I haven’t been that deep in shadow-cljs lately or doing any complex configurations.browser.cljs:20 shadow-cljs: #13 ready! or sodev ns? (require 'dev) in the REPL? load-file from the editor? (ns dev)? if you just use (dev/whatever) without doing those first you'll get the dev is not defined error?dev.cljs which contains the dev namespace.(defn ^:deprecated ab [a b] (+ a b)
Or when the namespace itself defined a value two times, like this:
(def company-id (random-uuid)) ; Some other code (def company-id #uuid "0acf9013-7c42-49fc-ae4b-221639bf9a34")
2.11.14 via :devtools {:ignore-warnings true} in your build config:npm-module) target, but I can’t call local JS files from CLJS files. I receive ReferenceError: shadow$provide is not defined at the place I try to https://github.com/rynkowsg/serverless-demo/blob/master/calc-nodejs-shadowcljs/src/main/calc.cljs#L5.
The URL to the repo is here: https://github.com/rynkowsg/serverless-demo/tree/master/calc-nodejs-shadowcljs
Any help, hint very much appreciated.import ToastManager from 'js-notifications'; const toastManager = new ToastManager();(:require ["js-notifications" :refer (ToastManager)] ) (.ToastManager. {}) -> module$node_modules$js_notifications$dist$ToastManager.ToastManager is not a constructor
import ToastManager from 'js-notifications'; -> ["js-notifications" :default ToastManager]
import defaultExport from "module-name"; it is right there in the first example 😛defaultExport is the name:as x and x/default but thats kinda lame:entries [] is not valid and requires at least one namespace:deps true. do you have "test" added in :paths in deps.edn?:source-paths is not a thing in deps.edn. it is :paths or :extra-paths:target :npm-module without :entries because that was not mandatory at the time. This is used to compile test files to be ran by jest. What should I put on :entries to have the same behavior as before? That is related to @ps question as he is using the project as a reference to run tests using jest.:autorun true and instead run the tests triggered by another watch util[2021-01-18 15:02:00.526 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/kepler_DOT_gl/dist/localization/index.js", :requires [{:line 44, :column 192}]}. What looks wrong is that path "node_modules/kepler_DOT_gl/..." when it should be "node_modules/kepler.gl/..." any ideas of what can be causing this? and the name has nothing to do with the problemrequire(somethingNotAString) or sorequire("./".concat(key))["default"]:devtools {:ignore-warnings true} so this doesn't blow stuff up:compiler-options {:warnings {:fn-deprecated false}} should work fine yes:devtools {:ignore-warnings true}(ns mytherapy.test
(:require [cljs.test :refer (deftest is use-fixtures)]
[shadow.dom :as dom]
[shadow.test :as st]
[cljs-test-display.core :as ctd]
["react-testing-library" :as rtl]
[cljs-time.core :as time]
[mytherapy.state-utils :refer [state-app make-note]]
))
;;
(use-fixtures :each
{:after rtl/cleanup})
(def test-state {:notes []
:records []
:data []
:currentNote {}})
(deftest a-failing-test
(is (= 2 2)))
(deftest a-failing-test-6
(is (= 9 2)))
(deftest test-make-note
(is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
:note_title "hello"
:note_type "note"
:timestamp_created "20210119T164619"
:timestamp_edited "20210119T164619"})))
(defn start []
(st/run-all-tests (ctd/init! "test-root"))
(a-failing-test)
(a-failing-test-6)
(test-make-note))
(defn stop[done]
; tests can be async. You must call done so that the runner knows you actually finished
(done))
(defn ^:export init[]
(dom/append [:div#test-root])
(start))deftest and so on(ns mytherapy.test
(:require [cljs.test :refer (deftest is use-fixtures)]
[shadow.dom :as dom]
[shadow.test :as st]
[cljs-test-display.core :as ctd]
["react-testing-library" :as rtl]
[cljs-time.core :as time]
[mytherapy.state-utils :refer [state-app make-note]]
))
;;
(use-fixtures :each
{:after rtl/cleanup})
(def test-state {:notes []
:records []
:data []
:currentNote {}})
(deftest a-failing-test
(is (= 2 2)))
(deftest a-failing-test-6
(is (= 9 2)))
(deftest test-make-note
(is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
:note_title "hello"
:note_type "note"
:timestamp_created "20210119T164619"
:timestamp_edited "20210119T164619"})))
(defn start []
(a-failing-test)
(a-failing-test-6)
(test-make-note))
(defn stop[done]
; tests can be async. You must call done so that the runner knows you actually finished
(done))
(defn ^:export init[]
(start)):runner-ns in your build config:runner-ns (optional)index.html you created{...
:builds
{:test
{:target :browser-test
:test-dir "test-out"
:ns-regexp "-test$"
:devtools {:http-port 8021
:http-root "test-out"}}}}:test-dir interfering with stuff-test so mytherapy.test wouldn't match that:default it might be :as or :refer. [“@react-native-community/cameraroll” :as CameraRoll] or [“@react-native-community/cameraroll” :refer (CameraRoll)]hawkdeps.edn and shadow-cljs.edn, and I have a “clj” and a “cljs” folder in src. I want shadow-cljs.edn to manage the cljs dependencies, but they are not being recognized at all. If I set :deps true I can successfully manage them from deps.edn instead, but I would prefer not having to do that. Any ideas what I might be doing wrong?shadow-cljs.edn:
{:source-paths ["src/cljs"]
:dependencies
[[re-frame "1.1.2"]
[reagent "0.9.1"]]
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:init-fn wallet.core/init}}
:devtools {:http-root "resources/public"
:http-port 4200}}}
:nrepl {:port 9000}}
and deps.edn:
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
metosin/reitit {:mvn/version "0.5.10"}
http-kit/http-kit {:mvn/version "2.5.0"}}
:paths ["src/clj" "resources"]
:aliases {:run {:main-opts ["-m" "wallet.core"]}}}:as reagent and :as re-frame in the requirements, that was just when I quickly prepared the code to demonstrate. The problem persists with correct requirements and is due to Cursive, like thheller explained:){:warnings-as-errors true} with cljs.js/eval-str?
It looks like the available options of [cjs.js/eval-str](https://cljs.github.io/api/cljs.js/eval-str) are limited.
(defn evaluate [s callback]
(cljs.js/eval-str
compile-eval-state
s
nil
{:eval cljs.js/js-eval
:load (partial shadow.bootstrap/load (analyzer/empty-state))
:warnings-as-errors true
:context :expr}
(fn [result] (do (js/console.log result)
(callback result)))))
I also tried to pass compiler-options as an argument of analyzer/empty-state but I had no success.:warning-handlers and it also didn't work.yarn build , it gives generates build file main.js. After linking the css and main.js to index.html it gives error on some of the assets file for ex png images. The css file background-image: url("/icons/square.png") these gives 404.
Any help would be appreciated!/icons/square.png it'll look at an absolute path for your file/home/user/project/foo/index.html it'll look for /icons/square.pngicons/square.png so the path is relative to the current file(defn parse-dtime
([parser stime]
(let
[d (js/Date. 0 0 0 0 0 0 0)
n (.strictParse parser stime d
--------------^-----------------------------------------------------------------
Cannot infer target type in expression (. parser strictParse stime d)
How to tell compiler, that parser is instance of goog.i18n.DateTimeParse. DateTimeParse.strictParse is from goog library and is renamed during advanced compilation.[parser stime] to [^js parser stime]. Does that work?[^goog parser stime]. ^js is fine too but prevents the renaming^goog just tells externs inference that it does NOT need to collect externs for this and as such the closure compiler is free to rename it^js creates externs for strictParse and as such closure will not rename it^js since the code size difference will be so tiny it won't matter:advanced optimizations and externs work^js or ^goog. it does not affect the generated JS at all..shadow-cljs/builds/<build-id>/release/shadow.externs.js or sobrowser target I tried to eval a quoted code list into Clojurescript runtime. while cljs.js/eval works with simple things like [1 2 3, anything that needs core NS stuff will tell me they are undefine with warning: i.e
(cjs/eval
(cjs/empty-state)
(parse-string "(cljs.core/println \"ehhlo bootstrapped\")")
{:eval cjs/js-eval
:source-map true
:context :expr}
(fn [r] r))
but if I choose browser target, start the browser, connect to cljs-repl, and change to bootstrap target midflight, it works .
If I choose bootstrap target, browser fails to connect to my cljs-repl;
Can I just use browser or bootstrap target instead of the mid-flight switch hack to make it work?output-dir to be out and I am getting
DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0which suggests it’s looking at
js instead:asset-path<NewLibProvider>
<App />
</NewLibProvider>
What is the best / most idiomatic way to do that in a shadow app?Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (rewrite_clj/custom_zipper/core.clj:59:1). #:clojure.error{:phase :compile-syntax-check, :line 59, :column 1, :source "rewrite_clj/custom_zipper/core.clj"}
I haven't fired up my project in a little while. It worked just fine last time I looked at it like a month ago but now the above occurs.
Edit: looks like upgrading to latest shadow fixed it.import React from 'react';
import BarcodeScannerComponent from "react-webcam-barcode-scanner";
function App() {
const [ data, setData ] = React.useState('Not Found');
return (
<>
<BarcodeScannerComponent
width={500}
height={500}
onUpdate={(err, result) => {
if (result) setData(result.text)
else setData('Not Found')
}}
/>
<p>{data}</p>
</>
)
}
export default App;
Any suggestions would be most grateful, thanks.localhost:7000 so far to access my live-reloading page. I thought I might be able to better separate my different web projects (and their differing SSL requirements) by changing the default dev-http host, so I modified my shadow-cljs.edn to read::dev-http {7000 {:root "classpath:public"
:host "stucco"}}
rather than:dev-http {7000 "classpath:public"}stucco:7000 . Am I misunderstanding something here? Do I need to configure something else for this to work?:host only does something if your machine has multiple ips so it knows which to pick but since it picks all by default that usually doesn't do anythingstucco 127.0.0.1 so /etc/hosts:dev-http {7000 "classpath:public"}shadow-cljs - config: /home/kimim/workspace/vorstellung/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593).
Assert failed: (sequential? root-contents):source-paths vector? maybe a set or map?.jar file on the classpath causing this.jar but isn't:log {:level :debug} in your shadow-cljs.edn. that should then log which one causes the troublehowever this module is in the root node_modules. what is your build config and how are you running it?cljs-runtime/marc.js suggests you have a (ns marc) which I don't see in your config so no clue:js-package-dirs ["vscodelib", "node_modules"] this is also suspect. why are you doing this?chai plays into all of this. datascript doesn't use it.:node-library isn't really meant to be re-bundled. it is meant to be used in node directly. (as the name implies 🙂):npm-module which will might work better for your use-case:source-paths ["src"] and src/vscodelib? the :js-package-dirs is misleading here and probably causing issuerequire("chai") but import Foo from "chai":source-paths?vscodelib makes me suspicious. is this running as a vscode plugin of some kind?src/vscodelib/test/databasespec.jsrequire("chai")?require at all. it should have importrequire should also worknpm=>import "./lib" what does that mean?node and then import lib? that is invalid?require("lib") this would be looking for node_modules/lib? which no output is going torequire("lib") will NOT look for that output at least not with the default node configurationshadow-cljs node-repl or that via Calva?node. you run require("./lib"). what happens next?shadow-cljs cljs-repl node:foo just to verify the connection worksnpx shadow-cljs cljs-repl node instead(require 'marc):exports {:dunno datascript.js/keywordize}} from your build config and instead use :exports {:dunno marc/foo}}def in that ns though. you can use any you already have or just add (def foo 3):js-options completelynode then global.shadow$provide = {}; then require("./lib")src/vscodelib/test/databasespec.js?var datascript_1 = require("datascript"); this is a problem and probably causing all the restdatascript package. not the one compiled by shadow-cljs you are doing all this forcljs꞉cljs.user꞉> @state/orders nil ; No available JS runtime. clj꞉cljs.user꞉> @stateshadow-cljs.edn
{:source-paths ["src"]
:dependencies [[binaryage/devtools "0.9.10"]
[proto-repl "0.3.1"]
[reagent "0.8.0"]]
:nrepl {:port 3333}
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main
{:entries [giggin.core]}}
:devtools
{:after-load giggin.core/main
:http-root "public"
:http-port 3000}}}}
in the browser. see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshootingdatascript npm package is bundled differently and not by shadow-cljsWarning: The tag <orders> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter. CLJS DevTools: some custom formatters were not rendered.
(ns giggin.state
(:require [reagent.core :as r]))
(def orders (r/atom {})); No available JS runtime. means that the browser has not connected back to shadow-cljs. that is the only issue you need to solve. the code does not matter. I cannot solve this for you without more info. the build config you provided will have generated a public/js/main.js. I assume you have a public/index.html file with a <script src="/js/main.js">?(js/alert "test") and then I saw a popup so it seems there is a js runtimeshadow-cljs ready message in the browser console?giggin.state/order?:target :esm which has got me further than I have been...:target :graaljs which sort of works for most stuff:entries [whatever.ns] :output-to "foo/bar.js":target :graaljs for them as well as some custom code so they get some hot-reloaddef's get re-evaluated and overwritten, running shadow-cljs watch , if I have state that I don't want to get re-initialized and re at the def form, there's defonce .(shadow/repl :app) Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28). watch for build not running
(shadow/watch :app) first?(shadow/watch :app {:autobuild false}) so it doesn't automatically recompile if thats what you are asking(shadow/node-repl) is usually good enough if you just want a repl[:app] Build failure: The required namespace "cljsjs.codemirror.addon.edit.matchbrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".I have already added
codemirror via npm install codemirror, so I’m stuck…src/main/cljsjs/codemirror.cljs file to my project, with this code inside:
(ns cljsjs.codemirror (:require ["codemirror" :as cm])) (js/goog.exportSymbol "CodeMirror" cm)However, I still get the build failure:
The required namespace "cljsjs.codemirror.addon.edit.matchbrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".I must be doing something silly — I just can’t work out what it is…
cljsjs.codemirror not cljsjs.codemirror.addon.edit.matchbrackets"codemirror/addon/edit/matchbrackets" but I'm not suresrc/main/cljsjs/codemirror/addon/edit/matchbrackets.cljs file to my project:
(ns cljsjs.codemirror.addon.edit.matchbrackets (:require ["codemirror.addon.edit.matchbrackets" :as cmaem])) (js/goog.exportSymbol "CodeMirrorAddonEditMatchbrackets" cmaem)Now I get the build error:
[:app] Build failure: The required JS dependency "codemirror.addon.edit.matchbrackets" is not available, it was required by "cljsjs/codemirror/addon/edit/matchbrackets.cljs". Dependency Trace: clojsandbox/app/core.cljs klipse/run/plugin/plugin.cljs klipse/plugin.cljs klipse/klipse_editors.cljs klipse/ui/editors/common.cljs klipse/ui/editors/editor.cljs cljsjs/codemirror/addon/edit/matchbrackets.cljs
/ instead of .. you can find the correct path by going into node_modules/codemirror and finding the correct folder or matching .js file for the abovenode_modules/codemirror/addon/edit/matchbrackets.js or node_modules/codemirror/addon/edit/matchbrackets as a folderqrious into my package.json. How do I require it in my namespace and call the constructor new QRious()? -> https://www.cssscript.com/pure-javascript-qr-code-generator-qrious/
I have tried ["qrious" :as qrious] but js/QRious is not defined. qrious seams to be a function, but calling it throws Cannot read property 'bind' of undefined .js/ for anything that you imported via require in the ns. you use the :as name directly(qrious. ...)(qrious. ...) throws Uncaught Error: Invalid option: __reactInternalInstance$uiqex7uo9w at Nevis.extend.exists._set (qrious.js:1924).
When using qrious in Vanilla JS, I have to call the QRious() constructor, which is defined globally when including the qrious.js via <script>. Don't I have to mention this QRious constructor somehow? Perhaps you have a hint for me after having a look at qrious.js: https://github.com/neocotic/qrious/blob/master/dist/qrious.jsconst qrious = require('qrious')? It works?
The doc does not mention this method.(ns your-namepace (:require ["qrious" :as qrious]))Then you could interop:
(def qr (qrious. #js {:element (.getElementById js/document "qr"), :value "Custom value"}))
> Don't I have to mention this QRious constructor somehow?
Note the dot after QRious, this is a sugar syntax for construct new Object...equivalent to
(def qr (new qrious #js {:element (.getElementById js/document "qr"), :value "Custom value"}))
Refresh your page and it should works.:compiler-options {:output-feature-set :es6} if there is code that can't be transpiled(defn ^:dev/after-load start []
(reagent/render [ui {:x (js/Date.now)}] dom-root))
Here is the entry point for react-native, it accepts a function that returns react component
(react-native/AppRegistry.registerComponent "myApp" #(reagent/reactify-component root))EDIT: I've tried below which I've found thru googling but does not work. Though I don't really understand the theory behind to be honest 😅
(def root-version (atom 0)) (defn reloadable-root [] @root-version (r/reactify-component root)) (defn start [] (rn/AppRegistry.registerComponent "myApp" reloadable-root)) (defn ^:dev/after-load after-load [] (js/console.log "after load...") (swap! root-version inc) (start))
@root-version outside of a scope where reagent looks for it(shadow.cljs.devtools.api/watch-compile-all!), you need to be in the CLJ repl.
But for evaluating cljs, you need to be in the CLJS repl. How do you manage to compile/reload while making changes?(shadow.cljs.devtools.api/watch-compile-all!) so I rarely have a reason to be in a CLJS repl when working on CLJSshadow-cljs watch app. or rather nowadays just shadow-cljs server and start the watch from the UItap> with Inspect but actually very little REPL for CLJStap> and sending forms to repl. But somehow I'm excited to acquire new super powers!! :star-struck:edn , it shows as the var(tap> ~selected) repl command 😉(ns main (:require ["@aws-sdk/client-cognito-identity-provider" :refer [CognitoIdentityProviderClient]]))I get an error returned
#object[TypeError TypeError: $jscomp.inherits is not a function]
import { CognitoIdentityProviderClient, AddCustomAttributesCommand } from "@aws-sdk/client-cognito-identity-provider";tools.deps integration. Certain I had this working before. I have a deps.edn like:
{:paths ["src"]
:deps {}
:aliases
{:dev
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.9.2"}}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}
and a shadow-cljs.edn like:
{:deps true
:builds {:app
{:target :node-script
:output-to "target/main.js"
:output-dir "target"
:exports {:handler platform.core/handler}}}}
but when I run clj -M:dev watch app, I get
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2). watch (No such file or directory)What am I missing?
deps.edn. The closing brace on extra-deps line meant that :main-opts was added as an alias and so ignored. Thanks for the help 😅shadow ns in a project here, it says the namespace isn't defined, but others like shadow.cljs.devtools.server.nrepl are there, any ideas what could be wrong?(shadow/nrepl-select :app) Syntax error compiling at (REPL:1:1). No such namespace: shadow
:as shadow?(shadow.cljs.devtools.api/nrepl-select :app), but found strange why only in this project I cant use just shadow/nrepl-select :thinking_face:(shadow/nrepl-select $NAME$), I've been using this snippet for many years now, in many different projects (with various different setup configurations), that's why this situation puzzles meshadow.user, that has the shadow alias.cljs/user.cljs file since I know that Shadow treats it specially. I guess this must be because something is missing in my config:
[2021-01-28 19:37:26.204 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 3, :from 10}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/eval17184/fn--17187/fn--17190 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)Failed to inspect file /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css it was required from /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js
remote: -----> Build remote: Running build (yarn) remote: yarn run v1.22.10 remote: $ yarn clean && shadow-cljs release app remote: $ rimraf public/js remote: shadow-cljs - config: /tmp/build_8c64e158/shadow-cljs.edn remote: ===== ERROR ================= remote: Executable 'java' not found on system path. remote: ============================= remote: error Command failed with exit code 1. remote: info Visit for documentation about this command. remote: remote: -----> Build failed
:output-dir. lets assume that is public so everything in the public folder you put on heroku on a static site. you don't tell it about shadow-cljs or npm or java or any of that. you purely put STATIC files on heroku. I assume there is a way to do that but I don't know how..js files, is there a way for shadow-cljs to automatically build both these files while watching?:cache-blockers or :dev/always (see docs) in combination with (shadow.cljs.devtools.api/watch-compile-all!) from the REPL:build-hooks let you do what you need in a cleaner way:modules or two separate builds and shadow-cljs watch build-a build-b`The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".
Dependency Trace:
ttncore/some_test.cljs
node_modules/@ndn/repo/lib/mod_node.js
node_modules/@ndn/repo-api/lib/mod_node.js
node_modules/@ndn/repo-api/lib/bulk-insert-initiator_node.js
node_modules/@ndn/repo-api/lib/data-store_node.js
node_modules/@ndn/packet/lib/mod_node.js
node_modules/@ndn/packet/lib/security/signed-interest-policy_node.js
node_modules/@ndn/packet/lib/interest_node.js
node_modules/@ndn/packet/lib/security/helper_node.js
node_modules/crypto-browserify/index.js
node_modules/create-hash/browser.js
node_modules/cipher-base/index.js
node_modules/stream-browserify/index.js
Searched for npm packages in:
/media/psf/DataPartition/lastmile/ttncore/node_modules
Here are the modules I have installed:
(parallels) parallels (98)# npm list
/cdn-cgi/l/email-protection /media/psf/DataPartition/lastmile/ttncore
├─┬ @babel//cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ @ndn//cdn-cgi/l/email-protection
│ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ @ndn//cdn-cgi/l/email-protection
│ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── @types//cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── @ndn//cdn-cgi/l/email-protection deduped
│ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ ├─┬ @ndn//cdn-cgi/l/email-protection
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── @ndn//cdn-cgi/l/email-protection deduped
│ ├── @types//cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ └─┬ /cdn-cgi/l/email-protection
│ │ └─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection.0.2 deduped
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ └─┬ /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection deduped
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection deduped
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├── @blakeembrey//cdn-cgi/l/email-protection
│ ├── @blakeembrey//cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── UNMET OPTIONAL DEPENDENCY /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ └─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ └─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ └─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection deduped
│ └─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection deduped
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── safe-buf/cdn-cgi/l/email-protection deduped
│ │ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ └── /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ └─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
└─┬ /cdn-cgi/l/email-protection
├─┬ @fullhuman//cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ └─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├─┬ /cdn-cgi/l/email-protection
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ ├── /cdn-cgi/l/email-protection deduped
│ │ │ └─┬ /cdn-cgi/l/email-protection
│ │ │ └── /cdn-cgi/l/email-protection deduped
│ │ ├── /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection deduped
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection30001171
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection deduped
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ └─┬ /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection
│ └─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ └─┬ /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├─┬ /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ ├── /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ ├── /cdn-cgi/l/email-protection
│ └── /cdn-cgi/l/email-protection
├─┬ /cdn-cgi/l/email-protection
│ ├── /cdn-cgi/l/email-protection deduped
│ ├─┬ /cdn-cgi/l/email-protection
│ │ └── /cdn-cgi/l/email-protection deduped
│ └── /cdn-cgi/l/email-protection
├── /cdn-cgi/l/email-protection
├─shadow-cljs installed in the project. hmm or not. seems to be in the listshadow-cljs ? Is this documented anywhere?package.json to pick the version you want and running npm install after. or npm install directly:node-library with :js-provider :shadow. And getting a bunch of The required JS dependency "stream" is not available and similar for node core libs. Whats the best way to get around this?:js-options {:keep-native-requires true} in your build config(-> "path/to/edn" shadow.resource/inline clojure.reader/read-string)
1..shadow-cljs/builds/<build-id>/dev and rebuild.shadow-cljs let me repro the issue locally, turned out to be a bug in an outdated version of shadow-cljs.package.json file and my require is correct, but
[:> ls/LoginScreen] returns [:> nil]I am wondering if using Expo SDK 40 and react 17.0.0 might be causing this problem. Any thoughts?
ls? what is your require? read the section about :default, maybe thats it https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages(require '["react-native-login-screen" :as le])
:default LoginScreenshadow-cljs.edn it works fine::proxy in shadow-cljs.edn for dependency resoltiuon?{:source-paths
["src"]
:proxy {:host "127.0.0.1" :port 3128}
:nrepl {:port 9000}
:dependencies
[[cider/cider-nrepl "0.25.8"]
[reagent "1.0.0"]
[re-frame "1.1.2"]]
:builds {:app {:target :browser
:output-dir "public/js"
:modules {:main {:entries []}}
:devtools {:http-root "public"
:http-port 3000}}
:prod {:target :browser
:output-dir "public/js"
:modules {:main {:entries []}}
:release {:compiler-options {:optimizations :simple}}}}}:maven {:proxy ...}:prod build is an anti-pattern in shadow-cljs:release bit into the :app configrelease builds so it does not affect the watch or compile buildsshadow-cljs release app ?{:mvn {:proxy {:host "127.0.0.1" :port 3128}}}/home/rameezk/.shadow-cljs/config.edn:maven not :mvnDevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0 the < part is because the static server returns the index.html, but the file is missing too.
I am not even sure if the file should or shouldn't exist and I don't need the source maps right now at all, but I suspect I am doing something wrong again and that's why I have these warnings:asset-path "/" but the files aren't actually located there. it should match the path you use to serve the JS. so maybe /js or soshadow-cljs watch app --verbose and found that it was using a different IP address than expo. How can I get them to be the same?[Wed Feb 03 2021 03:48:56.126] WARN The shadow-cljs Websocket was disconnected.
[Wed Feb 03 2021 03:48:56.127] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /10.212.134.22 (port 9630) from /10.0.2.16 (port 36722) after 10000ms"}
Now when I send forms to repl, I got this error
No available JS runtime. See
%IP-ADDRESS%? or do you just set the actual IP there?%IP-ADDRESS% is a placeholder for your machine real ip{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "192.168.1.111"} for instanceserver_host is used here https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/cljs/devtools/client/env.cljs#L84 if not set, it uses “localhost” which doesn’t work in iOS simulator (it needs ip address to connect)ipconfig getifaddr en0 where en0 is your network interface:local-ip "1.2.3.4" in your build config or via config merge. going through closure-defines is kinda backwards. just thought there was some magic %IP-ADDRESS% placeholder or something that metro will replace but I guess not.local-ip option. At the time i was adding hack with server-port override, it wasn’t there i think.react-native log-android in different terminal, it logs almost the same thing as the bundler (in again another terminal where I run react-native start) . No log about IP address. Am I missing something? How to I know what is the IP of the emulator?[2021-02-03 16:09:28.301 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-e94df828.js", :requires [{:line 1632, :column 73}]}
Trying to use https://www.npmjs.com/package/@aws-amplify/ui-react lib and requiring it like
(:require ["@aws-amplify/ui-react" :refer [AmplifyAuthenticator AmplifySignOut]]...I think the problem is here but not entirely sure what I can do about it
return Promise.resolve().then(function () {
return _interopNamespace(require(`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {...}, consoleError);
Any ideas?--verbose and it puzzles me.:dev/always and all namespaces blocked for caching by :cache-blockers-> Flush: meloview/comp/root.cljs <- Flush: meloview/comp/root.cljs (5 ms)No
Compile CLJS or Cache write for that namespaceA requires B which requires C, A might not recompile when C changes but B always will?(shadow-cljs.browser-tools/write-file "target/info.txt" "file content here") would be optimal.:dev-http server:browser-test:handler. so I do not see the point in shadow-cljs providing such a thing.:dev-http? https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http:dev-http {3000 {:root "public" :handler my.handler/handle}} and
(ns my.handler
(:require [shadow.http.push-state :as push-state]
[ :as io]))
(defn handle [{:keys [uri] :as req}]
(if (not= uri "/save-me")
(push-state/handle req)
(do (spit (io/file "somewhere" "foo.txt") (slurp (:body req)))
{:status 201
:body ""})))/save-mepostcss input.css -o out/out.css`` . Ideally with a watch function, so it runs that command only when the input.css changes?:build-hooks in the docs. fair warning though this is almost always a bad idea since it will slow down you CLJS recompile cycleshadow.dom/transition-supported? which looks like
shadow.dom.transition_supported_QMARK_ = (((typeof window !== 'undefined'))?goog.style.transition.isSupported():null);so i am wondering if theres a way to prescribe to shadowcljs to not include some of these helper packages? help much appreciated!
:runtime in the build config. that defaults to browser. for :deno you'll need :runtime :custom since I have not implemented hot-reload for it at all.compile and release kinda work for now.ignore-resources option existing once, but I'm not sure if I'm misremembering:js-options {:ignore-asset-requires true} to get the old behaviourdevtools.preload in the :preloads. Has something changed?devtools.preload? that is not from shadow-cljs or related to inspectshadow-cljs browser-repl or shadow-cljs node-repl and see if those show uptap> in my code that runs in the browser, then trying to inspect those values in tap>s are getting executed because I have console logging on the same code pathshadow-cljs: #21 ready! in the console also.browser-repl, and those values do show uptap> too early? like on page load?ready message so if you log before that it won't make it to the UIwatch builds:hawk :create #object[java.io.File 0x18f77246 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913] :hawk :modify #object[java.io.File 0x52954b80 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913] :hawk :delete #object[java.io.File 0x58038f69 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913] :hawk :delete #object[java.io.File 0x7f50d4a /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc] :hawk :create #object[java.io.File 0x43e0fe21 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc~] :hawk :create #object[java.io.File 0x393148d /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc] :hawk :modify #object[java.io.File 0x3fffaee3 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc] :hawk :delete #object[java.io.File 0x4b70ec0a /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc~]Is that normal?
:deps true style project with CIDER. I'm getting the dreaded "missing instance". I remember reading in the users guide (although i can no longer find it) that if i made sure ensure that shadow's middleware was included all would be good. I'm attempting:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/piggieback {:mvn/version "0.5.2"} cider/cider-nrepl {:mvn/version "0.25.8"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[\"cider.nrepl/cider-middleware\",\"shadow.cljs.devtools.server.nrepl/middleware\",\"cider.piggieback/wrap-cljs-repl\"]"]}}}' -M:test:cider/nrepl
and then
(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))after startup and i'm still getting the missing intance message. Is there something i'm skipping over?
(shadow.cljs.devtools.server/start!)npx shadow-cljs server which includes :nrepl {:port 8701}. My understanding is that it would have been the server:nrepl port and instead look up the port in .shadow-cljs/nrepl.port for local devC-c C-e like I normally do. Can someone here me with this?(shadow/compile
:build1
{:config-merge
{:closure-defines '{ true}}})
and i must be getting something slightly off because it gives the error that the structures can't be merged. the exception makes it look like the structure is a seq of map entries rather than a map potentially? sincere apologies if ive missed something in the manual that addresses this use-case(shadow/compile
:build1
{:config-merge
[{:closure-defines '{ true}}]})
which makes sense in hindsight. apologies for the noise!tap> in my code that runs in the browser, then trying to inspect those values in shadow-cljs watch dev-uiBut I am getting this error :
shadow-cljs - config: .../shadow-cljs.edn shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.4 running at shadow-cljs - nREPL server started on port 54872 shadow-cljs - watching build :dev-ui [:dev-ui] Configuring build. [:dev-ui] Compiling ... [:dev-ui] Build failure: The required namespace "react" is not available, it was required by "reagent/core.cljs".I have installed react with
npm install react react-dom create-react-classbut the issue is still there. Let me know if I am doing everything right ? Thanks for the help.
<project>/node_modules/react directory. if you don't have a package.json in your project dir it might install somewhere else.import() which is not supportedShadowJS.prototype.; is actually ShadowJS.prototype.; and not maybe some unicode char or so behind inbetween the .;?(ns debug) and put this in it
(defn find-it
{:shadow.build/stage :flush}
[{:keys [output] :as build-state}]
(->> output
(filter #(contains? (:properties %) ""))
(map :resource-id)
(prn))
build-state):build-hooks [(debug/find-it)](defn find-it
{:shadow.build/stage :optimize-prepare}
[{:keys [output] :as build-state}]
(->> (vals output)
(filter #(contains? (:properties %) ""))
(map :resource-id)
(prn))
build-state)shadow-cljs clj-repl is fine(vals)(vals output)() would be the empty sequence from the prn if it didn't find what it was looking for(defn find-it
{:shadow.build/stage :optimize-prepare}
[{:keys [output] :as build-state}]
(doseq [{:keys [resource-id properties]} (vals output)
prop properties
:when (< (count prop) 2)]
(prn [:prop resource-id prop]))
build-state)[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "L"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "R"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "C"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "P"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "U"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "N"] [:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "q"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "m"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "f"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-path/dist/d3-path.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "n"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "z"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "e"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "p"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "v"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "t"] [:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "o"] [:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "v"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/d3-dispatch/dist/d3-dispatch.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "d"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "n"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "p"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "t"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "i"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "m"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "$"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "o"] [:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "c"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/grayscale.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "d"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Q"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "q"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "L"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "p"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "M"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "S"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Z"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "H"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "V"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "U"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "X"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "u"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "m"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "W"] [:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "c"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "i"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "n"] [:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "e"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/barycenter.js"] "v"] [:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "k"] [:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/elm/elm.js"] "f"] [:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "v"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "v"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "e"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "d"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "w"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "L"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "M"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "m"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/haskell/haskell.js"] "f"] [:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/resolve-conflicts.js"] "i"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "z"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "x"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "t"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "i"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "y"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "A"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "m"] [:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "c"] [:prop [:shadow.build.npm/resource "node_modules/d3-chord/dist/d3-chord.js"] "_"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "s"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "a"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "b"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "r"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "g"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "l"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "h"] [:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "c"]
(defn find-it
{:shadow.build/stage :optimize-prepare}
[build-state]
(prn (shadow.build.closure/extern-props-from-cljs build-state))
build-state)"" then it is somehow coming from CLJS not JS[2021-02-05 17:19:55.794 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]}
#{"" "_run" "NaN" "flush-after-render" "getMode" "unbounded-unshift" "_peek-at" "_update-watching" "fromCharCode" "onChange" "_queued-run" "add-after-render" "flush-render" "_set-opts" "_peek" "isScrolling" "floorEntry" "autoLoadMode" "ceilingEntry" "createElement" "Fragment" "PersistentVector" "copyState" "POSITIVE_INFINITY" "findModeByName" "Children.toArray" "queue-render" "schedule" "startState" "_set-state" "hasNext" "findDOMNode" "flush-queues" "_handle-change" "getLength" "PersistentArrayMap" "Doc" "render" "_try-capture" "flush-before-flush" "cljsIsDirty" "unmountComponentAtNode" "NEGATIVE_INFINITY" "Component" "add-before-flush" "run-queues" "core" "equiv"}
Closure compilation failed with 1 errors
--- externs.shadow.js:13
Parse error. 'identifier' expected(defn find-it
{:shadow.build/stage :optimize-prepare}
[state]
(doseq [{:keys [ns file] :as src}
:let [{:shadow/keys [js-access-properties]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-properties "")]
(prn [:found ns js-access-properties]))
build-state)[2021-02-05 17:23:40.074 - WARNING] :shadow.build/hook-config-ex - {:hook-idx 0, :hook-sym debug/find-it, :build-id :app}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error macroexpanding doseq at (debug.clj:15:13). #:clojure.error{:phase :macro-syntax-check, :line 15, :column 13, :source "debug.clj", :symbol doseq}(defn find-it
{:shadow.build/stage :optimize-prepare}
[state]
(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-properties]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-properties "")]
(prn [:found ns js-access-properties]))
build-state)state and build-state be the same var?(defn find-it
{:shadow.build/stage :optimize-prepare}
[state]
(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-properties]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-properties "")]
(prn [:found ns js-access-properties]))
state)(defn plugin-paste []
{}
{:on-cm-init (fn [editor config state]
(cm/on-paste editor (fn [editor event]
(on-paste-event editor event))))})if i change it to
(defn plugin-paste []
{})glas-editor.plugin-pasteI removed the require for the plugin name space, now i get[:app] Compiling ... [2021-02-05 17:35:32.949 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} ------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/codemirror/lib/codemirror.js:2 constant module$node_modules$codemirror$lib$codemirror assigned a value more than once. Original definition at externs.shadow.js:11 --------------------------------------------------------------------------------
externs.shadow.js:
/** @const {ShadowJS} */ var location;
/** @const {ShadowJS} */ var module$node_modules$codemirror$lib$codemirror; <-- ln 11
ShadowJS.prototype.$;
ShadowJS.prototype.$$typeof;Found the following code that generates the error:
(ns glas-editor.plugin-paste
(:require
...
\["turndown" :as td\]
\["turndown-plugin-gfm" :as tdgfm\]
))
(def td-service (td/. (bean/->js {"headingStyle" "atx"
"codeBlockStyle" "fenced"})))
td/. is the cause.(td. ...) without the /?require in the code. anything that is not just a plain require call with a string argument is "invalid"run-tests using @testing-library/react-native npm module. But I'm getting this error
undefined is not an object (evaluating 'shadow.js.shim.module$$testing_library$react_native.render')Here is my test file (I think I'm importing it correct, see the js example https://callstack.github.io/react-native-testing-library/docs/getting-started/#example)
(ns limeray.component-test
(:require [clojure.test :refer [deftest run-tests run-all-tests]]
["@testing-library/react-native" :refer [render]]
[reagent.core :as r]
[limeray.component :as ui]))
(def jaime (render (r/as-element [ui/button {:title "My Title"}])))
(deftest render-button-with-title
(as-> (render (r/as-element [ui/button {:title "My Title"}])) $view
(.getByText $view "My Title")))
(run-tests)
Is this something related to externs?shadow-cljs watch app , then using cursive I connected to the repl, then switched to cljs by calling (shadow.cljs.devtools.api/repl :app)
The connected client is an android emulator. What I'm doing is to send the run-tests in repl.react-test-renderer which I think deals only with js objects (vdom)react-native anywhere. since that package needs to be built by metroyou cannot add requires dynamically in a react-native env.
In the context of browser env, what does it mean by requiring dynamically? Maybe this will help me understand why its not possible in react-native@testing-library/react-native in my production code. Metro will be able to provide it as deps?
EDIT:
I've just tried it, looks like lib is now being loaded:cache-blockers works but it's not very user-friendly when it comes to libraries^:dev/always:cache-blockers but then it's true that side-effecting on compilation is definitely not a widespread habitshadow-cljs.edn? The reason for this is I have multiple lein profiles, each of which corresponding to different environment like dev, test, prod, etc. and I'd like shadow-clj to be able to do the same. Would appreciate any insight. Thanks in advance 🙂shadow-cljs release app you do lein with-profiles +whatever run -m shadow.cljs.devtools.cli release applein config inside each build would be nice for something like this I imagine.lein as described.:target :node-script build. So first I'm doing shadow-cljs start && shadow-cljs clj-repl app and then running (shadow/watch :app) and (shadow/repl :app) from there, per https://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage. The prompt then changes to cljs.user=> and when I evaluate forms directly from there it complains "No application has connected..." which is to be expected I think since I haven't actually started a Node process. So far so good I guess.
However, at this point when I do :ConjureConnect 7001 from my editor and try to evaluate forms, it is connecting to a plain Clojure REPL and doesn't consider JS forms e.g. (js/console.log ...) valid. I think this is because the (shadow/... :app) forms only transform that one client connection into a CLJS REPL; the nREPL server itself is still in Clojure "mode"...but how do I get the server itself to compile CLJS forms?shadow-cljs node-repl isn't enough for your use case? second if you connect to the nrepl that connection starts out in CLJ mode. so you switch it via (shadow/repl :app)shadow-cljs node-repl it starts up the server on 7001 but when I do :ConjureConnect 7001 it complains:
[2021-02-07 12:53:39.022 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns }
FileNotFoundException Could not locate media_server/app__init.class, media_server/app.clj or media_server/app.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
My main file is src/media_server/app.cljs and when I change it to .clj it complains that the ns form does not conform to spec because I'm trying to require the "fs" node module.shadow-cljs server .. connect to nrepl and then run (shadow/node-repl)$ shadow-cljs node-repl
shadow-cljs - config: /home/tamayo/projects/media-player/server/shadow-cljs.edn
shadow-cljs - server version: 2.9.6 running at
shadow-cljs - nREPL server started on port 7001
cljs.user=> (shadow/watch :app) ;; <----------- TRYING TO SWITCH MODES HERE ----------<<<<<
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: :1:2
No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
Resource: :1:2
Use of undeclared Var shadow/watch
--------------------------------------------------------------------------------
TypeError: shadow.watch is not a function
at cljsEval (<eval>:1:16)
at global.SHADOW_NODE_EVAL ([stdin]:105:10)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
at ret (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:49:13)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:120:11)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:47:1)
at shadow$cljs$devtools$client$node$process_message (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:106:5)
at /home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:242:9
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:194:7)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:248:7)
cljs.user=>shadow-cljs server ... connect nrepl then (shadow/watch :app) and (shadow/repl :app)shadow-cljs node-repl in the command line that will drop you directly into CLJS mode as indicated by cljs.user=> promptshadow-cljs server.shadow-cljs commands or you can run all those directly over nreplnode-repl. that is just a simplified node repl that is already ready to go with its own node process but not coupled to any build:node-script where you have to manage the node process yourselfserver vs the various REPL commands...I tried various ways but still can't get my editor REPL to play nice with CLJS. So I need to just figure out what the issue is on the Conjure side. Sorry if it seemed like I wasn't listening, I was just trying to validate my understanding.shadow-cljs server and then connect conjure? without doing anything else?:nrepl {:init-ns ...} in your shadow-cljs.edn config?:devtools {:repl-init-ns foo.bar} in your build config insteadshadow-cljs on an M1 MacBook Pro for a couple of week. (PS: it’s amazing. IntelliJ/Cursive, shadow-cljs watch, kaocha watch, Fulcro RAD app running in browser. Laptop stays cool, totally silent, and runs for hours with only 20-30% battery consumed. So different than my Intel MBP, which would last for no more than 45m!)
But I have noticed something strange, and don’t know how to best document this strange behavior.
When using an ARM JVM (either IntelliJ JBR or Azul JVM), it seems to take much longer to detect file changes. This affects the shadow-cljs builds, and kaocha watch tests. When a save a file, it may take between 3 seconds and maybe even up to 10+ seconds for the file change to trigger a compile or test run.
Has anyone else run into this problem?
Is there a simple test case or scenario I can use to isolate what is causing the delay?
(I haven’t tried using an x86 JVM yet. I’m sufficiently afraid I’ll permanently break my dev setup by doing that… Unwarranted I’m sure, but… 🙂hawk file watching lib which seemed to cause trouble on Big Surshadow-cljs , and how it makes the build system just fade into the background, in the best possible way! 🎉🎉🎉 So wonderful!:fs-watch {:hawk false} in shadow-cljs.edn top level on older versions, basically the same effect(ns test.fixtures)
(defmacro with-fake-timers
[symbol & body]
`(let [~symbol (fake-timers/install)]
(try
my.util.cljs
(ns test.fixtures (:require ["@sinonjs/fake-timers" :as fake-timers]) (:require-macros [test.fixtures :refer [with-fake-timers]]))my.util-test.cljs
(ns test.fixtures-test
(:require
[cljs.test :refer [deftest testing is]]
[test.fixtures :refer [with-fake-timers]]))
(deftest macro-test
(is (= '_ (macroexpand-1 '(with-fake-timers clock (prn "Hello, world"))))))
(deftest with-fake-timers-test
(testing "Given a symbol to bind to and a body to execute, "
"it should replace the global timer APIs and execute the body"
(let [previous-value js/window.setTimeout]
(with-fake-timers clock
(let [actual (= js/window.setTimeout previous-value)
expected false]
(is (= actual expected)))))))import * as cdktf from 'cdktf';. If I transpile to CommonJS, it complains as well:
; Execution error (ReferenceError) at (<cljs repl>:1). module$docker$index is not defined
> tree ./.gen/providers-out/
./.gen/providers-out/
└── docker
├── config.d.ts
├── config.js
├── container.d.ts
├── container.js
├── data-docker-network.d.ts
├── data-docker-network.js
├── data-docker-registry-image.d.ts
├── data-docker-registry-image.js
├── docker-provider.d.ts
├── docker-provider.js
├── image.d.ts
├── image.js
├── index.d.ts
├── index.js
├── network.d.ts
├── network.js
├── secret.d.ts
├── secret.js
├── service.d.ts
├── service.js
├── volume.d.ts
└── volume.js
1 directory, 22 filesindex.js and the modules it refers to call out to cdktf (expected from node_modules)> (require '["/docker"]) FileNotFoundException: ~/hello-world/.gen/providers-out/docker (Is a directory) > (require '["/docker/index" :as docker]) nil > docker Execution error (ReferenceError) at (<cljs repl>:1). module$docker$index is not defined nil
ExceptionInfo closure errors {:tag :shadow.build.closure/errors, :errors [{:resource-name "docker/config.js", :source-name "docker/config.js", :line 3, :column 0, :msg "Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import cdktf from 'goog:shadow.js.shim.module$cdktf';?"}]> var docker = require('./.gen/providers-out/docker')
undefined
> docker
{
Config: [Getter],
ContainerNetworkData: [Getter],
Container: [Getter],
Image: [Getter],
Network: [Getter],
Secret: [Getter],
Service: [Getter],
Volume: [Getter],
DataDockerNetworkIpamConfig: [Getter],
DataDockerNetwork: [Getter],
DataDockerRegistryImage: [Getter],
DockerProvider: [Getter]
}
"shadow-cljs": "^2.11.17",
import * as cdktf from 'cdktf'; is invalid and would need to be import cdktf from 'cdktf';. which the warning is telling you basicallymodule$docker$index is not define -- what should I do in that case?> docker
#js {:Config #object[Config$$module$docker$config], :Container #object[Container$$module$docker$container], :ContainerNetworkData #object[ContainerNetworkData$$module$docker$container], :DataDockerNetwork #object[DataDockerNetwork$$module$docker$data_docker_network], :DataDockerNetworkIpamConfig #object[DataDockerNetworkIpamConfig$$module$docker$data_docker_network], :DataDockerRegistryImage #object[DataDockerRegistryImage$$module$docker$data_docker_registry_image], :DockerProvider #object[DockerProvider$$module$docker$docker_provider], :Image #object[Image$$module$docker$image], :Network #object[Network$$module$docker$network], :Secret #object[Secret$$module$docker$secret], :Service #object[Service$$module$docker$service], :Volume #object[Volume$$module$docker$volume]}
> Container
#object[Container$$module$docker$container]browser-repl or an actual build?shadow-cljs.edn after transpiling to ES2015 and changing the import statement for every single generated .js file(ns demo.script
(:require ["constructs" :refer (Construct)]
["cdktf" :refer (App TerraformStack)]
["/docker/index" :as docker :refer (Container)]))browser-repl for this?shadow-cljs.edn:
{:source-paths ["src/main" ".gen/providers-out"]
:builds {:app {:target :node-script
:output-to "target/script.js"
:main demo.script/main}}}module$docker$index is not defined now(defn install-timer [] (fake-timers/install)) and call that from the macro instead.r query argument -> browser tries to reload file and fails)link tag used to import the style as thats the only way to remove the csslink anymore so it won't be loaded*print-fn* such that if I print something from a function in the browser, I'll see that output in my repl. I can see that *print-fn* appears to be bound to the same thing (?) in both the client and the repl, but the behaviour diverges.repl-print-fn it seems.. although I guess that's just the var(prn :foo) from a connected repl, I see the output in the repl and the browser console, but if I do the same thing from a function (eg reagent component), then i only see it in the console.shadow-cljs cljs-repl app then those prints should be capturedrelease build won't write into location specified in {:release {:output-to "..."}}?:target are you talking about? :output-to for example is not an option for :browser:target :browser:output-dir then:modules should live in the same directory. otherwise complicates things with loader and source maps and so on:output-dir as well when running release?cljs-runtime dir you otherwise get with watch or compile output:simplegoog is not definedgoog=goog||{} which I guess comes from goog's base.js:pseudo-names true
$APP.$JSCompiler_stubMap$$ = [];
goog = goog || {};
$goog$global$$ = this || self;
$goog$NONCE_PATTERN_$$ = /^[\w+/_-]+[=]{0,2}$/;
$goog$cspNonce_$$ = null;
$goog$UID_PROPERTY_$$ = "closure_uid_" + (1E9 * Math.random() >>> 0);
$goog$uidCounter_$$ = 0;
$APP.$goog$now$$ = Date.now || function() {
return +new Date
}
;
$goog$evalWorksForGlobals_$$ = null;
$APP.$goog$inherits$$($goog$debug$Error$$, Error);var da=da||{} or pseudo-named var $goog$$ = $goog$$ || {}shadow-cljs command line tools, nothing from the compilationout/state.js - I added out to the shadow-cljs source-paths, since I read that js requires are read from the classpath, then I tried to require it in the ns form like (:require ["out/state" :as state] ... but it just appears to be an empty object :thinking_face:. This js file has exports and is used elsewhere in typescript files in the project.statee that doesn't exist I see this error printed: JS reload failed Error: Cannot find module 'out/statee' so it appears that it at least sees the module state since I don't get an error with that.Cannot find module 'out/state' so maybe it's not found. Hoping/guessing I'm just missing some small detail about this process.> node ./main.js
file:///home/john/cdktfclj/main.js:5
var SHADOW_IMPORT_PATH = __dirname + '/.shadow-cljs/builds/cdktf/dev/out/cljs-runtime';
^
ReferenceError: __dirname is not defined
at file:///home/john/cdktfclj/main.js:5:26
at file:///home/john/cdktfclj/main.js:1789:3
at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
at async Loader.import (internal/modules/esm/loader.js:166:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5)
I'm getting this error with the code that comes out of shadow-cljs compile app"type": "module", inside my package.jsonshadow-cljs is maybe outputting AMD instead of CommonJS -- is this configurable?:target :esm but you shouldn't use this when building for node currentlyCommonJS did an IIFE like AMD did__dirname not being present is purely an effect of node loading the file as a ESM module__dirname problem went away when I removed the --experimental flag to node"type": "module" is the same as --experimentalCommonJS instead of ES2015 then I get the error at the top of the other thread: module$docker$index is not defined["out/state" ...] will look for node_modules/out since it doesn't start with / or ./. so instead use ["/state.js" :as state]. the classpath will then be searched in order and if you have out on the classpath it'll eventually find <project>/out/state.jsout on the classpath (have verified with shadow-cljs classpath), and state.js exists in out, along with other js files and directories containing js files. When I try to require the file with ["/state.js" :as state] I get the following error:
[:calva-lib] Build failure:
FileNotFoundException: /home/brandon/development/calva/out/doc-mirror (Is a directory)
java.io.FileInputStream.open0 (FileInputStream.java:-2)
java.io.FileInputStream.open (FileInputStream.java:195)
java.io.FileInputStream.<init> (FileInputStream.java:138)
shadow.build.data/sha1-file (data.clj:341)
...doc-mirror is a directory, but I don't see how that is relevant / why it matters :thinking_face:index.js file (along with others), but it's the first one to contain one, alphabetically. Not sure if that has anything to do with the error./doc-mirror/index.js. it doesn't do any of the npm nonsense of guessing which file you mean. just refer to the file by name./state.js which is in the out directory. out is on the classpath, the file is in out and I import it at "/state.js" :as state . So I'm referring to it by name and starting with / so it doesn't check node_modules. When I try to do that, I get that error about that unrelated directory.Uncaught (in promise) Module not provided: ./assets/plus.js when trying to use a React component from the UI library. But this component works perfectly find in a normal JS library, in fact I was testing around with CodePen and there's nothing wrong with it. So I suspect it has something to do with shadow-cljs. I've created a GH issue with more details here: https://github.com/thheller/shadow-cljs/issues/840. Thanks in advance 🙂throw new Error('Namespace "' + name + '" already declared.'); be thrown from within goog.provide declaration? I’m trying to get webpack to happily hot reload cljs generated with :npm-modulegoog.provide with goog.constructNamespace_ as done here https://github.com/thheller/shadow-cljs/blob/f28003cbb062fd27685048e8b4793eb05ca8f829/src/main/shadow/cljs/devtools/client/env.cljs#L145:target :esm instead:npm-module has all sorts of little quirks that'll really get in your way:target :esm or :npm-module do and that works ok enough for a bit(defn get-x [] ^js/LibraryX @lib-x) (let [x (get-x)] (.methodA x) (.methodB x))manual externs
LibraryX.prototype.methodA = function() {}methodB gets renamed in release build and there's no compiler warning emitted(defn get-x ^js [] @lib-x)
^js inference seems to work fine in releaseshadow-cljs watch appBut in the browser app, I’m getting two errors:
Connection closedand
Stale clientHow to fix this error? There are warnings but no errors in the shadow command line
^js work but more specific ^js/Lib doesn't?watch you started. that can either happen if you have 2 shadow-cljs isntances running in the same project. or you changed the paths somewhere but still access the "old" JS^js solves the problem, externs inferred correctlyjps or jcmdEOF while trying to sync input stream.
shadow-cljs - HTTP server available at shadow-cljs - server version: 2.8.93 running at shadow-cljs - nREPL server started on port 7002 shadow-cljs - watching build
51168 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init5834689007742471668.clj 53409 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init6184901872508431686.clj 52882 clojure.main -m leiningen.core.main run -m shadow.cljs.devtools.cli --npm watch app 52885 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init2867749071698962093.clj 51910 53993 sun.tools.jcmd.JCmd
lein-shadow in your project.clj?(defproject vendo "0.1.0"
:description "Main Page. Vendomarch."
:url ""
:dependencies [[ch.qos.logback/logback-classic "1.2.3"]
[cheshire "5.10.0"]
[cljs-ajax "0.8.0"]
[clojure.java-time "0.3.2"]
[com.cognitect/transit-clj "1.0.324"]
[com.fasterxml.jackson.core/jackson-core "2.11.0"]
[com.fasterxml.jackson.core/jackson-databind "2.11.0"]
[com.google.javascript/closure-compiler-unshaded "v20200504" :scope "provided"]
[cprop "0.1.17"]
[day8.re-frame/http-fx "0.1.6"]
[expound "0.8.4"]
[funcool/struct "1.4.0"]
[luminus-aleph "0.1.6"]
[luminus-transit "0.1.2"]
[luminus/ring-ttl-session "0.3.3"]
[markdown-clj "1.10.4"]
[metosin/jsonista "0.2.6"]
[metosin/muuntaja "0.6.7"]
[metosin/reitit "0.5.2"]
[metosin/ring-http-response "0.9.1"]
[mount "0.1.16"]
[nrepl "0.7.0"]
[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.764" :scope "provided"]
[org.clojure/core.async "1.1.582"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f" :scope "provided"]
[org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f" :scope "provided"]
[org.clojure/tools.cli "1.0.194"]
[org.clojure/tools.logging "1.1.0"]
[org.webjars.npm/bulma "0.8.2"]
[org.webjars.npm/material-icons "0.3.1"]
[org.webjars/webjars-locator "0.40"]
[re-frame "0.12.0"]
[reagent "1.0.0-alpha2"]
[ring-webjars "0.2.0"]
[ring/ring-core "1.8.1"]
[ring/ring-defaults "0.3.2"]
[selmer "1.12.27"]
[thheller/shadow-cljs "2.8.93" :scope "provided"]
;; non-default dependencies
[com.novemberain/monger "3.1.0"]
[clj-http "3.10.1"]
[org.mongodb/mongo-java-driver "3.12.1"]
[com.cemerick/url "0.1.1"]
[com.draines/postal "2.0.3"]
[digest "1.4.9"]
;; cljs
[rgm/tailwind-cljs "0.1.0"]
[cljs-bean "1.5.0"]
[clojurewerkz/elephant "1.0.0-beta18"]
]
:min-lein-version "2.0.0"
:source-paths ["src/clj" "src/cljs" "src/cljc"]
:test-paths ["test/clj" "test/cljs"]
:resource-paths ["resources" "target/cljsbuild"]
:target-path "target/%s/"
:main ^:skip-aot vendo.core
:plugins [[lein-shadow "0.2.0"]]
:clean-targets ^{:protect false}
[:target-path "target/cljsbuild"]
:shadow-cljs
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:devtools
{:watch-dir "resources/public" :preloads [re-frisk.preload]}
:dev
{:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
:test
{:target :browser-test;;:node-test
:test-dir "resources/public/js/test"
:autorun true
:ns-regexp ".*"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}
}
:node-test
{
:target :node-test
:output-to "target/test/test.js"
}
:ci
{
:target :karma
:output-to "target/ci.js"
:ns-regexp ".*"
}
}}
:npm-deps [[shadow-cljs "2.8.93"]
[create-react-class "15.6.3"]
[react "16.13.0"]
[react-dom "16.13.0"]]
:npm-dev-deps [[xmlhttprequest "1.8.0"]]
:profiles
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "vendo.jar"
:source-paths ["env/prod/clj" "env/prod/cljs" ]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:jvm-opts ["-Dconf=dev-config.edn" ]
:dependencies [[binaryage/devtools "1.0.0"]
[cider/piggieback "0.5.0"]
[pjstadig/humane-test-output "0.10.0"]
[prone "2020-01-17"]
[re-frisk "1.3.2"]
[ring/ring-devel "1.8.1"]
[ring/ring-mock "0.4.0"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.24.1"]
[jonase/eastwood "0.3.5"]]
:source-paths ["env/dev/clj" "env/dev/cljs" "test/cljs" ]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user
:timeout 120000}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:jvm-opts ["-Dconf=test-config.edn" ]
:resource-paths ["env/test/resources"]
}
:profiles/dev {}
:profiles/test {}})lein-shadow related issueslein repl or whatever the command there is and in another process you run shadow-cljs watch appimport { some_thing } from 'goog:some.ns' ? I've done some searching but haven't found a solution.:dev {:compiler-options {:invalid-arithmetic false}} in shadow-cljs.edn silence a warning coming from a dependency?:dev {:compiler-options {:warnings {:invalid-arithmetic false}}} canReferenceError: ...... is not defined. This ...... can be almost anything, but most of the time is key, $coll, $seq or something like this. I'm not really asking to solve it, but maybe you can have some insight on where the problem is :thinking_face:$ to a symbol(int, int) or (long, long), or something). Maybe that's related? I remember that the method was resolved using reflection...:test {:target :node-test
:output-to "out/node-tests.js"
:autorun true}
to the configuration but nothing ever happens, and I don't know how to activate them:autorun will run tests after compilation. very probable that cider just isn't displaying the output, nrepl is weird in that way.:autorunshadow-cljs compile test && node out/node-tests.jshow do you run them from the repl? Since then I discovered that I can open a repl which targets :test that does what I want, but it seems I can only have one repl open in cider (?)
node the-tests.js whenever I want to run the tests. I'll still have the watch running usually to see compile errors and stuff(cljs.test/run-tests 'the.ns-test) or sonode-replshadow-cljs watch app --verbose to get a little more info about what is going on{
...
:js-options
{:resolve {"./fi" {:target :file
:require "node_modules/kepler.gl/dist/localization/fi.js"}}
...}
}
Which resulted in another error:
$jscomp.inherits is not a function
Is there some way to import this library?:compiler-options {:output-feature-set :es6}<LottieView
source={require('../components/img/animations/cat-loading.json')}
style={{marginRight: 100, marginLeft: 50}}
autoPlay
loop
/>
In this case I’m seeing the LottieView animation.
Cljs React Native:
[:> LottieView {:source (js/require "../resources/images/loading2.json")
:autoPlay true
:loop true
:style {:height 200
:marginright 200
:marginleft 50}}]
In this case I’m not seeing the LottieView animation. What might be causing this error?import LottieView from 'lottie-react-native';
js/require call. that looks wrong. might also be the :style map. not exaclty sure how reagent converts that, if at all.lumo? e.g. similar to npx shadow-cljs run ... except for .cljs files. so it would compile and then execute the script with node.:node-script and once its built you don't need shadow-cljs or the compiler at all anymoreclj -M -m cljs.main -t node -o main.js -i example.cljsshadow-cljs.edn and run multiple steps. i guess i'm really looking for something like lumo - a cljs interpereter that is pre-compiled into js on node.babashka might be a good fit? or even just clj? CLJS is only great for this is you have it precompiled and don't need the JVM anymore. Or just lumo. shadow-cljs will always require the JVM to compile so thats not the best fit if you want to compile on-demandmeander macro emits some "bad" JS code referencing jvm stuff. usually something like java.lang.Exception or so} catch (e48925) {
if (e48925 instanceof java.lang.Exception) {
var e__47256__auto__ = e48925;js/require , but trying to require them from the ns form doesn't work. The shadow compilation works, but with a require like ["/config.js" :as config] and then eval config I get
; Execution error (ReferenceError) at (
js/require insteadns :require it will become part of the shadow-cljs buildjs/require it then it will just resolve at runtime and not be part of the build:node-library. :esm will not give you any "new" features if it requires post-processing anyways. So until vscode can load ESM directly without further bundling :esm should not be used.
I'm sticking to :node-library but was thinking I could still bundle things with shadow if I could make typescript ignore the goog:.. imports, as you mentioned, and then stop using webpack. But I see you mentioned potential issues with that, so I probably will stop this approach now.js/require until you get the amount of JS code down significantly:browser and :karma build targets), so I can use devcards as a test harness for UI-based cljs tests:karma target could take a runner-ns option, I think that would do it! I was looking at using a custom runner-ns for the existing browser-target then some karma hackery to get it to run in CI, but I think doing it the other way around (starting with the existing karma target and adding a custom runner) would be simpler.:target :karma in the build config it'll "expand" :karma to shadow.build.targets.karma/process and call that function for every "stage" of the compilation. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L114:target :kira you'd create that shadow.build.targets.kira/process function and do whatever you want to do:target kira.target which would call (kira.target/process build-state) or :target kira.target/do-stuff which would call (kira.target/do-stuff build-state):shadow.build/stage etc keys to figure out what to do:runner-ns will probably be enough. the important bits there is just the exported init functiondevcards and shadow-cljs before but I can't find it:browser https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj):karma is much simpler and I think already allows what you are looking for via the :runner-ns option https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.cljshadow-cljs release with
:release {:compiler-options {:variable-renaming :off
:property-renaming :off
:pretty-print true
:source-map true
:infer-externs :auto
:output-feature-set :es6
:optimizations :simple}}
But to no avail.1 import firebase from 'firebase/app';
~~~~~~~~
8601 export = firebase;
~~~~~~~~~~~~~~~~~~
This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
If you see the message above, please use `esModuleInterop=true` in your `tsconfig.json` file.(ns kr.ui.firebase
(:require ["firebase/auth"]
["firebase/analytics"]
["firebase/app" :default firebase]
["capacitor-firebase-auth" :refer [cfaSignIn]]
["firebaseui" :as fbui]))
...
(.subscribe (cfaSignIn "") (fn [u] (js/console.log u :signed-in))) ;;offending line in my codeimport * as firebase from 'firebase/app';(cfaSignIn "") this fails?capacitor-firebase-auth expects?import * as firebase from 'firebase/app'; but you have ["firebase/app" :default firebase]lein project.clj and use codox that way. as far as I know codox doesn't actually compile the code, just needs to be able to read it.try...`catch` and then shadow tries to resolve it and fails:js-options {:resolve {"that-package" false}}shadow.http.push-state/handle and calling the wrapper in :dev-http. Same result when overriding :push-state/headers
- setting :devtools :http-handler, again pointing at my wrapper
I just wanted to ask here before going through the source, maybe there’s something i misunderstood entirely from the docs.
I’m starting the server up through emacs cljs-jack-in with
npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.9 server
;; dev/custom_handler.clj
(ns custom-handler
(:require [shadow.http.push-state :refer [handle]]))
(defn handle-wrapper
[req]
(handle (assoc-in req
[:http-config :push-state/headers]
{"conten-type" "text/html; charset=utf-8"
"access-control-allow-origin" "*"})))
;; shadow-cljs.edn
;; shadow-cljs 2.11.7
;; clojurescript 1.10.773
{:deps {:aliases [:dev :shadow :cljc]}
:nrepl {:port 8777
:middleware [refactor-nrepl.middleware/wrap-refactor]}
:dev-http {8281 {
:root "resources/public"
:push-state/headers {"access-control-allow-origin" "*"}
}
}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn remyrd.rock-n-call-frontend.core/init}}
:devtools {:http-root "resources/public"
:http-port 8280
:http-handler custom-handler/handle-wrapper
:preloads [devtools.preload]
}}}}(defn handle-wrapper
[req]
(-> req
(handle)
(update :headers merge
{"access-control-allow-origin" "*"})))dev-http and then another in devtools?:compiler-options {:output-feature-set :es6} or :es7 :es8. depending on what makes senseshadow-cljs watch since the problem doesn't happen when a release is built. I tried this with 2.11.11 and 2.11.18 and there was no change. I am on Debian Testing, none of my colleagues with Windows are experiencing this but for me, I am basically unable to work efficiently - there are no development tools for ClojureScript in Firefox. Chromium seems to be hit by this bug somewhat harder. What further debugging steps do you propose?[:browser] Build completed. (143 files, 137 compiled, 0 warnings, 8.33s)shadow-cljs watch I see:[:client] Build completed. (1106 files, 9 compiled, 0 warnings, 1.48s)
The release version looks like this:
[:client] Build completed. (1041 files, 895 compiled, 0 warnings, 113.01s)
The Java version is:
java --version
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.10+9-post-Debian-1, mixed mode, sharing):init-fn in your build config?:init-fn some.ns/foo to just :entries [some.ns]. that will cause the same code to be included but not called on startup:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:module-loader true
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:admin {:entries [orgpad.client.views.administration.core]
:depends-on #{:main}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :script}}
The init looks like this:
(defn init
"Init function of the client."
[]
(rf/dispatch-sync [:init/starting-app])
(window-events!)
(accountant/configure-navigation!
{:nav-handler #(rf/dispatch [:app/changed-route %])
:path-exists? #(routes/client-routes (:handler (b/match-route routes/routes %)))
:reload-same-path? true})
(webfonts/load!)
(mount-root))
I will try your proposed change:main {:entries [orgpad.client.core] ;:init-fn orgpad.client.core/init
:depends-on #{:shared}}
(restarted shadow-cljs watch) and it still hangs and shows "shadow-cljs - Reconnecting ..." in the browser, also the Console output looks pretty much the same as it looked before on such hangInstalling CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
util.cljs:136 CLJS DevTools: some custom formatters were not rendered.
devtools$util$check_custom_formatters_active_BANG_ @ util.cljs:136
browser.cljs:20 shadow-cljs: #6 ready!
react-dom.development.js:24995 Download the React DevTools for a better development experience:
core.cljs:11 csrf-token parsed: 9YQlw8taXECNrtRSbR8y1jjZ3awFctrGTALtx5YpLoTZxxhb0O9xIY1ZGxoTbWFGBF0D5VjbpxwKh6lWcore.cljs:11yarn start crashes and cant get pass this.shadow-cljs directory in the project. not a clue why it can't read a file it obviously found?(def csrf-token
"Value of CSRF token parsed from the metadata of HTML."
(-> "csrf-token" js/document.getElementsByName (aget 0) (.getAttribute "content")))
(js/console.log "csrf-token parsed: " csrf-token) this is the line 11:init-fn) however directly contributes to load time/static/ path or should I write a custom handler?/static/ path? You mean you don't have an actual /static/ directory on disk? that case would require a custom handler./static/ path on disk.:fs-watch {:hawk false} on an M1 Mac for 2 months now and came here to say the exact same thing. It’s faster without hawk on my setup. I should have mentioned it sooner!keyup and keydown). I've tried to use .setSelectionRange to manually correct the caret to the right place, but it gets overwritten, so right now the ugly workaround I have is to set the caret position on a short timeout. This leads to the caret visibly jumping as you type, but the characters mostly go where they need to go.
I want to stress that this all worked completely normally with figwheel, and only upgrading to shadow broke it. Are there any guesses to what might have broken it? Different optimizations, transpiling to a different version? I might have to switch back to figwheel if I can't solve this, because the current hack to type correctly is very unreliable and fragile.(defproject xxx "3.3.1"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.764"]
[org.clojure/spec.alpha "0.2.187"]
[medley "1.3.0"]
[re-frame "0.10.9"]
[garden "1.3.10"]
[day8.re-frame/http-fx "v0.2.0"]
[com.taoensso/tempura "1.2.1"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[thheller/shadow-cljs "2.11.18"]]
:plugins [[lein-garden "0.3.0"]]
:min-lein-version "2.5.3"
:source-paths ["src/clj" "src/cljs" "src/cljc"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]
:garden {:builds [{:id "screen"
:source-paths ["src/clj" "src/cljc"]
:stylesheet xxx.css/screen
:compiler {:output-to "resources/public/css/garden.css"
:pretty-print? true}}]}
:profiles {:dev {:dependencies [[binaryage/devtools "1.0.2"]
[day8.re-frame/re-frame-10x "0.3.7-react16"]
[day8.re-frame/tracing "0.6.0"]]
:plugins [[lein-kibit "0.1.8"]
[lein-shadow "0.3.1"]]}
:prod {:dependencies [[day8.re-frame/tracing-stubs "0.6.0"]]}}
:npm-deps [[create-react-class "15.6.3"]
[react "16.8.6"]
[react-dom "16.8.6"]
[react-flip-move "^3.0.4"]
[react-highlight.js "^1.0.7"]]
:npm-dev-deps [[shadow-cljs "^2.11.18"]]
:shadow-cljs {:lein true
:builds {:app {:target :browser
:modules {:app {:entries [xxx.core]}}
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}}
:devtools {:preloads [devtools.preload
day8.re-frame-10x.preload]
:watch-dir "resources/public"}
:compiler-options {:optimizations :simple}}}})1.10.773 for 2.11.18.1.10.773 did not change behaviour. I'm not ruling out a problem in re-frame/reagent/react that manifested by changing build tools, but I'm at loss so I will ask on #re-framerelease only or also with development builds?goog.DEBUG is true? In Clojure I would use requiring-resolve but that is not available in cljs. (I have a library under my :dev alias dependencies that I use during development but do not want to include in production code.) Thank you!:preloads [that.ns] in your :modules or :devtoolsmy.ns as a pre-load and in my code I use
(when goog.DEBUG (my.ns/my-fn))But will this not complain about unknown symbol
my.ns when I run release?*dyn-var* that lives in code that is save to share between both and call (when *dyn-var* (*dyn-var*)) in my prod code?(holyjak.fulcro-troubleshooting/troubleshooting-render-middleware) in my prod code I will call (js/holyjak.fulcro_troubleshooting.troubleshooting_render_middleware) As long as I only do this in dev, it will work.ns that you add to preload and that adds the middleware in question? or does it have to be in your app ns?(setup-app {:middleware <some middleware...>})
And my dev-time code is a library so I cannot assume anything about the user's code other than that it has a use for a middleware (as defined by the framework).root so I am not sure why it would fail a file system operation.
nil IOException: Operation not permitted java.io.UnixFileSystem.canonicalize0 (UnixFileSystem.java:-2) java.io.UnixFileSystem.canonicalize (UnixFileSystem.java:178) java.io.File.getCanonicalPath (File.java:620) java.io.File.getCanonicalFile (File.java:645) jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:566) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167) clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:438) shadow.build.node/flush-optimized/fn--18657 (node.clj:224) shadow.build.node/flush-optimized (node.clj:212) shadow.build.node/flush-optimized (node.clj:209) shadow.build.targets.node-library/flush (node_library.clj:194) shadow.build.targets.node-library/flush (node_library.clj:189) shadow.build.targets.node-library/process (node_library.clj:213) shadow.build.targets.node-library/process (node_library.clj:196)
:builds target, I had :output-dir "./" :output-to "./handler.js This stopped working for some reason. I changed it to :output-dir "output" :output-to "output/handler.js` and it worked! Removing the trailing / does not make a difference. Must be CircleCI or my updated Docker build image...Connecting to remote nREPL server... Clojure 1.10.1 (shadow/repl :main) Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance(I am running
npx shadow-cljs watch main )
Restarting Shadow fixed it so it is not a problem anymore but still, it was weird...[:dev] Build completed. (451 files, 3 compiled, 0 warnings, 5.12s)And would like to have the file paths of the 3 compiled files.
--verbose which is likely too verbose?(defn print-compilation-info [build-state & args]
{:shadow.build/stages #{:compile-finish :flush}}
(prn [:build-state build-state
:args args])
build-state):build-hooks [(env.hooks/print-compilation-info 1 2 3)]
build-state is not a good idea. it will be several hunderd megabytes 😛tap> and look at it in the UI-> Cache write: foo.cljs rows in addition to the non-verbose output. But i don’t find the info I need in the build-state. You think it is there in any of the stages, @thheller?(defn pez-print
{:shadow.build/state :flush}
[{:keys [build-sources] :as build-state}]
(let [compiled (get-in build-state [:shadow.build/build-info :compiled])]
(doseq [src-id build-sources
:when (contains? compiled src-id)
:let [rc (get-in build-state [:sources src-id])]]
(prn [:compiled (:resource-name rc)])))
build-state):shadow-build/build-info :compiled! Thanks. I’m tempted to name the hook like that. 😃rc will also contain all the other info. :file will have the .File instance if you need the full path. :resource-name is just the name on the classpath:file though so make sure you are only accessing it if it exist. won't exist for classpath .jar resources for example)(defn print-compiled-files
{:shadow.build/stages #{:flush}}
[{:keys [build-sources] :as build-state}]
(let [compiled
(get-in build-state
[:shadow.build/build-info
:compiled])
output
(->> rc
:resource-name
(for [src-id build-sources
:when (contains? compiled src-id)
:let [rc (get-in build-state
[:sources src-id])]])
(sort)
(into [:compiled]))]
(binding [clojure.pprint/*print-right-margin* 20]
(clojure.pprint/pprint output)))
build-state)cider-nrepl middleware does. did you install that?;; Startup: /Users/jimmy/.npm-packages/bin/npx shadow-cljs -d nrepl:0.8.2 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.4 server 43 ;; 44 ;; ClojureScript REPL type: shadow 45 ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :frontend) (shadow/nrepl-select :frontend))
m-x nrepl-toggle-message-logging and then try again. you can inspect the nrepl messages to see if there are any clues there(-->
id "51"
op "eldoc"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 11:35:14.713680000"
ns #("[my-namespace]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "helix/defnc"
)
(<--
id "51"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 11:35:14.717698000"
status ("done" "no-eldoc")m-x cider-describe-session and choose either of the two connections listed (if you only have the one connection at the moment. one is tooling, one is regular interaction). It should open up a buffer with Supported ops: and list what the connection can do. you can see if eldoc and info are supported. also, eldoc is something that happens on hover i think. I think you want to find an op of "info"(-->
id "23"
op "info"
session "dcdd12ab-8b2e-4411-8096-66c5e103943c"
time-stamp "2021-02-24 10:40:49.108554000"
ns #("metabase.sync.sync-metadata.tables-test" 0 39 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "testing"
)
(<--
id "23"
session "dcdd12ab-8b2e-4411-8096-66c5e103943c"
time-stamp "2021-02-24 10:40:49.113750000"
added "1.1"
arglists-str "[string & body]"
column 1
doc "Adds a new string to the list of testing contexts. May be n..."
file "jar:file:/Users/dan/.m2/repository/org/clojure/clojure/1.10...."
line 597
macro "true"
name "testing"
ns "clojure.test"
resource "clojure/test.clj"
see-also ("clojure.test/is" "clojure.test/deftest")
status ("done")
)(-->
id "66"
op "info"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 12:24:05.124286000"
ns #("[my-ns]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
sym "helix/defnc"
)
(<--
id "66"
session "50e453a5-e9b4-4b65-8572-923074485504"
time-stamp "2021-02-24 12:24:05.127422000"
status ("done" "no-info")
)
I do have two sessions. One shows me a big long list including eldoc and info. But the session listed above “50e453a5-e9b4-4b65-8572-923074485504” literally doesn’t open up anything when I do a cider-describe-nrepl-session:compiler-options {:output-feature-set :es3} in your build config works.release build work? watch doesn't need to work and has no priority to work.yarn start do? what template did you use? normally just shadow-cljs release <your-build-id>yarn postcss && shadow-cljs watch appshadow-cljs release appshadow-cljs watch main renderer. I can seem to do cider-connect-cljs just fine, but I can’t evaluate any functions or send anything to the repl. Maybe this is a better question for #emacs?WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information)
I wonder if this has anything to do with the problem. I even checked out the URL where it says “(https://docs.cider.mx/cider/troubleshooting.html#cider-complains-of-the-cider-nrepl-version)” but it didn’t really help.220 |
221 | export default class ABCMusicLexer extends antlr4.Lexer {
222 |
223 | static grammarFileName = "ABCMusic.g4";
---------------------------------^----------------------------------------------
'(' expected
--------------------------------------------------------------------------------
To add more details - I just call ANTLR4's code to generate some JS files that I include in my CLJS files and then I call shadow-cljs to build it all.
Is there any way to compile such classes?(def my-stack #(let [stack %
_ (DockerProvider. stack "default")
image (Image. stack "nginxImage" {})
container (Container. stack "nginxContainer" {} #_{:ports [{:internal 80
:external 8000}]})]
(set! (.-name image) "nginx:latest")
(set! (.-keepLocally image) false)
(set! (.-image container) (.-latest image))
(set! (.-name container) "tutorial")
#_(set! (.-ports container) {"internal" 80
"external" 8000})))
I should be able to set opts for these js interop objects like this:
(Container. stack "nginxContainer" {:port [{:internal 80 :external 8000}])
but this isn't working and so I'm having to use (set! -- any idea why that's not working?ports example fails either way (with or without set!) -- the error there is that it can't seem to map over [{,,,}]def with an anonymous function? makes its terribly hard to read.(Container. stack "nginxContainer" {:port [{:internal 80 :external 8000}]) I assume Container is some JS Object and you are passing a CLJS map as an argument which it very likely won't understand(Container. stack "nginxContainer" (clj->js {:port [{:internal 80 :external 8000}]))set! has the same issue. trying to pass a CLJS map to any JS object will either fail directly or fail silently since they all expect plain JS objects#js {:foo "bar"}clj-js worked! #js {,,, did not#js, I gotta apply it more liberally:
(Container. stack "nginxContainer" #js {:image (.-latest image)
:name "tutorial"
:ports #js [#js {:internal 80
:external 8000}]})(defn my-stack [app name]
(let [stack (TerraformStack. app name)
image (Image. stack "nginxImage" #js {:name "nginx:latest"
:keepLocally false})]
(DockerProvider. stack "default")
(Container. stack "nginxContainer" (clj->js {:image (.-latest image)
:name "tutorial"
:ports [{:internal 80
:external 8000}]}))))#js doesn't apply to nested values so clj->js is better for more complex structures where you don't care about performance:extension build and then open the url that I'm matching in my shadow-cljs.edn I'm getting the following error multiple times:
browser.cljs:406 WebSocket connection to '' failed: Unknown reason
shadow$cljs$devtools$client$browser$ws_connect_impl @ browser.cljs:406
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:388
browser.cljs:20 🠶 shadow-cljs: websocket error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
browser.cljs:20 🠶 shadow-cljs: WebSocket disconnected!
It keeps trying to reconnect and always fails.
I'm using binaryage/chromex shadow example as my template with some changes:
• Removed deps.edn
• Removed all dependencies
• Changed the :content-script :matches to a specific url instead of <all_urls>
More info in thread 🧵shadow-cljs.edn file looks like:
{:source-paths ["src/background"
"src/popup"
"src/content-script"]
#_#_ :dependencies [[binaryage/chromex "RELEASE"]
[binaryage/devtools "RELEASE"]]
:builds {:extension
{:target :chrome-extension
:extension-dir "resources/unpacked"
:manifest-file "resources/unpacked/manifest.edn"
:compiler-options {;
:closure-output-charset "US-ASCII"
; we need to fully inline source maps to avoid devtools security restrictions of loading .map
; files via chrome-extension://<extension-id>/out/cljs-runtime/goog.debug.error.js.map urls
:source-map-inline true}
:outputs {:background {:output-type :chrome/background
:entries [chromex-sample.background]}
:content-script {:output-type :chrome/content-script
:chrome/options {:matches [""]
:run-at "document_end"}
:entries [chromex-sample.content-script]}
:popup {:output-type :chrome/shared
:entries [chromex-sample.popup]}}}}}
manifest.edn file looks like:
{:name "Test chrome extension"
:version "1.0"
:description "Test chrome extension"
:manifest-version 2
:permissions ["http://*/*"
"https://*/*"]
:browser-action {:default-title "Show the popup"
:default-icon "images/icon48.png"
:default-popup "popup.html"}
:content-security-policy
["default-src 'self';"
;; FIXME: unsafe-eval should be injected for dev, user shouldn't have to write this
"script-src 'self' 'unsafe-eval' ;"
"connect-src * data: blob: filesystem:;"
"style-src 'self' data: chrome-extension-resource: 'unsafe-inline';"
"img-src 'self' data: chrome-extension-resource:;"
;; FIXME: localhost only? don't want to allow any origin though
"frame-src 'self' :* data: chrome-extension-resource:;"
"font-src 'self' data: chrome-extension-resource:;"
"media-src * data: blob: filesystem:;"]}
:matches?:matches is working as I'm only getting shadow error messages in this site: https://classroom.google.com/u/0/ta/not-reviewed/all:matches [""]watch and compile)release can and should be stricter:matches ["" ":*/*"] probably{:source-paths ["src/background"
"src/popup"
"src/content-script"]
#_#_:dependencies [[binaryage/chromex "RELEASE"]
[binaryage/devtools "RELEASE"]]
:builds {:extension
{:target :chrome-extension
:extension-dir "resources/unpacked"
:manifest-file "resources/unpacked/manifest.edn"
:compiler-options {:closure-output-charset "US-ASCII"
:source-map-inline true}
:outputs {:background {:output-type :chrome/background
:entries [chromex-sample.background]}
:content-script {:output-type :chrome/content-script
:chrome/options {:matches ["" ""]
:run-at "document_end"}
:entries [chromex-sample.content-script]}
:popup {:output-type :chrome/shared
:entries [chromex-sample.popup]}}}}}
":*/*" instead of ""<meta name="Content-Security-Policy" ...>:devtools {:enabled false} and it won't try to connecthttps sites[Sun Feb 28 2021 22:39:55.649] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /172.25.210.33 (port 9630) from /192.168.0.166 (port 50594) after 10000ms"}
[Sun Feb 28 2021 22:40:10.782] WARN The shadow-cljs Websocket was disconnected.
[Sun Feb 28 2021 22:40:10.792] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /172.25.210.33 (port 9630) from /192.168.0.166 (port 50612) after 10000ms"}
[Sun Feb 28 2021 22:40:10.852] LOG giving up trying to connect
adb tcpip running from windows then within WSL2 adb connect to connect to the deviceshadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}' lets you set a specific one$G__37663_G__37667_G__37671_G__37675_G__37682_G__37686_G__37691_anchor_37656_old_coll_37645_old_items_37652$ $G__37664_G__37668_G__37672_G__37676_G__37683_G__37687_G__37692_idx_37657_new_len_37651$$
cljs/closure.clj with just (ns cljs.closure) on your classpath@stitches/react , required by https://github.com/pmndrs/leva , I’ve tried setting
{:js-options {:resolve {"@stitches/react" {:target :npm
:require "@stitches/react/dist/stitches.react.esm.mjs"}}}})
but that doesnt seem to actually change the file being resolved
as can be seen
#error {
:cause closure errors
:data {:tag :shadow.build.closure/errors, :errors [{:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 1218, :msg Class names defined inside a function cannot be reassigned.} {:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 1229, :msg Class names defined inside a function cannot be reassigned.} {:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 4095, :msg Class names defined inside a function cannot be reassigned.}]}bump-closure I hit
Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1). com.google.javascript.jscomp.AnonymousFunctionNamingPolicyDo you see a quick fix? Or should I wait. Seems like David is pretty active on the branch
2.11.19 should fix thatThe required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".might be another removal
cljs/closure.clj thing.org.clojure/google-closure-library {:mvn/version "0.0-20201211-3e6c510d"}src/main/cljs/closure.clj or so(ns cljs.closure) nothing else:paths (or :source-paths if just shadow-cljs.edn) you are "overwriting" the file in the clojurescript released jar(range) causes this behavior. Are there any good strategies for dealing with this?pr-str or so on the result?cljs/eval-str and show the result in a divpr-str? THAT is were your infinite sequence is realized*print-length* to limit the amount of items printed(defonce evaluated-output (r/atom nil))
(defn compile-it [code]
(let [options {:eval cljs/js-eval
:load (partial boot/load c-state)}
callback (fn [result]
(reset! evaluated-output (:value result)))]
(cljs/eval-str c-state code "[demo-bootstrap-cljs]" options callback)))
and then I render it:
[:pre>code "Output: " [:strong (str @evaluated-output)]]
(str @evaluated-output)pr-str in either case but str is the same in this case(binding [*print-length* 5] (pr-str @evaluated-output)) might be enoughpr-str thenpr-str produces EDN outputstr calls toString (which will not always be EDN)index.html?shadow-cljs.edn in the command line?npx shadow-cljs --config-data "$(cat /path/to/shadow-cljs.edn)"
clj -M:defaults:dev:ui -A:shadow-cljs watch appbut I need to say which subproject's app build i mean and have all the paths work out.
npx:source-paths per build?'[:input {:type "text"
:default-value "foo"
:on-change (fn [e]
(frontend-ns.state/assoc-in id (.. e -target -value)))}]
which on the frontend should result in a CLJS hiccup vector where the function is a js function compiled from the CLJS counterpart.:npm-module output into a webpacked js frontend at work. One footgun is that forgetting to mark things with ^:export has no consequence during dev time but is obviously catastrophic at release time. Is it possible to have the dev build munge names so that we can kinda feel this pain under dev settings and not just in CI or (gasp) released?:target :esm. there the exports are configured in the build config so no ^:export there^:export:entries vector? Basically everything will be compiled either directly or transitively so would be nice to just get all namespaces for free.:advanced optimizations (which you should for browser builds). with one small adjustments you can just interpret the EDN though: turn functions into actual data. for [example](https://github.com/thheller/shadow-cljs/blob/f0a2ae8e9cfdbadc19641bd89327b3fb496733d3/src/main/shadow/cljs/ui/components/inspect.cljs#L107) in the stuff I'm building you'd say :on-click {:e :some.ns/foo! :with "some" :other "args" :maybe true} (just data). yes that limits you to only using events that already exist but that might be enough for you:entries [] is allowed againSyntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1). com.google.javascript.jscomp.AnonymousFunctionNamingPolicy
master yes. I still haven't checked all the closure-library/compiler related changes and verified they workAnonymousFunctionNamingPolicy issue is fixed but there might be others I'm not yet aware of since the closure-lib has undergone some rather big changes toomaster with the latest closure-compiler and library and everything appears to work fine:npm-module and using in JavaScript code... when I try to run our existing Jest unit tests for the JavaScript code, the JS file that's loading the the CLJS file is failing with
● Test suite failed to run
Namespace "goog.math.Long" already declared.
at Object.<anonymous>.goog.module (frontend/src/cljs/cljs_env.js:124:13)
at frontend/src/cljs/goog.math.long.js:14:8
at Object.<anonymous>.goog.loadModule (frontend/src/cljs/cljs_env.js:322:27)
at Object.<anonymous> (frontend/src/cljs/goog.math.long.js:12:6)
at Object.<anonymous> (frontend/src/cljs/cljs.core.js:4:1)
at Object.<anonymous> (frontend/src/cljs/metabase.types.js:4:1)
at Object.<anonymous> (frontend/src/metabase/lib/types.js:13:29)
Any idea what I might be doing wrong? I'm importing the CLJS code into the JS code like
import { isa, TYPE } from "cljs/metabase.types";
This works fine everywhere except for when I go to run the Jest unit tests:npm-module build?release builds since they don't share anything globallein and just have the files as usual on the :source-pathsIllegalArgumentException: No matching method setOriginalPath found taking 1 args for class com.google.javascript.jscomp.SourceFile$Preloaded clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) shadow.build.closure/convert-sources-simple*/iter--86592--86596/fn--86597/fn--86598 (closure.clj:1855) shadow.build.closure/convert-sources-simple*/iter--86592--86596/fn--86597 (closure.clj:1830) clojure.lang.LazySeq.sval (LazySeq.java:42) clojure.lang.LazySeq.seq (LazySeq.java:51) clojure.lang.RT.seq (RT.java:535) clojure.core/seq--5402 (core.clj:137) clojure.core.protocols/seq-reduce (protocols.clj:24) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/reduce (core.clj:6828) clojure.core/into (core.clj:6895) clojure.core/into (core.clj:6887) shadow.build.closure/convert-sources-simple* (closure.clj:1859) shadow.build.closure/convert-sources-simple* (closure.clj:1826) shadow.build.closure/convert-sources-simple (closure.clj:2117) shadow.build.closure/convert-sources-simple (closure.clj:2069) shadow.build.compiler/maybe-closure-convert (compiler.clj:1169) shadow.build.compiler/maybe-closure-convert (compiler.clj:1162) shadow.build.compiler/compile-all (compiler.clj:1414)
:runtime-id. so (shadow/repl :app {:runtime-id 123})tap> might also be useful:test-ci {:target :node-test
:output-to "out/node-test/js"
:autorun "true"
:js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}
"devcards-syntax-highlighter" {:target :npm :require "highlight.js"}}}}}
but I get
[:test-ci] Compiling ... The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".I’m quite unsure what I might have done wrong
leiningen, I can set a soft link to the library package directory from the app package directory (in the checkouts subdirectory of the app package directory). Is there a way to do something like this for development purposes with shadow-cljs where the app is a CLJS program? Or other ways to simplify development with local package dependencies?:source-paths to the proper places:source-paths and see if that can work for me. thanks!!((requiring-resolve 'cljs.repl/repl) ((requiring-resolve 'cljs.repl.browser/repl-env)) :need-prompt (constantly false) :prompt (constantly ""))But what if I have shadow-cljs in the mix? Does shadow-cljs expose a repl-env that I can pass to
cljs.repl/repl?
The most straightforward method I know of is to start a Clojure socket REPL and call (shadow.api/repl :id), but there doesn't seem to be a way to disable the prompt. Also, promoting a Clojure REPL to a ClojureScript REPL is rather problematic as far as editor integrations go, because it's difficult for the editor to know whether it's in Clojure or ClojureScript mode. I'd rather have a whole separate socket connection for the ClojureScript REPL, but I haven't found a way to do that with shadow-cljs.cljs.repl/repl equivalent in shadow-cljs but I could add the :prompt config options. why do you not want a prompt? what editor did you use? most editors use nrepl and not many people use the socket repl at all:prepl {12345 :build-id} will start a prepl on port 12345 for the build-id:prompt option would be great, but I'm not yet sure whether I'd actually end up using it. What I'd really like is a way to run a ClojureScript REPL in a way that's agnostic to build tooling.shadow.remote stuff I built might be of interest for you but thats heavily under documented and not final yetshadow.remote and one day I'll document and publish it((requiring-resolve 'cljs.repl/repl)
((requiring-resolve 'cljs.repl.browser/repl-env))
:need-prompt (constantly false)
:prompt (constantly ""))
In a shadow-cljs project, I get this:
Execution error (IllegalArgumentException) at shadow.build.cljs-hacks/eval24027$fn (cljs_hacks.cljc:981).
cljs.repl/repl will never work with shadow-cljs:prompt thing if it comes to that. In any case, thanks for the help!:prompt?(shadow/api :app).2.11.22 has (shadow/repl :id {:prompt false})=> is the "prompt" (really, the namespace indicator) my client prints (disregard the namespace there, it's WIP), the second line is the prompt shadow-cljs printed. The point is just that I'd like to be sure that what I'm getting from the server is just EDN and I can control when foo=> gets printed and how.lein new re-frame <app-name>
I see other projects set up differently and I’m wondering what is the consensus on setting this up, if any?
Lastly, any reading material you could point out regarding deployment best practices.re-frame-template uses Leiningen with Lein Shadow.
Some regard Leiningen as "the old way". But it still works pretty well for us.
If you just want to have a play around with ClojureScript, Shadow-cljs and re-frame, the template is probably more than good enough - because the build tooling doesn't matter too much. But if you are starting a new, serious project which will grow over time, then you may want to choose to not use Leiningen - the Shadow-clj docs will give you the alternative structure.watch taking > 5s to detect a change? I’m not sure what I changed, if anything, but now there’s a significant delay between when I save a file and when shadow-cljs compilesflush stage could be visible in a browser?build-state:shadow.build/build-info is the key of the data that the clients will get:sources and those have :warningsreact-color (https://www.npmjs.com/package/react-color)
I get a couple of errors and warnings when running karma on the produced code (`:karma-coverage`):
# karma start 10 03 2021 16:57:08.655:INFO [preprocessor.coverage]: coverage not included in reporters dots,progress 10 03 2021 16:57:08.881:WARN [karma]: No captured browser, open 10 03 2021 16:57:08.973:INFO [karma-server]: Karma v5.2.3 server started at 10 03 2021 16:57:08.973:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited 10 03 2021 16:57:08.976:INFO [launcher]: Starting browser ChromeHeadless 10 03 2021 16:57:10.131:INFO [Chrome Headless 88.0.4324.182 (Linux x86_64)]: Connected on socket pvu_uV4i-0kufk6WAAAA with id 85631944 10 03 2021 16:57:10.581:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$UnfoldMoreHorizontalIcon.js?80c4489cd485acfeed1e160ad69825303e4ee8e4 10 03 2021 16:57:10.595:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$CheckIcon.js?3b1f8ad831751a7b84b35493627cc64278e2c8c7 10 03 2021 16:57:10.765:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$UnfoldMoreHorizontalIcon.js?80c4489cd485acfeed1e160ad69825303e4ee8e4 10 03 2021 16:57:10.800:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$CheckIcon.js?3b1f8ad831751a7b84b35493627cc64278e2c8c7 Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$ChromeFields' Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$ChromeFields' Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$Chrome' Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$Chrome' Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$index' Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$index' Chrome Headless 88.0.4324.182 (Linux x86_64) ERROR Uncaught Module not provided: module$node_modules$$icons$material$UnfoldMoreHorizontalIcon at target/cljs-runtime/shadow.js.js:37:9 Chrome Headless 88.0.4324.182 (Linux x86_64) ERROR Uncaught Module not provided: module$node_modules$$icons$material$UnfoldMoreHorizontalIcon at target/cljs-runtime/shadow.js.js:37:9I read some passed discussions on this channel, about adding
:js-options {:ignore-asset-requires true}, others about adding :compiler-options {:output-feature-set :es8} but none solved my issue.module$node_modules$$icons$material$UnfoldMoreHorizontalIcon.js
module$node_modules$$icons$material$CheckIcon.js
...with that double $ which doesn't match the ones indicated in the 404 warnings.$$ are the replacements for the /@ in actual source path (which aren't valid in JS identifiers)$$ in $ for some reason?:karma-coverage target. With :karma it works just fine.shadow-cljs 2.10.6 to 2.11.22, and I see a number of warnings about not being able to infer the type of things. I've gone though and manually hinted most them as ^js , but I'm getting warnings that I don't know how to hint everytime I use a deftype that implements reagent.ratom.IReactiveAtom.
387 |
388 | (deftype Foo [^:mutable amdoc ^:mutable clj-value ^:mutable snapshot meta validator ^:mutable watches ^:mutable callback]
-------^------------------------------------------------------------------------
Cannot infer target type in expression (. (. Foo -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
389 | IAtom
390 | reagent.ratom.IReactiveAtom
391 |
392 | FooClassification
Any insight as to why this is happening now, and more importantly, how to resolve it?reagent.ratom.IReactiveAtom should be reagent.ratom/IReactiveAtom I think(set! *warn-on-infer* false):compiler-options {:infer-extern true}
How did we end up with a frontend between acme and app ?
The dots become slashes in the expected directory structure? Then in the edn you have
:builds
{:frontend
...
What happened to acme and app here?
There just seems to be an awful lot of magic happening here based on strings and names that I'm not understanding. I think I just need to create a few examples using the npx create-cljs-project with different names and see what gets created. Thanks!acme-app. that is literally only the directory name the files are in. it has nothing to do with what the project does. The name I picked because naming is hard but I tried to explain why I didfoo.core namespaces. I personally don't like .core names so I used something else. its just a name, use what makes sense for you.learn-reframe folder.
.
├── learn-reframe.iml
├── node_modules
├── package.json
├── package-lock.json
├── pom.xml
├── shadow-cljs.edn
└── src
└─ main
└─ test
For now I don't care about names so a random prefix will do, exfn
So I create
src\main\exfn\app.cljsWith namespace
(ns )So I my edn should look like this:
{...
:builds
{:???
{:target :browser
:modules {:main {:init-fn }}}}}
I'm not sure what my :??? would be :exfn or :app?:app I think?:app is fineshadow-cljs watch app etc commands:npm-module and bundling that into a webpack frontend, is it possible to get a cljs repl connected to the webpacked build? Does shadow emit all of the necessary bridge stuff during a watch such that this is a reasonable thing to expect?shadow.cljs.devtools.client.browser ns from the JS side of things. so if (process.env.NODE_ENV === "development") { require("wherever/shadow.cljs.devtools.client.browser.js") }process.env.NODE_ENV? I'm quite the beginner with webpack stuff. presumably that's in the webpack config? i'm surprised to see a require that uses that(when (identical? js/process.env.NODE_ENV "development") (js/require "./shadow.cljs.devtools.client.browser.js")) should work:npm-module. so it cannot inject that for you before loading that ns[Thu Mar 11 2021 15:25:10.620] WARN The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:25:10.640] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
[Thu Mar 11 2021 15:26:37.705] WARN The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:26:37.706] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
[Thu Mar 11 2021 15:28:01.413] WARN The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:28:01.419] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Network is unreachable"}
[Thu Mar 11 2021 15:29:27.332] WARN The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:29:27.333] ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
everything is running smoothly but I get the warning and error periodically.(defn init []
(dispatch [:register-db])
(render-root "Humboi" (as-element [view];;[root-comp]
)))
Basically removed the root-comp with a rn view------ WARNING #1 - :fn-arity -------------------------------------------------- Resource: re_frisk/trace.cljs:27:11 Wrong number of args (1) passed to reagent.impl.component/do-render -------------------------------------------------------------------------------- ------ WARNING #2 - :fn-arity -------------------------------------------------- Resource: re_frisk/trace.cljs:31:54 Wrong number of args (1) passed to reagent.impl.component/do-render -------------------------------------------------------------------------------- ------ WARNING #3 - :undeclared-var -------------------------------------------- Resource: re_frisk_remote/core.cljs:120:15 Use of undeclared Var reagent.impl.component/static-fns --------------------------------------------------------------------------------
:target -> :karma js bundle is too big to be handled by karma-coverage plugin (JavaScript heap out of memory is thrown). The idea I had in my mind to split tests and source code into different modules and check coverage only on source part. But to be honest I have no idea on how to implement that.
So my questions are:
1. Is it possible to use :modules for :build -> :target -> :karma ? I have tried and it seems they are ignored
2. Can we use namespace regex for :modules -> :entries ? I have tried :entries [".*-tests"] but it doesn’t work:modules is not supported by :target :karma. the target however is very little code so you can maybe figure out what you need and modify it to fit your needs. see https://github.com/thheller/shadow-cljs/blob/d810a0f5e1b1c78f15e0365ce7a05cba16f0ca70/src/main/shadow/build/targets/karma.cljshadow from React Native. the library depends both directly and transitively on node's crypto module. i'm not super familiar with RN and its tooling, but it seems to be a well-recognized limitation that the crypto module needs to be browserified to some degree in order to be used, so all the proposed solutions trickle down into the build process. does this seem like something we could solve by tweaking shadow configuration? we've tried using :target :react-native and a few ways of redirecting :resolve, but the transitive dependency seems to retain require('crypto') somewhere or another. most recently weve been looking into ways of combining :js-provider :require with whatever polyfills crypto in :target :browser. let me know your thoughts and how you might approach this, it would be pretty awesome to get this workingkaocha will not help here:target :react-native and follow whatever react-native instructions are for using the crypto module. there should be some? this needs to be resolved in the react-native configuration side of things. something in metro probably. no clue how.crypto from metro would have a lot more documentation, but everything i've been able to find seems somewhat poorly supported. i was hoping to shield consumers of the library from a change to their build process, but it seems that might not be the best route.:js-options {:keep-as-require #{"react-native"}} for example:js-provider :shadow and it'll bundle every JS require except for those mentioned in :keep-as-require.crypto that might work. fairly undesirable but it might work:js-provider :require is hardcoded for :react-nativeshadow . i highly admire how easy it has been to grok how the config comes together:js-provider :shadow and :keep-as-require https://github.com/thheller/shadow-cljs/blob/ea54e4b943c762645178303778aef094387f1a85/src/main/shadow/build/targets/react_native.clj#L131metro solution (https://github.com/brix/crypto-js/pull/259#issuecomment-588201011), which is the best way ive been able to find to do it generally (assuming it works). but im still going to see if im able to produce an artifact that doesnt need it directly from shadow, since i think that would be a pretty neat capability:target :browser is not meant for react-native and don't waste your time trying to adjust it.:fs-watch {:hawk false} in shadow-cljs.edn should also workrelease build with optimizations :simple breaks due to loading errors, but optimizations :advanced works fine.
I get things like::js-options {:minimize-require false} in your build config. that'll at least make it more obvious which files failshadow-cljs release app --debug might also helpResource: node_modules/automerge/src/automerge.js:2 constant module$node_modules$automerge$src$automerge assigned a value more than once. Original definition at externs.shadow.js:20
import AsyncStorage from '@react-native-async-storage/async-storage';into shadow-cljs:
(ns com.yardwerk.mobile-ui.async-storage
(:require
[cognitect.transit :as t]
[com.fulcrologic.fulcro-native.alpha.components :as c :refer [react-factory]]
["@react-native-async-storage/async-storage" :default AsyncStorage]))
and I am getting the following error:
undefined is not an object (evaluating 'shadow.js.shim.module$$react_native_async_storage$async_storage.default')I am scratching my head. I checked everything -- the package.json, reloaded node_modules, etc. Anybody run into this problem?
["@react-native-async-storage/async-storage" :as AsyncStorage]. your translation is otherwise correct but sometimes packages don't actually have a default export and are bundled as commonjssetItem fails:
undefined is not an object (evaluating 'shadow.js.shim.module$$react_native_async_storage$async_storage.setItem')
(js/console.log AsyncStorage) or so to find out what it actually isnpm installlein install, except if you want to use it the recommended way (npm)?lein install.m2 so that has nothing to do with itsrc/main into the source paths of your project~/code so just :source-paths ["src/main" "../shadow-cljs/src/main"]. while keeping the normal shadow-cljs dependency to get all other transitive dependencies and stuffdeps.edn alias:
:dev-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.22"}
...
:main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "ui"]}
and shadow-cljs.ednbuild:
{:ui {:target :browser
:output-dir "projects/ui/public/js"
:asset-path "projects/ui/js"
:module-hash-names false
:modules {:ui {:init-fn ui.main/init!
:preloads [devtools.preload
day8.re-frame-10x.preload]}}
:dev {:compiler-options {:infer-externs :auto
:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:devtools {:repl-pprint true
:preloads [shadow.remote.runtime.cljs.browser]
:http-root "projects/ui/public"
:http-port 8280}}}
When i load the app in the browser, I get "is the watch for this app running?". I only changed paths to move the location of shadow-cljs.edn up a couple of directories. Any help appreciated.:asset-path looks incorrect. likely that should just be /js?:assset-pathto "/js", but I still get the same error. My command is:
clojure -M:defaults:ui:dev-cljswhere
defaultsis a set of override-deps to version-lock libraries shared across projects and ui is:
{:extra-deps {ui/ui {:local/root "projects/ui"}}}
which adds the project-level deps.edn<project>/projects/ui/public<script src="/js/ui.js"> in the HTML:output-dir and the :http-root serves them:preloads [shadow.remote.runtime.cljs.browser]. that has been the default for a while now.:modules key does.shadow-cljs watch?npx shadow-cljs run shadow.cljs.build-report app report.htmlOne thing I noticed, is that currently the clojurescript runtime is taking 400kb. That seems surprising — I thought it would be doing some kind of tree-shaking. (To test, I deleted all code in
core.cljs, and left the imports)
Here’s my shadow config in project.clj:
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:watch-dir "resources/public"}}
:test
{:target :node-test
:output-to "target/test/test.js"
:autorun true}}}
I may be missing something trivial. (perhaps I need to manually set a certain kind of :optimizations? Any pointers / resources for debugging further would be appreciated!/dev/…/app.cljs file, which imports
[cljs.spec.alpha :as s]
[expound.alpha :as expound]
[devtools.core :as devtools]))
And my core.cljs file imported [reitit.coercion.spec :as reitit-spec], which seem to also be a culprit.
My guess right now is that I am incorrectly using /dev/ vs /prod/, and then will learn more about what reitit-spec is about.:preloads ns/env/dev/cljs/[app-name]/app.cljs , which does the following:
(ns ^:dev/once
(:require
[virtual-library.core :as core]
[cljs.spec.alpha :as s]
[expound.alpha :as expound]
[devtools.core :as devtools]))
(extend-protocol IPrintWithWriter
js/Symbol
(-pr-writer [sym writer _]
(-write writer (str "\"" (.toString sym) "\""))))
(set! s/*explain-out* expound/printer)
(enable-console-print!)
(devtools/install!)
(core/init!)
Looking at project.clj, looks like this gets replaced by a /prod/ in uberjar:
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "virtual-library.jar"
:source-paths ["env/prod/clj" "env/prod/cljs" ]
:resource-paths ["env/prod/resources"]}
I think the way I set up shadow, the reporting script is assuming env/dev/*. Will look deeper into this, and :preloads.
From a quick test, looks like this is indeed what is happening,:modules {:app {:init-fn ! :preloads [virtual-library.dev]}}.dev ns(enable-console-print!) (devtools/install!) (core/init!)
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:init-fn virtual-library.core/init! :preloads [virtual-library.dev]}}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:preloads [day8.re-frame-10x.preload]
:watch-dir "resources/public"}}
:test
{:target :node-test
:output-to "target/test/test.js"
:autorun true}}}
first thought, will try moving day8.re-frame-10x.preload into virtual-library.dev . Let me know if there’s more cleanup I could do : } — thanks team:preloads together. either in :modules or :devtools is fine^:export some variables for JS consumption - the build in shadow is :npm-module. To clean things up I wanted to do export a cljs var within a macro, but I'm struggling to find a way to do so - attaching the metadata to the resulting cljs var doesn't get shadow to include the var in the module.exports. I can goog.exportSymbol manually in the macro code, but I do I also need the JS var in the module.exports object. Is this a known limitation or is there a way to get this working?(defmacro make-story2 [nm body]
`(defn ^:export ~nm []
(reagent.core/as-element ~body)))
I've also tried:
(defmacro make-story2 [nm body]
`(do
(defn ~nm []
(reagent.core/as-element ~body))
(alter-meta! (var ~nm) assoc :export true)))(defmacro make-story2 [nm body]
`(defn ~nm
{:export true} []
(reagent.core/as-element ~body)))defn, but not for def I guess I can refactor to use defn^:export ~nm [] isn't valud~(vary-meta nm assoc :export true) would do it(defmacro make-story2 [nm body]
`(defn ~(vary-meta nm assoc :export true) []
(reagent.core/as-element ~body)))SyntaxError: Invalid or unexpected token at eval (<anonymous>) at Object.goog.globalEval () at Object.env.evalLoad () atThe error doesn't really tell me where the problem lies, and the compiled js file being loaded is >4000 lines. How can I figure out what's causing the error?
:output-dir:devtools {:loader-mode :script} in the build config:loader-mode will load things as one script at a time, instead of all at once:8281?:loader-mode :script gave me a much nicer error, albeit in a different file...:script will not abort loading if one file fails. so it likely just creates a cascade of other errorslein checkouts 😉 or deps.edn via :local/root:source-paths might work too (thats what I usually do)(ns core
(:require [cljs.spec.alpha :as s :include-macros true]))
(def exports #js
{:and s/and})s/or is a macro. you cannot call it dynamically from a function. what you are trying is simply not possible without eval:closure-defineswatch or compile produce the cljs-runtime dir. release does not and does not need it. it also doesn't clear it though. you can just rm -rf the-output-dir && shadow-cljs release app or so yourselfDevTools failed to load SourceMap: Could not parse content for :<dev-http-port>/some/path/within/<:asset-path>/cljs-runtime/<cljs-ns>.js.map: Unexpected token < in JSON at position 0I have looked into the generated code and reviewed the source maps v3 specification; shadow-cljs writes relative sourceMappingUrl (and sourceURL). According to the spec the browser should resolve sourceMappingURL relative to the "page's origin" for evaled code. As it stands, the only chance I have to make this work is to pass a custom
:dev-http :handler that strips /some/path/within from the URL before handing it to the default :handler, correct?
Would it make sense to provide an option to have shadow-cljs create absolute URLs for sourceMappingUrl and sourceURL? This would probably only make sense with a single port :dev-http ...:asset-path. so "/js" instead of "js" or whereever you have your files:asset-path with / has lead to the creation of absolute // # sourceURL and everything works as expected now. Thank you for debugging my configuration without me even sharing it..
Thank you for your quick response and your great work on shadow-cljs:raised_hands::dev-http. :asset-path is the config option that controls this.FileNotFoundException: .shadow-cljs/builds/app/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long)
java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
java.io.FileOutputStream.open (FileOutputStream.java:298)
java.io.FileOutputStream.<init> (FileOutputStream.java:237)
java.io.FileOutputStream.<init> (FileOutputStream.java:187)
shadow.build.cache/write-file (cache.clj:24)
shadow.build.cache/write-file (cache.clj:24)
shadow.build.closure/convert-sources-simple/fn--12171/fn--12173 (closure.clj:2139)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6827)
clojure.core/reduce (core.clj:6810)
....shadow-cljs.edn file to it with a :test build that runs my (failing) tests. Now I want to connect my REPL to it. I get No JS runtime if I try to eveluate anything towards the :test build. Is there a way I could make that work? Guessing not, so next question is how do I create a build that I can connect to and use for REPL-ing? I could make a small webapp, I guess, but it still seems a bit heavier than what I really need. Anyone know of a library project out there I could have a look at?shadow-cljs node-repl or shadow-cljs browser-repl:test builds (assuming that is actually :browser-test or :node-test) do not support REPLs:node-test. I’m trying to make it using CLJC, so same tests for Clojure as for ClojureScript. They run, but all fail utterly. I want to be able to load the test file and the tested file in the repl. Tried node-repl which also gave me No JS runtime, but I am testing it via Calva, which I haven’t done in a while, so that might be broken. Will try from the prompt now and see what that gives me.node-repl and then connecting to the test build instead of the node-repl?node-repllet> macro stuff you helped me with over at ClojureVerse) also works. That’s great. But the tests are not passing in the :test build. I’ll see if I can figure that out.browser-repl option, btw.(testing "Taps the binding box"
(let [tapped (atom nil)
save-tap (fn [v] (reset! tapped v))]
(add-tap save-tap)
(is (= [:foo :bar]
(sut/let> [foo :foo
bar :bar]
[foo bar])))
(is (= '[[foo :foo]
[bar :bar]]
@tapped))
(remove-tap save-tap)))
Failing like this:
FAIL in (let>) (pez/taplet_test.cljc:20:11) Taps the binding box expected: (= (quote [[foo :foo] [bar :bar]]) (clojure.core/deref tapped)) actual: (not (= [[foo :foo] [bar :bar]] nil))
setTimeout so it is async(defn sync-fn [f] (f))
(def ^:dynamic *dummy* nil)
(deftest let>
(testing "Evaluates as `let`"
(is (= [:foo :bar] (sut/let> [foo :foo
bar :bar]
[foo bar]))))
(testing "Taps the binding box"
(let [tapped (atom nil)
save-tap (fn [v] (reset! tapped v))]
(add-tap save-tap)
(is (= [:foo :bar]
(binding [#?(:clj *dummy*
:cljs *exec-tap-fn*) sync-fn]
(sut/let> [foo :foo
bar :bar]
[foo bar]))))
(is (= '[[foo :foo]
[bar :bar]]
@tapped))
(remove-tap save-tap)))
...
It works, but ¯\(ツ)/¯binding to just use do for CLJ but this is fine too#?(:cljs (set! *exec-tap-fn* (fn [f] (f))) somewhere in that fileerror when calling lifecycle function app.core/reload! #error {:message "Unexpected compile spec type", :data {:given nil, :type nil}}
eval @ env.cljs:198
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:196
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:233
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
eval @ env.cljs:240
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:49
eval @ browser.cljs:93
eval @ shared.cljs:32
shadow$remote$runtime$shared$process @ shared.cljc:164
eval @ shared.cljs:284
shadow$cljs$devtools$client$shared$remote_msg @ shared.cljs:16
eval @ websocket.cljs:16reload! method throws an exception. no clue what.{:builds :....
{:target :browser
:output-dir "out/testtt"
:compiler-options {:infer-externs :auto}
:modules {:shared {:entries [cypress.core]}
:cypress.blablabla.edit-test
{:entries [cypress.blablabla.edit-test]
:depends-on #{:shared}}
:cypress.blablabla.add-test
{:entries [cypress.blablabla.add-test]
:depends-on #{:shared}}}}}
And thanks for this very awesome piece of software, Thomas o/cypress.blablabla... namespace, right now it creates a thin js file for each, it gives me SHADOW_ENV is not defined error. The only way to do this is through a build (maybe any other dynamic way)?shared.js first before loading the other moduleSHADOW_ENV comes from)shared.js + the module fileshared.js before appears to be the best approach, I just wanted to check if there was another way.
Thanks, @thheller and @mauricio.szabo o/:target abstraction in shadow-cljs would allow for a :target :cypress and then just take the minimum amount of config to emit the output that fits best for cypressUncaught TypeError: a is undefined createGenerator shared.js:27 levels index.js:757
levels: function* levels(editor) {
.....
yield* levels;
},
Does anyone know if there some shadow setting I have missed? Or something else obvious?(defn text-editor* []
(r/as-element
(let [editor (slate-react/withReact (slate/createEditor))
[value setValue!] (react/useState [{:type "paragraph"
:children [{ :text "A line of text in a paragraph." }]
}])]
[:> slate-react/Slate {:editor editor
:value value
:onChange setValue!}
[:> slate-react/Editable]])))
createGenerator and I notice that the fn above createGenerator in the callstack itself a generator (`yield return..`) - I am guessing google closure does something to insert the call to createGeneratoreditor is actually what you expect? I mean log it or so. I don't have a clue what any of this does but the code looks very suspiciousreact/useState you are using a CLJS datastructure that you then hand to the slate-react/Slate via :value. so unless slate-react is some kind of CLJS wrapper for slate that will likely not work. also the (slate/createEditor) would recreate the editor on every render.arguments: undefined
arguments: Arguments(2) [{…}, {…}, callee: ƒ, Symbol(Symbol.iterator): ƒ]
inside of chrome's Scope Local display. Clearly something weird there. Should I be asking about this in the more general clojurescript or could this be some weird compilation/module bundling thing caused by shadow?r/with-let and clj->js on the maps provided. Strangely, the observed behaviour did not change (I originally though there was some magic happening doing the clj->js conversion behind the scenes)ns form to add :requires as well, so I imagine that would make it more difficult to integrate ?tap> integration is basically the first step in that directionrelease builds and just seamlessly disappears(+ x 5)^:re-frame/trace
• If it is there, then look for all reg-event-* forms in that ns
• Replace all the fn or defn forms in those forms with fn-traced or defn-traced from re-frame-debux
• Or, if macroexpansion has already run just do the equivalent of the re-frame-debux macroexpansion inline, but we would still need to refer to some helper fns / global state to store the tracing via requires. :compile-prepare I see a bunch of files in the build-state . Can one just replace those files in their entirety with a different file (i.e. read the file, modify it, write it out to a tmp location) then return the new tmp files in the build state ? or is that a really bad idea ?:compile-prepare all dependencies are already resolved. so you cannot add a new require or so for example.:ns-aliasesrender-root call. if you do not use that you are on your own and I cannot help.render-root and also added {:dev/after-load true} but the refresh doesn’t happengoog.object/get in a reframe handler. Does that come under “missing :ns require”?js/{:deps true
:builds
{:test
{:target :npm-module
:output-dir "test-out"
:entries [humboi.core-test]}
:dev
{:target :react-native
:init-fn humboi.core/init
:output-dir "app"
:compiler-options {:closure-defines
{"re_frame.trace.trace_enabled_QMARK_" true}}
}}}
(defn
init
{:dev/after-load true}
[]
(dispatch [:register-db])
(render-root "Humboi" (as-element [root-comp]))):register-db thing does or the root-comp(defn
init
{:dev/after-load true}
[]
(render-root "Humboi" (as-element [view])))
Change to this ^^, but still no hot-reloading(js/console.log "foo") to the init fn to check if its actually getting calledwatch running so it should connect automaticallygiving up trying to connect
:local-ip "1.2.3.4" in your build config or shadow-cljs watch app --config-merge '{:local-ip ...}'shadow-cljs release app ?
I create an app template using create-reagent-template. I’m using shadow-cljs with the lein flag set to true. The dev setup works using shadow-cljs watch app but I noticed there’s no index.html file generated. Similarly, when I build the release version, there’s not index.html . I’m failing to understand what is the entry point of the reagent app.
I’m trying to deploy to Firebase Hosting but predictably it complains with a 404. Here’s my shadow-cljs.edn :
{:lein true
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:app {:entries [noorvir.com.core]}}
:devtools {:after-load noorvir.com.core/mount-root}}}
:dev-http {3000 {:root "public"
:handler noorvir.com.handler/app}}}
Thanks in advance!index.html is your job. shadow-cljs does not handle html generation.
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link href="/css/styles.css" rel="stylesheet" type="text/css">
</head>
<body class="body-container">
<div id="app"></div>
<script src="js/app.js" type="text/javascript"></script>
</body>
</html>
Am I supposed to call an init method somewhere?:entries [.core] to :init-fn .core/initinit! which I didn’t notice.release? what did your :handler do?(def app
(reitit-ring/ring-handler
(reitit-ring/router
[["/" {:get {:handler index-handler}}]
["/items"
["" {:get {:handler index-handler}}]
["/:item-id" {:get {:handler index-handler
:parameters {:path {:item-id int?}}}}]]
["/about" {:get {:handler index-handler}}]
["/cards" {:get {:handler cards-handler}}]])
(reitit-ring/routes
(reitit-ring/create-resource-handler {:path "/" :root "/public"})
(reitit-ring/create-default-handler))
{:middleware middleware}))index.html and :dev-http {3000 "public"} is enoughinit! which I didn’t notice.js outputcreate-cljs-project described here https://github.com/thheller/shadow-cljs#quick-start(ns humboi.events (:require [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [ajax.edn :as edn] [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax] [day8.re-frame.http-fx] [cljs.core.async :refer [go]] ))However, I’m getting this error:
1. Unhandled java.io.FileNotFoundException Could not locate day8/re_frame/http_fx__init.class, day8/re_frame/http_fx.clj or day8/re_frame/http_fx.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.why is the repl looking for java files? Why am I on a clojure repl? In the same repl, when I do (shadow/watch :dev) it works and the watch is running smoothly too.
(shadow/repl :the-build)
Are these of any help to you?
https://shadow-cljs.github.io/docs/UsersGuide.html#build-repl
https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_repl
https://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage
https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integrationshadow option in cider, and try to run (shadow/watch :dev), I get No available cljs runtimeshadow-cljs run shadow.cljs.build-report app report.html and getting an error:
Caused by: NoSuchFileException: .shadow-cljs/release-snapshots/app/latest/goog.debug.error.js.mapI've tried created the build both after a
compile and a release but get the same error. Project is :npm-module. Anyone ever see anything like this?:browser builds. doesn't make sense for :npm-module builds since they are "incomplete"material-ui/ which also uses @emotion/styled and @emotion/react and running into some issues with the :require/:refer:
core.js:1662 TypeError: module.keyframes is not a function
at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple (TouchRipple.js:58)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$ButtonBase (ButtonBase.js:37)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$index (index.js:34)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$node$AccordionSummary$AccordionSummary (AccordionSummary.js:31)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$material_ui$core$node$AccordionSummary$index (index.js:27)
at shadow.js.jsRequire (js.js:66)
I'm using shadow-cljs 2.11.20
Which seems to be the :refer of https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/index.js#L20@next packages you are on your own. they are unreleased preview alpha packages that very likely contain some breaking changes that might not match "current" documentation or so@material-ui/styled-engineshadow-cljs.edn uses the aot artifact by defaultthheller/shadow-cljs dependecy to thheller/shadow-cljs$aot in deps.edn I thinkwith-profile with shadow-cljs, like when I use aliases with -A using deps.edn?lein directly if you need that. lein with-profiles +foo run -m shadow.cljs.devtools.cli release app or whatever would be similar to shadow-cljs release app:ssl in our configuration which enabling https for all builds. Is it possible to run :devtools for one of the build on http?
To add more context: I am trying to run tests using https://github.com/lambdaisland/kaocha-cljs2 and having https there adding a lot of overhead to setup all the tools to have proper certificates provided everywhere. Also Chrome complains with registering custom ServiceWorkers when self signed certificates are used which seems to be configurable but again adds another overhead.2.11.26 I added an option to allow that. :dev-http {3000 {:root "public" :ssl false}}:dev-http is a global configuration, isn’t? What I need to run one of the builds (test one) on http, but I want application build still to be run using https. Is it possible to solve somehow, maybe disable ssl using :devtools configuration?:devtools :http-root and :http-port are old configuration and were replaced by :dev-http:devtools {:http-port 3000 :http-root "public"} that should instead be :dev-http {3000 "public"} or the the example above with the disabled :ssl:dev-http {3000 {:root "public" :ssl false} 3001 "something-else"}[:failed-to-compare "^16.13.1" "16.9.0" #error {
:cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:via
[{:type java.lang.NullPointerException
:message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
:trace
[[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]
[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]
[shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]
[shadow.cljs.devtools.server.npm_deps$fn__17458$fn__17459 invoke "npm_deps.clj" 46]
[clojure.lang.Delay deref "Delay.java" 42]
[clojure.core$deref invokeStatic "core.clj" 2320]
[clojure.core$deref invoke "core.clj" 2306]
[shadow.cljs.devtools.server.npm_deps$fn__17458$fn__17461 invoke "npm_deps.clj" 52]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]
[shadow.cljs.devtools.server.npm_deps$main$fn__17546 invoke "npm_deps.clj" 223]
[clojure.core$complement$fn__5669 invoke "core.clj" 1441]
[clojure.core$filter$fn__5893 invoke "core.clj" 2821]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.RT seq "RT.java" 535]
[clojure.core$seq__5402 invokeStatic "core.clj" 137]
[clojure.core$seq__5402 invoke "core.clj" 137]
[shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]
[shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]
[shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]
[shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$apply invoke "core.clj" 660]
[shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]
[shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 665]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}]=== Version jar: 2.11.25 cli: 2.11.25 deps: 1.3.2 config-version: 2.11.25
(render)) in your file? you should not be doing that.:init-fn in your module to call the code you want to run on startup{:target :browser :modules {:sw {:init-fn my.sw/init :web-worker true}}} should be ok"dependencies": {
...
"vega": "5.20.0",
"vega-embed": "6.17.0",
"vega-lite": "5.0.0"
...
}
When the application starts up, these warnings show up in the browser console
as soon as the application loads.
shadow-cljs - failed to load module$node_modules$d3_array$dist$d3_array js.js:74:16 shadow-cljs - failed to load module$node_modules$vega_format$build$vega_format js.js:74:16 shadow-cljs - failed to load module$node_modules$vega_loader$build$vega_loader js.js:74:16 shadow-cljs - failed to load module$node_modules$vega_dataflow$build$vega_dataflow js.js:74:16 shadow-cljs - failed to load module$node_modules$vega$build$vega_node js.js:74:16 shadow-cljs - failed to load module$node_modules$vega_embed$build$vega_embedIn my cljs code, I'm attempting to use the vega library like this.
(ns components.charts.vega-chart
(:require
;; ...
["vega-embed" :as vega-embed]))
;; later in the namespace
(vega-embed/embed node spec options)
The value of vega-embed is an empty javascript object. The problem seems to be occuring before I even get to exectue this code.
If I evaluate any of my cljs code that makes use of vega-embed I get a bunch of errors that all trace back to the vega code not being loaded (nils, not a function, etc)
Would anyone be able to help me get to the bottom of this?:output-feature-set :es6
to my shadow-cljs :compiler-options map fixed this for me. I got the idea from this post https://stackoverflow.com/questions/64461818/require-aws-amplify-v-3-amplify-and-auth-classes-in-clojurescript-reagent-shadow:autorun option for a build with a :browser-test target? I find it pretty useful to be able to run the test with one command, like the :node-test ones:karma:target :esm and watch ? is there anything I could help with in that direction?:target :custom :devools {:client-ns the.ns-you-work-on}} in your build configload.clj :
(ns load
(:require [clojure.data.csv :as csv]
[ :as io]))
(defmacro timeline
[]
(with-open [reader (io/reader (io/resource "timeline.csv"))]
(doall (csv/read-csv reader :separator \;))))
and a load.cljs :
(ns load (:require-macros [load]))but when I try to require and then use it from my
user.cljs , e.g.,
(ns user (:require [load :as load])) (def timeline-data (load/timeline))I get an error which seems to be related to the amount of lines in the csv file (433)
(macroexpand '(load/timeline)) then it works. I’m sure I’m just doing some n00b macro error here.([1 2 3] [3 4 5])doall with a vec and it should be okSharedArrayBuffer and it looks like it originates from something like shadow$provide.module$node_modules$scheduler$cjs$scheduler_development.(defn js-i18n [format-string-string & args]
(js* "ttag/t`~{}`" format-string-string)
(apply ttag/t (-> format-string-string chomp-format-string into-array) args))
i'm playing around with emitting a tagged format literal in js for our i18n. And strangely, this is emitting
(metabase.shared.util.i18n.js_i18n.cljs$core$IFn$_invoke$arity$variadic = (function (format_string_string,args){
ttag/t`format_string_string`;
return cljs.core.apply.cljs$core$IFn$_invoke$arity$3(shadow.js.shim.module$ttag.t,cljs.core.into_array.cljs$core$IFn$_invoke$arity$1(metabase.shared.util.i18n.chomp_format_string(format_string_string)),args);
}));
which is including the name of the var, not its contents: ttag/t'format_string_string' (had to use apostrophes instead of backticks here).
however, evaluating (js* "1 + ~{}" x) at a repl where x is (def x 3) correctly yeilds 4. So it seems to resolve at runtime in a repl but under advanced compilation uses the local name(js* "1 + ~{}" x) ends up as 1 + x in the code so of course that is valid?1 + 3 instead of 1 + x with that being a valid localjs* special form? or does that strike you as the wrong approach?(js/ttag.t (js-template "foo"))?t(`foo`) //distinct from t`foo`
myTag`That ${ person } is a ${ age }.`;
is equivalent to
myTag(["That ", " is a "], person, age)
(js-template foo "bar") or (js-tagged-template foo "bar")(js-template (function-that-is-called-with-template-arg) "foo") is
function_that_is_called_with_template_arg()`foo`
(js-template js/ttag.t "foo") would be
ttag.t`foo`
(js-template alias/foo "foo") would be
whatever.alias.was.foo`foo`
:npm-module so if you have (:require ["ttag" :refer (t)]) and (js-template t "foo") what would give you
shadow.js.shim.module$ttag = require("ttag");
shadow.js.shim.module$ttag.t`foo`(js* "ttag/t~{}) to get it to workjs*, doesn't need to do all I'm doing now2.12.0 (minor bump because of new cljs version) which also has the (js-template ...) if you want to try thatshadow-cljs - server version: 2.12.0 running at , and (js-template ttag/t "hello") is giving me an error about an undeclared var js-template(special-symbol? js-template) is returning false which surprises me(:require [shadow.cljs.modern :refer (js-template)])(js-template ttag/t "hello") and similarly with just a base test: (js-template "hello"): cannot read property call of undefined(js-template "hello ${\"there\"}") and it emitted t'hello \$"there"' which was almost workable. not sure how to handle this. off the cuff might be (js-template "hello " x) might emit t'hello ${x}'but i doubt that might be worth the trouble and sounds like a super uphill battle going into cljsstr but emit a template string(js-template "hello " x) will emit exactly
`hello ${x}` (js-template "hello ${\"there\"}") is therefore pointless and will be escaped 😛(js-template "hello " (any-cljs "expr")) is totally valid, if it was using ${} then you'd run into all sorts of annoying quoting issues"your {x} works perfectly" and will expect the translated phrase to be "your {placeholder} works perfectly" and i can't recreate that in this guise(js-template "your " x " works pefectly") would emit the "works pefectly" as part of the substitution rather than the base phrase() which I can't do anything about unfortunately`your ${x} works perfectly` `your ${(x)} works perfectly` x resolves to in this case. could also by some.other.ns.x(let [x "soundcard"] (js-template "your " x " works pefectly"))
var x_46339 = "soundcard";
(metabase.shared.util.i18n.js_template.cljs$core$IFn$_invoke$arity$3 ? metabase.shared.util.i18n.js_template.cljs$core$IFn$_invoke$arity$3("your ",x_46339," works pefectly") : metabase.shared.util.i18n.js_template.call(null,"your ",x_46339," works pefectly"));var x_48110 = "soundcard";
`your ${x_48110} works pefectly`;js*lein new re-frame my-app template had a major new release today. It now creates a pure shadow-cljs build using shadow-cljs.edn and package.json as the source of configuration. Appreciate any testing, feedback, issues or PRs from the shadow-cljs community to improve it further.
https://github.com/day8/re-frame-templatenpm-run-all and cross-env like this setup does https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/package.json#L2-L10cross-env to make things work in windows, since it doesn't support the FOO=thing env vars otherwisenpm-run-all contains the run-p and run-s utils to run things in parallel or sequentially:devtools :http-root and :http-port. they have been deprecated for years and :dev-http should be used instead https://shadow-cljs.github.io/docs/UsersGuide.html#dev-httpnpm-run-all / cross-env, that will be very helpful.:devtools usage now.:dev-http {8280 {:root "resources/public" :handler foo.bar}} would be the handler variantdevtools, uses dev-http.:build-hooks actually work? I can't remember 😛:build-defaults {:build-hooks ...} should but otherwise no right?build-defaults and the version is set correctly.yarn upgrade-interactive --exactshadow-cljs server or shadow-cljs watch running you can find the nrepl port via the .shadow-cljs/nrepl.port filemapbox-gl ^2.2.0 as a dependency in package.json
• I have a :main build that targets :browser with an entrypoint like (ns mapbox-test.main :require [mapbox-gl])
• compilation (`npx shadow-cljs build main`) fails like this:
Closure compilation failed with 2 errors --- node_modules/mapbox-gl/dist/mapbox-gl.js:33 This code cannot be converted from ES6. class expression that cannot be extracted --- node_modules/mapbox-gl/dist/mapbox-gl.js:37 This code cannot be converted from ES6. class expression that cannot be extracted• if I instead do
npx shadow-cljs browser-repl then (require 'mapbox-gl), I see no errors.
I guess I’m confused about (among other things) what the difference is between these two ways of requiring something.:compiler-options {:output-feature-set :es6} or higher (`:es7, :es8, :es2019, :es2020`) in your build config. browser-repl defaults to :es-next-in (the most modern stuff):es5 and you are using code that cannot be converted lower:es8 is a good default nowadays unless you need to support IE11(ns foo.core (:require [bar_baz :as baz])) ;; typo, "_" instead of "-"
10:47:01.189 [XNIO-1 I/O-1] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1The are printed every couple of seconds. Seemingly when ping/pong messages are exchanged over the websocket between shadow and my site in a browser session. Is there any way to hide these? They started showing up recently and I'm unsure what I did to trigger these to appear.
cider-jack-in-cljs. Maybe I will have different results if I start shadow in a terminal and connect to that through cidershadow-cljs watch app and connected manually with cider. I still see the messages, both in my terminal and my connected cider repl.
We do have a logback.xml in this project. I will try to exclude these logs somehow. Do you happen to know what the logger name would be for these messages?<logger name="io.undertow.websockets.core.request" level="WARN" /> firstname="io.undertow" since you likely don't care about any of the messages it outputs. not just that ns.config/logback.xml . I believe one of my dependencies also had some logback stuff defined in it, and that is what my repl was picking up.
I added "config" to my :source-paths in shadow-cljs.edn and added this line to my logback.xml file
<logger name="io.undertow" level="OFF" />Without modifying my source paths my logback wasn't picked up. Now that it is, my repl is cleared up.
config/logback.xml . I believe one of my dependencies also had some logback stuff defined in it, and that is what my repl was picking up.
I added "config" to my :source-paths in shadow-cljs.edn and added this line to my logback.xml file
<logger name="io.undertow" level="OFF" />Without modifying my source paths my logback wasn't picked up. Now that it is, my repl is cleared up.
(into [] $o) though, so not a huge deal. Awesome tool!(extend-protocol p/Datafiable
reagent.ratom/RAtom
(datafy [r]
(with-meta [(deref r)] (meta r))))p being (:require [clojure.core.protocols :as p]):preloads:git-inject {:version-pattern #"^v\/(.*)$"
:ignore-dirty? false}/?
you probably meant to do \\ to escape a \ so you match \/ in the final regex (or you just want to remove the \ so you match a single /, if that's what you want)\\shadow-git-inject has been fixed. We have also moved re-frame-template to use this update. Thanks for report.js/require ?ReferenceError: require is not defined
(defonce electron (js/require "electron"))
^:const (e.g. in (def ^:const my-var 3000)) still justified when using shadow-cljs?^:const is probably the most misunderstood feature in CLJ(S) so I would avoid it. but you can use it if you must.;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:dev-http
{8020 "public"}
:builds
{:app
{:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main ; becomes public/js/main.js
{:init-fn starter.browser/init}}}}}
:socket-repl false so it skips trying to start that;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:socket-repl false
:dev-http
{8020 "public"}
:builds
{:app
{:target :browser
:output-dir "public/js"
:asset-path "/js"
0.0.0.0 by default which should be localhost. I do not know why it would fail. nobody else has reported this before.127.0.0.1 for the socket-repl. maybe you only have ipv6 configured? no ipv4 at all?localhost. is that maybe not configured for some reason?ping localhost in the terminal/etc/hosts?$ cat /etc/hosts ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost
npm install <package> --save-dev?ns :require forms control what the build will actually use for all optimization levels:preloads. they are not included in the release buildsdeps.edn or a project.clj to setup things for Clojure in Cursivedeps.edn or leiningen project.clj for defining dependencies instead of shadow-cljs.ednpom.xml works fine, you do NOT need to use deps.edn or project.clj for Cursive. Regardless of what you use though Cursive does not support JS dependencies as of nownpm install shadow-cljs or clojurescript itself?.shadow-cljs/nrepl.port in the project~/.shadow-cljs/config.edn then no since that would start to conflict as soon as you run more than one shadow-cljs instance at the same timelein and don't want it to get confused. Otherwise the other option also works yes.goog.isDefAndNotNull function. However, I got an error like this:
Execution error (TypeError) at (<cljs repl>:1). goog.isDefAndNotNull is not a functionthere is any additional config I need to setup to make this work on shadow-cljs side?
bide will need to change that.* functions over the past few years. we were stuck with a quite old closure-library version for a while due to those incompatibilities even in cljs.core. the new CLJS release (announcement still upcoming) fixed those but a lot of libraries still need adjustments for the newer version as wellThe required namespace "data-request.core" is not available.
I've slimed down my src/cljs/data_request/core.cljs to this:
(ns data-request.core) (defn ^:export initialize [x] (prn x))And my
shadow-cljs.edn looks like this:
{:source-paths ["src/cljs/data_request"]
:dependencies []
:builds {:data-request {:target :browser
:modules {:main {:entries [data-request.core]}}
:output-dir "../output/dev/"
:asset-path "/cljs/output/dev/data-request_target"}}}
But still:
# yarn shadow-cljs watch data-request yarn run v1.22.10 $ /webapp/cljs/admin/node_modules/.bin/shadow-cljs watch data-request shadow-cljs - config: /webapp/cljs/admin/shadow-cljs.edn shadow-cljs - updating dependencies shadow-cljs - dependencies updated shadow-cljs - server version: 2.12.1 running at shadow-cljs - nREPL server started on port 7890 shadow-cljs - watching build :data-request [:data-request] Configuring build. [:data-request] Compiling ... [:data-request] Build failure: The required namespace "data-request.core" is not available.
data-request.core would be expected to be at <classpath-root>/data_request/core.cljs. Since your classpath root is src/cljs/data_request, it will be looking for src/cljs/data_request/data_request/core.cljs and not finding it:asset-path also looks incorrect. that should be the path under which you access the files over HTTP, that likely isn't :port/cljs/output/dev/data-request_target/main.js?:nrepl {:port ...} if you can. most editors nowadays support reading that port rom the generated .shadow-cljs/nrepl.port file instead:test
{:dependencies [[binaryage/devtools "1.0.2"]]
:source-paths ["env/test" "test/src"]}
shadow-clj.edn
:lein {:profile "+dev,+test"}
…
:builds
{:dev {...}
:test
{:target :node-test
:output-to "test/target/testable.js"
:ns-regexp "myapp\\..*"
:autorun true}}
And here’s the problem:
$ npx shadow-cljs watch test
…
[:test] Compiling ...
[:test] Build failure:
Resource does not have expected namespace
{:tag :shadow.build.resolve/unexpected-ns, :resource "src/myapp/runner.cljs", :expected-ns src.myapp.runner, :actual-ns myapp.runner}
Any ideas why it doesn’t accept the namespaces? It hasn’t been a problem with our previous test runner.
A potentially relevant side note is that Cursive also complains in these files that the namespace is missing a src. (for example in (ns myapp.test.db ...) ) but it seems to me this shouldn’t be needed.:source-paths you have configured in project.clj? you do not need a "runner" for the tests, that is generated for you by the :node-test target.["env/test" "test/src"] - some environment configuration variables, and then all the test files. File hierarchy is e.g. test/src/myapp/test/db.cljs
You’re right, the runner file remained from old solution. After removing it, same problem remains but for other files (e.g :expected-ns src.myapp.test.api.transform, :actual-ns myapp.test.api.transform)"test" on the classpath, which is the default when using lein via :test-paths ["test"]. You need to override that so the classpath doesn't contain duplicated entries.2.11.18 right now.
Looks like we didn’t have a :test-paths set in project.clj at all, so I tried setting it to ["test/src"] which seems to have solved the namespace issue! Now I get another error instead but it seems related to our own code.shadow-cljs clj-repl) you can call (def build-state (shadow/compile! :the-build))(tap> build-state) and look at entire state in the shadow-cljs UI:compiler-env key and that has :cljs.analyzer/namespacesrelease! but just noticed that has a bad return value(shadow/release* (shadow/get-build-config :the-build) {}) should be okdeps.cljs seems like something you should absolutely not do. shadow-cljs will also never compile typescript for you so they'll like remain unused.ReferenceError: window is not defined errors; it looks like it’s happening when this line runs, https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/js.js#L82, as a result of my “shared” module calling SHADOW_ENV.evalLoad("cljsjs.jquery.js", …) because of another library’s jQuery dependency (namely castra.core’s). Has anyone else solved this problem in a project?window at the top of the web worker’s compiled JS by adding var window = goog.global;, that problem goes away – but then I start to get a document is not defined error that seems to ultimately be caused by shadow.dom.js.window:module you are using as a web-worker via :web-worker true?:shared, I inserted another module between :shared and those modules with jQuery dependencies. No more window-related errors. Thank you!SyntaxError: […]/node_modules/@zip.js/zip.js/lib/core/codecs/codec-pool-worker.js: Support for the experimental syntax 'importMeta' isn't currently enabled (82:72):
80 | let messageTask;
81 | if (!workerData.interface) {
> 82 | workerData.worker = new Worker(new URL(workerData.scripts[0], import.meta.url));
| ^
83 | workerData.worker.addEventListener(MESSAGE_EVENT_TYPE, onMessage, false);
84 | workerData.interface = {
85 | append(data) {
Add @babel/plugin-syntax-import-meta () to the 'plugins' section of your Babel config to enable parsing.
I found https://github.com/thheller/shadow-cljs/issues/190 but I wasn’t sure how to proceed. One comment in there suggested that .babelrc could somehow be used, but I’m not sure if that’s applicable here.(:require ["@zip.js/zip.js/dist/zip-no-worker.min.js" :as zip]) maybe that works for you$ syntax has been in shadow-cljs for a long time too. it is a useful addition so use it when it make sense for you.compile works fine
• watch throws piggieback-related exceptions
• Both work completely fine if I revert to version "2.11.23" (happens to be the version I use on another project).["clipboard" :as clipboard]instead of cljsjs.clipboard. But how do I update this line?
(new js/Clipboard (rdom/dom-node button))
js/GlobalThingy references and just use it like any regular CLJS namespace(new clipboard (rdom/dom-node button)). just using the :as clipboard directlyIllegalStateException: Externs must contain builtin for env BROWSER: whatwg_console.js is caused by? I'm trying to migrate everything to the newest cljs and shadow-cljs.:local/root. So it's interesting that if I just use the old thing it's fine.closure-compiler-externs artifact I think. maybe you just excluded that by accidentexterns.zip on the classpath? 😛shadow-cljs clj-repl ( "externs.zip") should give a clue"jar:file:/Users/taronish/.m2/repository/com/google/javascript/closure-compiler-externs/v20180805/closure-compiler-externs-v20180805.jar!/externs.zip"
#object[java.net.URL 0x1a418fc7 "jar:file:/C:/Users/thheller/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20210302/closure-compiler-unshaded-v20210302.jar!/externs.zip"]
closure-compiler-unshaded and the separate closure-compiler-externs don't exist anymore?clj -Stree should tell you what is adding it:exclusions% shadow-cljs node-repl
shadow-cljs - config: /Users/dottedmag/w/hz/shadow-cljs.edn
shadow-cljs - server version: 2.12.1 running at
shadow-cljs - nREPL server started on port 52529
cljs.user=> shadow-cljs - #4 ready!
(throw "x")
^C
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
cljs.user=> Failed to read: clojure.lang.ExceptionInfo: Input/output error {:type :reader-exception, :line 2, :column 1, :file "dummy.cljs"}^C(throw (ex-info "foo" {})) works as expected. must have something to do with throwing a string. I'll investigate.jar as a project file:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}:autorun true no. otherwise yes. see node out/node-tests.js --helpMultiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "re_frame/interop.cljs"] still waiting for #{reagent.core}
{:aborted [:shadow.build.classpath/resource "re_frame/interop.cljs"], :pending #{reagent.core}}
Oddly, 2.12.1 works.:browser build?{:some-alias
{:extra-deps {
thheller/shadow-cljs {:mvn/version "2.11.23"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"
"--config-merge" {:some "thing"}]}}
Running this alias gives me this error:
Error while parsing option "--config-merge {:some": java.lang.RuntimeException: EOF while reading
I did try to change the format of the map to be wrapped in a string, put it inside the string containing --config-merge, and wrapping it with both single and double quotes. Ideas?{}, it seems to work.["-m" "shadow.cljs.devtools.cli"
"server"
"--config-merge" []]
seems to be valid syntax and gives this message
--config-merge expects an EDN map argument
{:v []}:node-test, actually.Uncaught Error: Minified React error #321; visit for the full message or use the non-minified dev environment for full errors and additional helpful warnings. Could this be caused by the fact that Material UI components use React Hooks, which are disallowed in React class components?
While debugging this, I set up a minimal test project to investigate the issue: https://github.com/tvirolai/mui-cljs-test. Here, Component1 renders while Component2 (with a Material UI icon) fails with the error. Any idea how to get around the issue? I asked around in the #clojurescript channel a couple of weeks ago, but couldn't find a workaround...:target :npm-module is broken in at least 2.12.3:
IllegalArgumentException: No matching field found: stripTypePrefixes for class com.google.javascript.jscomp.CompilerOptions
require
import { App } from '@inertiajs/inertia-react'
import React from 'react'
import { render } from 'react-dom'
const el = document.getElementById('app')
render(
<App
initialPage={JSON.parse(el.dataset.page)}
resolveComponent={name => require(`./Pages/${name}`).default}
/>,
el
)
Is this possible with ClojureScript/Shadow-CLJS in the browser?
With goog/require or something like that?Uncaught ReferenceError: require is not defined
(ns myreagent.core
(:require
["@inertiajs/inertia-react" :refer [App]]
[reagent.dom :as d]))
(def el (.getElementById js/document "app"))
(defn home-page []
[:> App {:initial-page (.parse js/JSON (.. el -dataset -page))
:resolve-component (fn [name] (.-default (js/require (str "./Pages/" name))))}])
(defn mount-root []
(d/render [home-page] el))
(defn ^:export init! []
(mount-root))require like that is not supported, but you can probably replace it with either just a normal reference or something using shadow.loader(defn Home [{:keys [name]}]
[:h1 (str "Hello " name "!")])
(defn home-page []
[:> App {:initial-page (.parse js/JSON (.. el -dataset -page))
:resolve-component (fn [name] (r/reactify-component Home))}])107 | (let [an (rum/react *active-notes)] 108 | [:div 109 | [:div [:code (pr-str an)]] ---------------------------------^---------------------------------------------- Use of undeclared Var starter.browser/an --------------------------------------------------------------------------------also saw this with another thing where a function argument was regarded as undeclared
data-page attribute object.(case name "foo" ComponentA "bar" ComponentB ...)rum I'm guessing that would be related to https://github.com/tonsky/rum/issues/233:target :intertia that automates all of that and emits the code optimal for intertia:browser (or whatever you are using) build to match what intertia wantsyarn remove) does not seem to help. I've also tried restarting shadow-cljs and removing all build files.
The import that fails is [react-syntax-highlighter :refer [Prism]], the error is, the line that fails in the generated code is Object.defineProperty(exports,"Prism",{enumerable:!0,get:function(){return _prism.default}}), and the error (that happens in the browser – everything compiles without error) is:
TypeError: Cannot read property 'default' of undefined
at Object.get [as Prism] (<url-for-cljs-runtime-dir>/module$node_modules$react_syntax_highlighter$dist$cjs$index.js:2:442)
Any idea what could be going on here? How can I debug this further?cljs-runtime/module$node_modules$react_syntax_highlighter$dist$cjs$prism.js.map
contains
var _prism = _interopRequireDefault(require(\"./styles/prism/prism\"));
, but there's no corresponding var _prism line in
cljs-runtime/module$node_modules$react_syntax_highlighter$dist$cjs$prism.jsprism.js:
shadow$provide.module$node_modules$react_syntax_highlighter$dist$cjs$prism=function(global,require,module,exports){var _interopRequireDefault=require("module$node_modules$$babel$runtime$helpers$interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0});exports.default=void 0;global=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$highlight"));module=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$styles$prism$prism"));
var _refractor=_interopRequireDefault(require("module$node_modules$refractor$index"));require=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$languages$prism$supported_languages"));global=(0,global.default)(_refractor.default,module.default);global.supportedLanguages=require.default;exports.default=global}prism.js.map:
{
"version":3,
"file":"module$node_modules$react_syntax_highlighter$dist$cjs$prism.js",
"lineCount":2,
"mappings":"AAAAA,cAAA,CAAe,2DAAf,CAAgF,QAAQ,CAACC,MAAD,CAAQC,OAAR,CAAgBC,MAAhB,CAAuBC,OAAvB,CAAgC,CAGxH,IAAIC,uBAAyBH,OAAA,CAAQ,kEAAR,CAE7BI,OAAA,CAAOC,cAAP,CAAsBH,OAAtB,CAA+B,YAA/B,CAA6C,CAC3CI,MAAO,CAAA,CADoC,CAA7C,CAGAJ,QAAA,CAAQK,OAAR,CAAkB,IAAK,EAEnBC,OAAAA,CAAaL,sBAAA,CAAuBH,OAAA,CAAQ,iEAAR,CAAvB,CAEbS,OAAAA,CAASN,sBAAA,CAAuBH,OAAA,CAAQ,0EAAR,CAAvB,CAEb;IAAIU,WAAaP,sBAAA,CAAuBH,OAAA,CAAQ,qCAAR,CAAvB,CAEbW,QAAAA,CAAsBR,sBAAA,CAAuBH,OAAA,CAAQ,2FAAR,CAAvB,CAEtBY,OAAAA,CAAc,CAAC,CAAA,CAAGJ,MAAH,CAAcD,OAAf,EAAwBG,UAAxB,CAAmCH,OAAnC,CAA4CE,MAA5C,CAAmDF,OAAnD,CAClBK,OAAA,CAAYC,kBAAZ,CAAiCF,OAAjC,CAAqDJ,OAErDL,QAAA,CAAQK,OAAR,CADeK,MApByG;",
"sources":["node_modules/react-syntax-highlighter/dist/cjs/prism.js"],
"sourcesContent":["shadow$provide[\"module$node_modules$react_syntax_highlighter$dist$cjs$prism\"] = function(global,require,module,exports) {\n\"use strict\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _highlight = _interopRequireDefault(require(\"./highlight\"));\n\nvar _prism = _interopRequireDefault(require(\"./styles/prism/prism\"));\n\nvar _refractor = _interopRequireDefault(require(\"refractor\"));\n\nvar _supportedLanguages = _interopRequireDefault(require(\"./languages/prism/supported-languages\"));\n\nvar highlighter = (0, _highlight.default)(_refractor.default, _prism.default);\nhighlighter.supportedLanguages = _supportedLanguages.default;\nvar _default = highlighter;\nexports.default = _default;\n};"],
"names":["shadow$provide","global","require","module","exports","_interopRequireDefault","Object","defineProperty","value","default","_highlight","_prism","_refractor","_supportedLanguages","highlighter","supportedLanguages"]
}prism.js. Could this be a bug, or is there something I should be doing to make sure that these lines get included?TypeError: $jscomp.inherits is not a function
dynamic-import be useful?
https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/esm.cljs#L15functions/index.js file. Unfortunately this requires duplicating my dependencies since firebase expects a functions/package.json file listing all deps and I also have to include those deps in the root package.json for shadow.
Is there any way around this duplication. I don't see any support in shadow for specifying a different package.json for a particular build. Maybe there is another solution I'm missing?:js-options {:js-packages-dirs ["functions/node_nodules"]} then it'll take the packages installed there instead of the default <project>/node_modulescider-connect-cljs on a shadow-cljs project. I'm not sure this is the right channel to post my question, but I'm in the hope that someone else here would have faced the same issue before and will point me in the right direction or just say the right channel :)
I noticed that when I connect Emacs to a running nrepl using cider-connect-cljs, my REPL doesn't work the same way as it does when I use cider-jack-in-cljs for instance. To be honest, I don't know if cider-connect-cljs and cider-jack-in-cljs have different user experiences but I assume they don't.
I have recorded a video to try to explain the problem a bit better. What you can see is:
- Run shadow-cljs watch to have the app and a REPL running
- Use cider-connect-cljs to connect Emacs on the running REPL
- Try to set the current namespace using cider-repl-set-ns
- Try to eval a fn using cider-eval-last-sexp
The project you see on the video is here https://github.com/wcalderipe/cljs-playground (there's nothing special).
Versions:
macOS Big Sur 11.2.2
Emacs 27.1
Cider latest commit on master (I'm using straight.el)cider-repl-set-ns executes (in-ns 'whatever) then that will not work unless the NS is already compiled and loaded(require 'whatever) first(in-ns 'foo) under the hood. btw, in-ns works if I just type it on the REPL(shadow/nrepl-select <the-build>). But since cider-nrepl is not on the classpath it never realizes that the clj repl has been switched to cljs and is stuck in a pending state (or what it thinks is a pending state)goog.isBoolean not being defined.
This is right now only happening in my karma build.
And only in the cljs-oops library: https://github.com/binaryage/cljs-oops
It is getting called by the oops function (in js terms) Object.oops$core$validate_object_access_dynamically
I took a look at the generated output javascript file and I see that stuff like goog.isObject gets assigned and even goog.isDateLike which I don’t think I am directly touching in this project.
But there is no similar assign to goog.isBoolean in the output file so it looks like it got pruned.
My karma build parameters are:
{:target :karma
:output-to "target/test-ci.js"
:compiler-options {:devcards true
:infer-externs true
:output-feature-set :es-next
:warnings {:redef-in-file false :infer-warning false}
:pretty-print true
:pseudo-names true}}
Noteworthy & Breaking Changesoops got updated:target your.own-target(defn process [build-state] build-state)process bit is there?:browser is by far the most complicated target but karma pretty straightforward[:app] Build failure: The required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated Warning: Nashorn engine is planned to be removed from a future JDK release NPM dependency "@js-joda/core" has installed version "1.12.0" "3.2.0" was required by jar:file:/Users/den/.m2/repository/cljs/java-time/cljs.java-time/0.1.18/cljs.java-time-0.1.18.jar!/deps.cljs shadow-cljs - HTTP server available at shadow-cljs - server version: 2.11.18 running at shadow-cljs - nREPL server started on port 8877 shadow-cljs - watching build :app [:app] Configuring build. -> build target: :browser stage: :configure <- build target: :browser stage: :configure (4 ms) [:app] Compiling ... -> Resolving Module: :main [:app] Build failure: The required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".
✨ Done in 0.35s. ➜ z1 git:(simple) ✗ yarn global add shadow-cljs yarn global v1.22.5 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Installed "
shadow-cljs - server version: 2.11.18 you are notThe required JS dependency "@material-ui/core/SnackBar" is not available, it was required by "athens/views.cljs".when building on Linux but not Mac
core components like
["@material-ui/core/ExpansionPanel" :as ExpansionPanel]
["@material-ui/core/ExpansionPanelDetails" :as ExpansionPanelDetails]
["@material-ui/core/ExpansionPanelSummary" :as ExpansionPanelSummary]
["@material-ui/core/Slider" :as Slider]
["@material-ui/core/Switch" :as Switch]SnackBar instead of Snackbar. interesting that this works on Mac but not Linux though!:dev-http is meant as a STATIC webserver and using a custom handler is not recommended:preloads per module yes. just {:modules {:main {:init-fn :preloads [foo.bar]}}}:dev but they aren't being included now:
{:modules {:main { :dev
;; moving to here:
{:preloads [...]} }
:worker{}}
:devtools {:after-load app.client.client-entry/refresh
:http-port 8044
:http-resource-root "public"
:http-root "resources/public"
;; moving from here
:preloads [com.fulcrologic.fulcro.inspect.preload
app.client.development-preload
com.fulcrologic.fulcro.inspect.dom-picker-preload]}}:preloads are ALWAYS developmen only and do not apply to release buildsbackground and devtool but not content-script. Though I have not been able to get any working. Wondering what the current state of this is and whether it is worth investing any more time in trying to get it working. Seems that there is a lot of nrepl and sourcemap related issues..[:mobile] Build completed. (203 files, 91 compiled, 0 warnings, 13.29s)
Exception in thread "async-dispatch-2" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
at clojure.core.async.impl.protocols$eval1077$fn__1078$G__1066__1083.invoke(protocols.clj:21)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:979)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async$ioc_alts_BANG_$fn__3907.invoke(async.clj:384)
at clojure.core.async$do_alts$fn__3839$fn__3842.invoke(async.clj:253)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__1491.invoke(channels.clj:265)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)shadow-cljs.edn and the manifest.edn @thheller. Currently I get a tonne of few websocket errors that are thrown in the console and a bunch of sourcemap errors.
https://github.com/homebaseio/datalog-console/blob/extension/shadow-cljs.edn
https://github.com/homebaseio/datalog-console/blob/extension/shells/chrome/manifest.ednfulcro-inspect so that it is easier to reference across the two and see differences.devtools-url removes the ws errors that are thrown. But this makes it different to what is happening in fulcro-inspect. Which has 9632 in the devtools-url and then 9630 in the CSP rules.Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.DevTools failed to load source map: Could not load content for : HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME:devtools-url at all if you want to avoid that headache:source-map-inline true in :compiler-options:source-map-inline true worked for chrome-extension target but doesn't seem to be working for chrome target https://github.com/homebaseio/datalog-console/blob/extension/shadow-cljs.edn#L21. Though perhaps I have something else configured wrong here?
I also seem to be able to connect to the background runtime with the repl when I set my devtools-url to 9630.
When the devtools-url is set to 9632 I get WebSocket connection to '' failed: followed by shadow-cljs - remote-error several times before it gives up trying to connect.fulcro-inspect:chrome-extension target not supporting it properly or something:browser target for the panel UI that is still throwing the source map error.:output-feature-set :es5 setting with shadow-cljs.
When my compiled javascript is loaded I get an error that says
Uncaught TypeError: $jscomp.arrayFromIterable is not a function
memoizedFn memoize.js:60
setEnabled history.js:503
<anonymous> events.cljs:458
re_frame$fx$do_fx_after fx.cljc:59
... blah blah ...
<anonymous> babel-polyfill.min.js:1
m babel-polyfill.min.js:1
b babel-polyfill.min.js:1
Using the browser console, I can see that the $jscomp object is defined, but the function arrayFromIterable is not defined on it. Other functions are.
I was able to fix this by defining the function in a :prepend statement for my module.
:prepend "$jscomp.arrayFromIterable = function(a) {return a instanceof Array ? a : $jscomp.arrayFromIterator($jscomp.makeIterator(a));};"
It fixed my problem. My javascript loads but it feels dirty. Is there another way to solve this?$jscomp I havent been able to track down yet.shadow/builds/<build-id>:es6 but I can't do that because of internet explorer 😞myPreloads.js to the beginning of the test/target/testable.js file (which obviously isn’t a good idea).(ns preloads (:require ["./myPreloads.js"]))and the js file I want to run, which requires its own modules myPreloads.js
...
require("module-alias/register");
...
I get the following error when trying to run the tests:
SHADOW import error /app/.shadow-cljs/builds/test/dev/out/cljs-runtime/myPreloads.js
/app/test/target/testable.js:67
throw e;
^
Module not provided: shadow.js.shim.module$module_alias$register
Looking at the generated testfile testable.js, this is where it does the import.
SHADOW_IMPORT("shadow.js.shim.module$module_alias$register.js");
Can’t really figure out how to require these modules so that shadow can find them. Am I missing something here?:test profile in shadow-cljs.edn file
:js-options {:entry-keys ["module" "browser" "main"]}window object got my tests to run in node.myPreloads.js are pretty simple, you could try re-writing them in clojurescript directly in your preloads cljs file. Perhaps shadow-cljs doesn't understand the code in your js file.:js-options determines which build variant to use for the npm package, e.g. CommonJS or ESM. Unfortunately, adding it doesn’t do anything for me. Unfortunately, myPreloads.js is quite extensive so I’m trying to avoid rewriting it in cljs.:node-test I presume?:node-testnode -r ./preloads.js your-test-output.js:autorun run this as well though?:compiler-options {:force-library-injection ["es6/util/arrayfromiterator"]}. the problem is that the polyfill detection logic somewhere makes a mistake and that part gets lost but you can always just tell it which polyfills to include:prepend:force-library-injection ["es6/util/arrayfromiterable"] in my compiler-options and that did not work. arrayfromiterator also didn't change anything but that function is available already.arrayfromiterable needs to be included here: https://github.com/thheller/shadow-cljs/blob/9a4144b65141ecdacc28fefed53fe968035363e5/src/main/shadow/build/closure.clj#L2522:force-library-injection key works for my release build, but not a development build.:closure-defines {app.core/APIKEY #env "APIKEY"} , I don’t understand how to reach it from within the app.core namespace{:api-key #shadow/env "APIKEY"} I get a compile error No reader function for tag shadow/env . And simply referring to it by its name, APIKEY , I get an undeclared var error(goog-define APIKEY "default value") in app.core and then use it like any other clojure def(shadow.cljs.devtools.api/compiler-env :the-build)watch needs to be running for that to workclojure.main/repl that leverages shadow-cljs to evaluate ClojureScript. I'm wondering whether there's any prior art on this sort of thing I ought to be looking at?
I tried quickly hacking something together and came up with this:
;; *out-fn* is bound to a function that prints to the socket output stream
(let [out-fn tutkain.repl.runtime.repl/*out-fn*]
(clojure.main/repl
:read clojure.core.server/repl-read ;; add :repl/quit support
:need-prompt (constantly false) ;; don't want prompt
:prompt (constantly "") ;; don't want prompt
;; eval is code -> value -- cljs-eval is string -> string, so need to pr-str the input form
:eval #((requiring-resolve 'shadow.cljs.devtools.api/cljs-eval) :app (pr-str %) {})
:print (fn [{:keys [results out err ns]}]
(when (seq out) (out-fn {:tag :out :val out}))
(when (seq err) (out-fn {:tag :err :val err}))
(run! #(out-fn {:tag :ret :val % :ns ns}) results))))
This seems to work as far as very basic use goes. Does this seem like a reasonable approach? I know that's not enough to have special things like in-ns work -- need to look into that some more.(shadow.cljs.devtools.api/repl :the-build {:prompt false})(when file
(let [{:keys [results err]} ((requiring-resolve 'shadow.cljs.devtools.api/cljs-eval)
:app
(format "(cljs.core/load-file \"%s\" %s)" file code) {})]
(when err
(out-fn (response-for message {:tag :err :val err}))
(run! #(out-fn (response-for message {:tag :ret :val %})) results))))
And the code is a ClojureScript namespace that uses an auto-qualified keyword like ::db/reset, I get this error:
repl-input.cljs [line 23, col 38] Invalid keyword: ::db/reset.The namespace has a require like this:
[app.client.db :as db]. Are auto-qualified keywords not supported?
This might also be more of a general ClojureScript question, but if I've understood correctly, shadow-cljs implements its own load-file kind of thing.shadow-cljs node-repl or browser-repl and then the actual command{:builds {:main
{:js-options {:babel-preset-config {:ie 11}}
...}}
...}:compiler-options {:output-feature-set :es3}String.includes . The code is for a client and not open source, so I'd have to see if the error is in the application code or one of the libraries we're using.:compiler-options {:force-library-injection #{"es6/string/includes"}} in your build configURLSearchParams is causing a problem.release build? unless you are on version 2.12.5 the :force-library-injection only works for release buildsURLSearchParams, though.URLSearchParams):force-library-injection? It seems like it's a fallback/last resort, but the documentation could definitely note that.:builds . It also looks like the issue is coming from one of the libraries I'm using. I don't think that should make a difference, as it's also ClojureScript that would need to be compiled, though?A and B with shadow-cljs, and load them both into the same browser webpage as compiled JS scripts. I am trying to make A read a CLJS hashmap produced by B.
The transmission of the data is made via JS property js/window.b-data. This part is working.
Now, when A runs (get b-data :foobar) it returns nil. The keyword is not found because :foobar in A is different than :foobar in B.
;; We are in A's runtime. (def b-foobar (first (keys js/window.b-data))) (keyword-identical? :foobar b-foobar) ;; false (identical? (.-fqn k) (.-fqn :ui/alert)) ;; true (keyword? b-foobar) ;; falseThe problem of
(get b-data :foobar) is that b-foobar fails keyword?.
(core/defmacro keyword? [x] (bool-expr `(instance? Keyword ~x)))Maybe
Keyword is a different in A and in B ?
Would there be a way with Shadow-CLJS to make b-data pass the predicate keyword? ?Keyword inside cljs/core.js :
cljs.core.Keyword = (function (ns,name,fqn,_hash){
this.ns = ns;
this.name = name;
this.fqn = fqn;
this._hash = _hash;
this.cljs$lang$protocol_mask$partition0$ = 2153775105;
this.cljs$lang$protocol_mask$partition1$ = 4096;
})
Since both compiled CLJS runtime are using a different function (the same implementation but different "instance"), it makes sense that the instance? fails.re-frame.db/app-db(defn rewrite [x]
(walk/prewalk
(fn [x]
(case (pr-str (type x))
"cljs.core/Symbol" (symbol (.-ns ^js x) (.-name ^js x))
"cljs.core/Keyword" (keyword (.-ns ^js x) (.-name ^js x))
x))
x))const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: './public/js/index.js',
mode: 'development',
output: {
path: __dirname + '/public/js',
filename: "libs.js"
},
devServer: {
stats: 'errors-only',
contentBase: path.resolve(__dirname, '/public/js'),
publicPath: '/'
},
plugins: [
new webpack.ProvidePlugin({
react: 'react',
ReactDOM: 'react-dom',
})
],
module: {
rules: [
]
}
};
Still getting:
app.js:1563 Error: Dependency: react-dom not provided by external JS. Do you maybe need a recompile?
at shadow$bridge (index.js:14)
at eval (shadow.js.shim.module$react_dom.js? [sm]:3)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:497)
at Object.env.evalLoad (app.js:1560)
at app.js:1699
env.evalLoad @ app.js:1563
(anonymous) @ app.js:1699
11:27:52.383
2. Btw: Specifying global require like (:require ["react"]) does not work. It has to be (:require ["react" :as react]). Why?(ns web.globals (:require ["react" :as react] ["react-dom" :as react-dom]))Still I don't understand why it needs this :as 😕
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!
var ALL = {};
ALL["@ant-design/icons"] = require("@ant-design/icons");
ALL["antd/lib/divider"] = require("antd/lib/divider");
ALL["antd/lib/input/Search"] = require("antd/lib/input/Search");
ALL["antd/lib/layout/Sider"] = require("antd/lib/layout/Sider");
ALL["antd/lib/layout/layout"] = require("antd/lib/layout/layout");
ALL["react"] = require("react");
ALL["react-dom"] = require("react-dom");
global.shadow$bridge = function shadow$bridge(name) {
var ret = ALL[name];
if (ret === undefined) {
throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
}
return ret;
};
shadow$bridge.ALL = ALL;
This is without :as:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!
var ALL = {};
ALL["@ant-design/icons"] = require("@ant-design/icons");
ALL["antd/lib/divider"] = require("antd/lib/divider");
ALL["antd/lib/input/Search"] = require("antd/lib/input/Search");
ALL["antd/lib/layout/Sider"] = require("antd/lib/layout/Sider");
ALL["antd/lib/layout/layout"] = require("antd/lib/layout/layout");
global.shadow$bridge = function shadow$bridge(name) {
var ret = ALL[name];
if (ret === undefined) {
throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
}
return ret;
};
shadow$bridge.ALL = ALL;:as. without it is is basically unusable so I don't understand why that is even a question?:as and that could be considered a bug but I'd still like to understand why you don't want the :as? I mean you do intend to use react right?import statements but since the shadow-cljs external index generates require that won't work:refer to emit import instead but that'll have a few compatibility issues so I used require for now(:require ["./core.less"]) will not work since classspath relative imports will always be processed by shadow-cljs directly and only supports JS:require noimport or js/require is not valid:require["antd/lib/divider" :default AntDivider] with just ["antd" :refer (Divider)] or whatever that would be?public/js/index.js. you could write a manual public/js/index-with-styles.js or whatever that just does require("./index.js"); require("./ant.less") etcimport React from "react" which in JS terms is a singular default export[react :as react] so :as**import * as react from "react"require in the first place is compatibility(ns {:external/assets ["./foo.less"]} (:require ...))require is bad IMHOshadow-cljs will only automatically recompile the direct dependents since in theory dependencies further up cannot be directly affected by those interface changes.:dev/always metadata if you want to force recompile a namespace on every change2.12.5. Not sure how to troubleshoot this:
[2021-04-15 12:37:05.387 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1).
...
[2021-04-15 12:44:11.955 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__initnpm fund for details
found 0 vulnerabilities
IllegalArgumentException: no conversion to symbol
clojure.core/symbol (core.clj:596)
clojure.core/symbol (core.clj:589)
shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:70)
shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:65)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:126)
shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:669)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.core/apply (core.clj:660)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:665)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
duck clojure --version
Clojure CLI version 1.10.3.822
duck java --version
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)shadow-cljs run? that expects more arguments? did you mean shadow-cljs server, shadow-cljs watch app or so?Closure compilation failed with 1 errors --- node_modules/lezer-tree/dist/tree.cjs:385 ES6 transpilation of 'declaration with multiple destructuring children not in statement block' is not yet implemented.
:compiler-options {:output-feature-set :es6}"f.git.zc is not a function"
here's the code that's failing (println (<p! (.. octokit -git (updateRef update-args)))) - octokit is pulled from a github npm library.
so this def seems externs related but I'm wondering how i'd resolve this in a nodejs context? do I really need to add externs for each function i want to use from github's library?
interestingly, i have another line prior to the above which seems to run successfully without any extern issues: ref-resp (js->clj (<p! (.. octokit -git (getRef ref-args))))
any idea what might be happening here?octokit is but in theory yesnode_modules/ directory along with the JS script that shadow-cljs outputs, then I get this error when the script is run on github: Error: Cannot find module '@actions/core'
while committing node_modules/ alongside the script seems to work, i always thought doing a release with shadow-cljs would automatically use the closure compiler to inject the relevant JS from those node modules into the outputted script. i feel like there might be a piece of this i'm not following:node-script (which I assume you are using?) does not bundle the dependencies since node will provide them via node_modules:prepend "some-string"(let [^js data (.data author-post)
postRef (.-post data)]
)
gives me Cannot infer target type in expression (. inst_51072 -post)
but if I do this
(defn get-data
[^js o]
(.data o))
(let [data (get-data author-post)
postRef (.-post data)]
)
it works. any ideas why? there's something i'm not understanding, and any advice would extremely appreciated!(aget data "post")works too, but i'm cargo-culting the belief that this is bad
:foreign-lib, telling the cljs-compiler what namespace it :provides. We could then put this bundle in in the dependency jar, and then have access to those same foreign libs in the dependent project. The shadow browser target operates on the node_modules folder. Is there some recommended approach to coordinating these kinds of transitive js dependencies with shadow?:js-provider :external as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-externalnode_modules itself into the jar file, and have shadow access it from the depedent's classpath?:js-provider :external
2. Generate libs.js via webpack
3. Package libs.js in the dependency jar
4. Configure the dependent project with :js-provider :external
5. Include the libs.js along with the depedent's main.js
Have I got the right idea?:provides in the dependent project, but this seemed easier than having package.json track transitive dependencies and then having to manually sync npm installs.:exclusions. I have a bit of a special case, but the right :exclusions did it.shadow-cljs start After long time I’m getting
shadow-cljs - server starting "a lot of dots and" `Cannot contact jenkins_cluster: hudson.remoting.RequestAbortedException: java.nio.channels.ClosedChannelException` error.It could be some policy of our Jenkins which doesn’t allow that but I cannot find any information which I can pass to our DevOps to investigate that. Is the some way to get more details what is going on under the hood of this command? Or maybe there is a way to enable some logs (`-v` and
--debug shows nothing)?shadow-cljs start on Docker image https://github.com/theasp/docker-clojurescript-nodejs locally. You can reproduce it from your project directory using
docker run --rm -v ${PWD}:/home/my-project -w="/home/my-project" theasp/clojurescript-nodejs:latest npx shadow-cljs startstart in a CI environment?shadow-cljs server for that. I am not sure if it is the best choice. I would appreciate a better advice on that if you havelambdaisland.chui.remote to be preloaded. And shadow-cljs server looks ideal. I could try to look for another way to achieve the same. But do you have any idea why it doesn’t work on Docker? Is it expected or can I log the issue in GitHub for that?.shadow-cljs/ dir provide some clues? I'm not capable of debugging docker issues. if server works fine I'd assume start to work as well since the only thing it does is detach to process into the background.shadow-cljs server works inside Docker. I haven’t checked it separatelyshadow-cljs server with local docker I get a project specific error (out of scope for my question). But it seems shadow-cljs start hanging when errors occur, is it possible?start yesshadow-cljs server failed (actually process just ends) during fetching lein private dependencies because of luck of permissions. During shadow-cljs start it just shows dotsstart all logging goes into the log files in .shadow-cljs/server.stdout.log or server.stderr.logstart is hanging when error occurs during start up if you don’t mind.
My root issue on Jenkins was that jks ssl certificate which we use for local environment was not committed and I still not sure is it a good idea to commit it. Is it possible somehow to force shadow-cljs to ignore ssl certificate if it is not found instead of throwing exception?:ssl config from shadow-cljs.edn before actually starting it(require '[ :as io])
(require '[clojure.edn :as edn])
(let [file (io/file "shadow-cljs.edn")]
(-> (slurp file)
(edn/read-string)
(dissoc :ssl)
(as-> config
(spit file (pr-str config)))))clojure installed on the CI system you can just put that into a script file and run it with that:js-provider :external, I have found that it only works with ["react" as react] style requires. Meaning that both the string-style and the alias is required in order for the corresponding js require to be generated. Is this a known issue/by design? This could be very tricky for others to figure out. The string syntax is fine, when documented, but the required alias is more of a pitfall.:target :node-library and I would like to use the fetch api. But (js/fetch ...) fails with fetch is not definded and requiring ["node-fetch"] fails with symbol module$shadow_js_shim_module$node_fetch already provided by [:shadow.build.js-support/require "node.fetch"], conflict with [:shadow.build.js-support/require "node-fetch"]. Any suggestions how to access the fetch function? Thank you.node.fetch and a node-fetch? they clash, stick to one I guess?node.fetch[node.fetch :as nf] errors in the compiler with he required namespace "node.fetch" is not available. Requiring ["node.fetch" :as nf] passes the compiler, but errors at runtime when loading with Error: Cannot find module 'node.fetch'. 😞"node.fetch" come from? if you ONLY have "node-fetch" that should be totally fine but having that as well as "node.fetch" will not work"node.fetch"firebase-admin and firebase-functions. Perhaps it comes from there.:node-library, then shadow-cljs will not process any npm dependencies at all. some CLJS code must be requiring thatnode-fetch AND node.fetch both munge into the module$shadow_js_shim_module$node_fetch pseudo-namespace and they need to be uniqueshadow.js.shim.module$node_fetch. might be something weird in your setup, can't sayjs/performance for :target :node-test ?(:require ["perf_hooks" :refer (performance)]) or sojs/performance works(require '["@date-io/date-fns" :as DateFnsUtils]) => nil DateFnsUtils => nil
node and the var x = require("@date-io/date-fns") x just to see what that would be> var x = require("@date-io/date-fns")
undefined
> x
[Function: DateFnsUtils]> (require '["@date-io/date-fns" :as DateFnsUtils]) nil cljs.user=> DateFnsUtils #object[Function] cljs.user=>
"@date-io/date-fns": "^2.10.8",
"date-fns": "^2.21.1",server {
listen 127.0.0.1:80;
include /home/dev/src/locations.conf;
}
THis is what I have in my nginx config.location /client/ {
alias /home/dev/src/client/resources/public/;
}
So going to 127.0.0.1/client/ will load up everything. Shadow-cljs is stuck reconnecting and then stops trying. Changing it to localhost makes shadow-cljs connect right away and everythign works. :x:http {:port 9630
:host "127.0.0.1"}
this does not help. Looks like the server is not started at http://127.0.0.1:9630/, at least my browser shows nothing when trying to open that page. So even when specifying the host, the reconnection fails.NAME STATE VERSION * Ubuntu-20.04 Running 2
localhost0.0.0.0:http :host[2021-04-21 10:03:22.948 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (clojure/tools/reader/edn.clj:75:9). #:clojure.error{:phase :compile-syntax-check, :line 75, :column 9, :source "clojure/tools/reader/edn.clj"}
clojure.lang.Compiler.analyze (Compiler.java:6808)
clojure.lang.Compiler.analyze (Compiler.java:6745)
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3820)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7109)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.analyze (Compiler.java:6745)
clojure.lang.Compiler$IfExpr$Parser.parse (Compiler.java:2837)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7107)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.analyze (Compiler.java:6745)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6120)
clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6436)
Caused by:
RuntimeException No such var: err/throw-no-dispatch
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7388)
clojure.lang.Compiler.resolve (Compiler.java:7358)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7319)
clojure.lang.Compiler.analyze (Compiler.java:6768)
clojure.lang.Compiler.analyze (Compiler.java:6745)lein deps :tree shows that shadow-cljs depends on org.clojure/tools.reader "1.1.3.1"throw-no-dispatch existslein repl (with profiles if needed) and ( "clojure/tools/reader/edn.clj")user=> ( "clojure/tools/reader/edn.clj") #object[java.net.URL 0x440076b6 "jar:file:/Users/lilactown/.m2/repository/org/clojure/tools.reader/1.1.3.1/tools.reader-1.1.3.1.jar!/clojure/tools/reader/edn.clj"]
org.clojure/tools.reader 1.3.3lein deps :tree shows the following output:
[thheller/shadow-cljs "2.12.5" :exclusions [[fipp] [edn-query-language/eql] [com.wsscode/pathom]]]
[cider/piggieback "0.5.0" :exclusions [[org.clojure/clojure] [org.clojure/clojurescript] [nrepl]]]
[javax.xml.bind/jaxb-api "2.3.1"]
[javax.activation/javax.activation-api "1.2.0"]
[com.bhauman/cljs-test-display "0.1.1"]
[com.google.javascript/closure-compiler-unshaded "v20210302"]
[expound "0.8.5"]
[hiccup "1.0.5"]
[org.clojure/clojure "1.10.1"]
[org.clojure/core.specs.alpha "0.2.44"]
[org.clojure/spec.alpha "0.2.176"]
[org.clojure/clojurescript "1.10.844" :exclusions [[com.google.javascript/closure-compiler-unshaded] [org.clojure/google-closure-library] [org.clojure/google-closure-library-third-party]]]
[org.clojure/core.async "0.3.465"]
[org.clojure/tools.analyzer.jvm "0.7.2"]
[org.clojure/core.memoize "0.5.9"]
[org.clojure/tools.analyzer "0.6.9"]
[org.ow2.asm/asm-all "4.2"]
[org.clojure/data.json "1.0.0"]
[org.clojure/google-closure-library-third-party "0.0-20201211-3e6c510d"]
[org.clojure/google-closure-library "0.0-20201211-3e6c510d"]
[org.clojure/tools.cli "1.0.194"]
[org.clojure/tools.reader "1.1.3.1"]tools.reader to appear elsewhere in the tree as well if something else depended on it?managed-dependencies or so?:js-options {
:js-provider :shadow
:keep-native-requires true
}:js-provider :shadow is NOT recommend for node builds'Module not provided: mongodb-extjson':external ?:js-provider :require and use ncc I linked@imported from the top-level css file, which is the only one explicitly included in the html?shadow-cljs , it updates package.json and yarn.lock by calling yarn, and then it tells me "specify which action to run". I get what I want because package.json and yarn.lock are updated, but I think I may have not used the intended workflow. :target is :react-native if that's relevantshadow-cljs calls yarn, it complains IOException: Cannot run program "yarn" (in directory "."): error=2, No such file or directory. I work around that by calling shadow-cljs through yarn through npx: npx yarn shadow-cljs. Is that the intended way?
Update: I guess the correct answer to this is don't mix npm/npx and yarn like this. Use npm and package-lock.json and npx, or use yarn by installing it globally and use yarn.lock.yarn.lock it'll attempt to use yarn.nil .
Did it happen to anyone before?:npm-deps {:install false} in your shadow-cljs.edn to disable to automatic install(defmacro def-from-file [var path-to-file f]
`(def ~var
(~f ~(read-string (slurp path-to-file)))))
I've been unable to call the macro with file being the value bound to a closure define.
With the shadow-cljs guide stating that closure defines “are essentially compile time constants” I thought there must be a way to eval them inside macros… is that actually possible? If not, are there other ways to do what I'm looking for here?(defn copy-to-clipboard [val]
(let [c (.-clipboard js/navigator)]
(-> (.writeText c val)
(.then (fn [] (debug "copied to clipboard")))
(.catch (fn [e] (error "clipboard error:" e))))))Uncaught TypeError: navigator.clipboard is undefined
^js hint you only need if things are getting renamed but it doesn't seem to be renamedfunction eNa(a){return navigator.clipboard.writeText(a).then(...js/navigator and see what that is. maybe it is redeclared somewhere locally or soinf-clojure-connect with localhost and the port in .shadow-cljs/socket-repl.port. The repl opens fine.
3. Then, when I try to eval any require, I get errors such as:
Could not locate timeline/test_utils__init.class, timeline/test_utils.clj or timeline/test_utils.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.I’ve tried to have a look at shadow’s manual but I’m not too familiar with cljs and front-end. Am I missing something?
(help). I think there's a small banner indicating this. You get a clojure repl and you can start your repl with (shadow/repl :your-build)
shadow-cljs - REPL - see (help) To quit, type: :repl/quit shadow.user=>
(shadow/browser-repl) or (shadow/node-repl) if you don't have a build configured yet and just want a REPL(help) . Thanks 🙇karma .
What would be a good approach of debugging that? :thinking_face:
I guess I can bisect and run karma, just wondering if there’s a more efficient way:output-dir in the build configbrowserfeaure.js , looks like the const googUserAgent = goog.require('goog.userAgent'); returns nil :S:js-options {:resolve {"jquery" false}}:output-dir and asset-path to different values than they are now. For example:
:builds
{:my-build {:output-dir "dev/public/js" :asset-path "/js" :modules {...}
:devtools {:http-port 8021
:http-resource-root "public"
:http-root "dev/public/"}}:dev-http):main-opts ["-m" "shadow.cljs.devtools.cli" ]
I fount that line here https://shadow-cljs.github.io/docs/UsersGuide.html#deps-ednwatch app in the deps.edn?"watch" "app":main-opts ["-m" "shadow.cljs.devtools.cli" "watch app"]release mode. watch does not affect it"./icons/marker.png
I’ve tried using this but it’s not loading./ in the path it'll be relative to the page you are on. you need to make sure the path is correct.node_modules cache without restarting npx shadow-cljs watch app ? Any option?console.log on npm package for debugging.touch node_modules/that-package/package.json to trigger a recompilenode_modules files because some projects used like 5000 files from there and that was causing some performance issuespackage.json files in cause you npm install stuff or sodefonce my app-db in a re-frame project from a hot-reload perspective?def on my app-db. hot reload seems to work the same.(def app-db (ratom {})) . I just want to understand a bit better how it really works. Even if I realize I should stay away from the subject during the demo. 😃re-frame.db namespace so it is never reloaded and never has this issue(set! js/NODE_ENV (if goog.DEBUG "development" "production") in my entry point? Is there a way to say this in the shadow-cljs.edn?user.i_use_worklet*=*function(){var _f*=*function _f(){*return* console.log("Hey I'm running on the UI thread");};_f._closure*=*{console*:*console};_f.asString*=*"function(){const{console}=this._closure;{return console.log(\"Hey I'm running on the UI thread\");}}";global.__reanimatedWorkletInit(_f);*return* _f;}();
from this
user.i_use_worklet*=*function(){"worklet";*return* console.log("Hey I'm running on the UI thread");};:advanced will likely remove the "worklet;" thing:advanced:advanced or even :simple would be the major hurdle here(set! *warn-on-infer* false) somewhere above those forms if you know they are safe and can be renamed (which they likely can)(defn ^Return foo [] ...) worked but (defn foo ^Return [] ...) didn't(ns my-app.views
(:require ["react-chartjs-2" :refer [Line]]))
(defn chart []
[:> Line
{:data {:labels ["1" "2" "3" "4" "5" "6"]
:datasets [{:label "# of Votes"
:data [12 19 3 5 2 3]
:fill false
:backgroundColor "rgb(255, 99, 132)"
:borderColor "rgba(255, 99, 132, 0.2)"}]}
:options {:scales {:yAxes [{:ticks {:beginAtZero true}}]}}}])
But I get this error:
error when calling lifecycle function my-app.core/mount-root Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `my-app.views.chart`.
Line seems to be undefined and I don't know why. Both "chart.js": "^3.1.1" and "react-chartjs-2": "^3.0.2" are in my package.json. I'm quite sure it was working yesterday, but don't know what I've changednouislider-react to the project, but I just removed it and it's still not working. What should I look for in the exports? I'm not too familiar with JS modules and exports, but I found this in node_modules/react-chartjs-2/dist/index.js:
var Line = React.forwardRef(function (props, ref) {
return React__default.createElement(ChartComponent, Object.assign({}, props, {
type: 'line',
ref: ref,
options: props.options || {}
}));
});
react-native run-android ?:exclusions on npm-deps ?
I see the bit about cdn and resolve-global here: https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global which would be handy if I could do the exclusions:js-options {:resolve {"npm-dep" false}} will "ignore" the dependency but fail if you actually attempt to use it in the code:npm-deps {:install false} in the shadow-cljs.edn root will not attempt to install npm-deps from deps.cljs at all, there are no specific exclusions otherwiseprn? I don't use anything else that prints in my own codestr call, but more likely prn or pr-str yes(def x (atom {:x nil})) -> (swap! x assoc :x x) ->
The result object failed to print. It is available via *1 if you want to interact with it. The exception was: RangeError: Maximum call stack size exceeded :repl/print-error!
(def x #js {:x nil})
#'cljs.user/x
cljs.user=> x
#js {:x nil}
cljs.user=> (set! (.-x x) x)
The result object failed to print. It is available via *1 if you want to interact with it.
The exception was:
RangeError: Maximum call stack size exceeded
:repl/print-error!.shadow-cljs/nrepl.port file)(shadow/repl :the-build-id) to switch that connection to CLJS(shadow/node-repl) instead:node-script gives you the file in :output-tonode whatever.jsmain?main fn as the init fn described in the post above)js , out, manifest.json, .shadow-cljs, node_modules etc{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dba9bebab8aff6abbfbd9beef5e9f5eb"}, :content ("[email protected]")} as a dependency:
[2021-04-30 13:37:26.247 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:468)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/pdfjs-dist/build/pdf.js:9211:32 String continuations are not recommended. See -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: node_modules/pdfjs-dist/build/pdf.js:9225:34 String continuations are not recommended. See -------------------------------------------------------------------------------- ------ WARNING #3 - ----------------------------------------------------------- Resource: node_modules/pdfjs-dist/build/pdf.js:9327:34 String continuations are not recommended. See -------------------------------------------------------------------------------- ------ WARNING #4 - ----------------------------------------------------------- Resource: node_modules/pdfjs-dist/build/pdf.js:9344:36 String continuations are not recommended. See --------------------------------------------------------------------------------
shadow.cljs.bootstrap.node. I was checking the post here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for some tips. When I try to eval something I get
[:result {:error #error {:message "Could not eval [test]", :data {:tag :cljs/analysis-error}, :cause #error {:message nil, :data {:clojure.error/source nil, :clojure.error/line 1, :clojure.error/column 1, :clojure.error/phase :compilation}, :cause #error {:message "Cannot read property 'findInternedVar' of null at line 1 ", :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}}}]
Can you see if there is something wrong with my configs or code:require these:
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.node :as shadow.bootstrap]
...
(defn print-result [{:keys [error value] :as result}]
(prn [:result result]))
(def code "(+ 1 2)")
(defonce compile-state-ref (env/default-compiler-env))
(defn compile-it []
(cljs/eval-str
compile-state-ref
code
"[test]"
{:eval cljs/js-eval
:load (partial shadow.bootstrap/load compile-state-ref)}
print-result))
(shadow.bootstrap/init compile-state-ref
{:path "out/extension/bootstrap"}
compile-it)
(compile-it):builds
{:dev {:target :node-library
:output-to "out/extension/extension.js"
:output-dir "out/extension"
:exports-var prode.extension/exports
:devtools {:repl-pprint true}
:compiler-options {:source-map-detail-level :all
:output-wrapper false
:optimizations :simple}}
:bootstrap {:target :bootstrap
:output-dir "out/extension/bootstrap"
:entries [cljs.js]
:macros []
:exclude #{cljs.js}
:compiler-options {:warnings {:infer false}
:optimizations :simple}}}(compile-it) until the above init has completedinit will already call it when its doneshadow.bootstrap/init is going to run the compile-it, where should I see the result (it’s not printed to the REPL)?[2021-05-01 21:53:18.838] [renderer11] [error] transit-load failed: Error: transit-load failed
at new cljs$core$ExceptionInfo (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11455:1)
at Function.cljs$core$IFn$_invoke$arity$3 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
at Function.cljs$core$IFn$_invoke$arity$2 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
at ReadFileContext.callback (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/shadow/cljs/bootstrap/node.cljs:38:9)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:265:13)
at FSReqCallback.callbackTrampoline (internal/async_hooks.js:120:14)/bootstrapout/extension and the output is inside that one out/extension/bootstrap. Did you mean that bootstrap should go actually on the same level as the out folder (project root)?:path "out/extension/bootstrap":path at all? it defaults to this https://github.com/thheller/shadow-cljs/blob/015926609e1c070de57efa71646c46f92f08d7d9/src/main/shadow/cljs/bootstrap/node.cljs#L13path/resolve call:path and it is working 🙂var wasmBinaryFile="data:application/octet-stream;base64,ABCD"; is getting altered. Just for context..wasm file over the ajax or so? inlining it via base64 will make it needlessly large?(:require #?(:cljs ["imgui-js" :as imgui]))touch node_modules/imgui-js/package.json which will then trigger a recompile:js-options {:resolve {"imgui-js" {:target :file, :file "src/cljc/imgui/imgui.js"}}}:resolve if you have stuff on the classpath anyways(:require ["/imgui/imgui.js" :as imgui]) https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]) . And it tries to do require('imgui-js') to get in that same file. Since it looked like I needed that resolve bit to make imgui_demo.js happy i just used that in my cljc file too.:resolve in the shadow cljs settings to keep the other include happy and move to use (:require ["/imgui/imgui.js" :as imgui]) in my cljc file then?:resolve for packages you already control is almost guaranteed to be wrongimgui.js really is the thing that does everything. imgui_demo.js is several thousand lines of js that is recommended to include when developing since it both serves as documentation and a settings tweaker. Again all not really my code, though I can always change things up if necessary in the fork.imgui_demo.js has one of those standard check all sorts of places to figure out how to require imgui.js.// imgui_demo.js top
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('imgui-js')) :
typeof define === 'function' && define.amd ? define(['exports', 'imgui-js'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ImGui_Demo = {}, global.ImGui));
}(this, (function (exports, ImGui) { 'use strict';
... );
require('imgui-js') it seems?(:require
#?(:cljs ["imgui-js" :as imgui])
;;#?(:cljs ["/imgui/imgui.js" :as imgui]) ;; this does not work!
#?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]))
:js-options {:resolve {"imgui-js" {:target :file :file "src/cljc/imgui/imgui.js"}}}(:require
#?(:cljs ["/imgui/imgui.js" :as imgui])
#?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]))shared.js which shadow-cljs is compiling.SHADOW_ENV.evalLoad("module$imgui$imgui.js", true , ......
SHADOW_ENV.evalLoad("module$src$cljc$imgui$imgui.js", true , ......
:resolve. as I said that this is NOT relevant hererequire('imgui-js') is a problem?:resolve bit then shadow cljs is not able to build anything:
X Compilation failed.
The required JS dependency "imgui-js" is not available, it was required by "imgui/imgui_demo.js".
imgui-js from? it is not the file you generate from the wasm right? did you modify that file in any way?require('imgui-js') part is in the helper files like imgui_demo.js that are also a part of that projectsrc/cljc/imgui/imgui.js WHERE is this from? is this also wasm generated code?require('imgui-js') with require('./imgui.js') insteadrequire('imgui-js') is interpreted as "require the imgui-js npm library" but it is not an npm library. avoid resolve to fix this, much better to fix it in the source directly:resolve to :file. I should probably remove that altogether since it is basically never the correct way to do anything:resolve:resolvecider-jack-in-cljs, select shadow-cljs then shadow as the repl type,No available JS runtime. See
node-repl is saving me… before it was failing with an error I can’t find, but I may be in business!! apologies for the flailing, I think I’m good 🙂{:npm-deps {:install true}} which installs non-tooling JS deps in the top-level package.json / node_modules, instead of the one in react-native/, where metro in the end looks for it? One might end up with different versions of the same package in the two node_modules directories.:npm-deps install completely at some point and make it a proper manual command instead{:npm-deps {:install false}} and go with that one right away.
I briefly tried debugging though and it didn't find the CLJS source. I suspect that that has to do with the fact that the CLJS source files are outside of the metro / react native root, but I didn't have time yet to look into that.shadow-cljs release app on my reagent/reframe app. the js folder that is created is 25MB. do I need to manually delete the cljs-runtime folder?cljs-runtime folder is not used by release builds yessrc/ and i get conflicts on compile so i assume it is being added to the cp. unfortunately i don't see changes i've made to the codebase, or see any hot reloads when i change cljs filessrc? replacing shadow-cljs internal namespace should be fine yes?shadow-cljs.edn only (no deps.edn, project.clj) you might need to add :aot false to the top levelsrc/shadow/cljs/ui/components/inspect.cljs and just added a simple prn to ui-tap-panel and it doesn't seem to be overwriting the default inpsect.cljsshadow-cljs.edn with deps.edn and :deps truejs/Object support to inspecttap> on a pure JS object just printed js/Object:js-options
{:source-map false}
would prevent source maps from things inside of node_modules from being outputted?:js-options
{:source-map false}
set.
https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/build/api.clj#L125`default-js-options`https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/build/api.clj#L125(ns xxx (:require ["my-lib/my-thing-1" :default my-thing-1*])) (def my-thing-1 my-thing-1*)for every
my-thing-n, is there a way similar to (:require ["my-lib/my-thing-1" :default my-thing-1* :reexport), so that I can use xxx/my-thing-1 in another ns in the same project?:keep-native-requires for node to work, but :keep-native requires leaves as you'd imagine, the requirement as "require" whereas typescript seems to hate that, throwing this error: WARNING in ../node_modules/datahike/datahike.js 112:12-19 vs-sprot-mm: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted:keep-native-requires has to do with anything? when you are using node anyways you absolutely should not be using :js-provider :shadow?:target :node-library?:node-library would do what you need. if you describe what the problem with that was I can maybe help further:js-options config whatsoeverrelease if you intend to release the actual library to be used in projects. compile or watch will only work on the machine it was compiled on in the directory it was compiled in(def fs node-fs) with (:require ["fs" :as node-fs]) or something like that?js/require so externs inference is "hindered" a little. that is why you are seeing the existsSync (and likely the others) getting renamed(:require ["fs" :as fs]) externs inference would be much smarter and generate the proper externsnode-repl NOTHING is getting renamed since it does not run through :advanced compilationrelease things will get named and minified(:require ["fs" :as fs]) then shadow-cljs will automatically add externs for whereever fs/* is used. with (js/require ...) this is not done. basically since you are never supposed to use that ...^js hint would also fix problems with this but the lib doesn't have itexterns/your-build-id.txt and just one line for existsSync (and maybe more lines for other stuff getting renamed)release and typescript.lein-env file?//JS version
import { Button } from "@chakra-ui/react";
import { ChakraProvider } from "@chakra-ui/react";
class App extends Component {
render() {
return (
<ChakraProvider>
<Button
px="3"
py="2"
bg="green.200"
rounded="md"
_hover={{ bg: "green.300" }}>
Click me
</Button>
<h1>Hello World</h1>
</ChakraProvider>
);
}
}
//cljs version
(ns todo.views
(:require
[re-frame.core :as re-frame]
[todo.events :as events]
["@chakra-ui/react" :refer (ChakraProvider)]
["@chakra-ui/react" :refer (Button)]
[todo.subs :as subs]))
(defn button-panel []
[:div {:id "button-panel"}
[:> Button {:px 10 :py 5 :bg "green.200" :on-click
#(re-frame/dispatch [::events/update-counter 1])} "+"]
[:> Button {:px 10 :py 5 :bg "green.200" :on-click
#(re-frame/dispatch [::events/update-counter -1])} "-"]])
(defn main-panel []
(let [counter (re-frame/subscribe [::subs/counter])]
[:> ChakraProvider
[:div
[:h1 @counter]
(button-panel)]]))
(ns todo.views
(:require
[re-frame.core :as re-frame]
[todo.events :as events]
["@chakra-ui/react" :as cui]
[todo.subs :as subs]))
(defn button-panel []
[:div {:id "button-panel"}
[:> cui/Button {:mr 1 :bg "green.200" :on-click
#(re-frame/dispatch [::events/update-counter 1])} "+"]
[:> cui/Button {:bg "green.200" :on-click
#(re-frame/dispatch [::events/update-counter -1])} "-"]])["@chakra-ui/react" :refer (ChakraProvider Button)] would be ok too"@chakra-ui/react" require twice and the second one replaced the first one instead of adding to itreact-pdf or generally pdfjs working nicely with shadow? feel like I’m mashing a square peg into a round hole, mostly because I’m not super familiar with pdfjs:js-provider :external , is it required to have a node_modules installed before compiling with shadow? I'm getting an error without it:
The required namespace "react" is not available, it was required by "reagent/core.cljs".I'm getting my js bundle via another source (not npm), and wondering if there's still some way to make it work with shadow.
(:require [react ...]) as in a symbolnode_modules(:require ["react" ...]) that check is not necessary since we know that strings are reserved for JS libs:npm-deps from deps.cljs for thatformat it will drag pprint informat . Do you know what namespace that lives in?:debug flag):advanced that simply isn't practical. much better to click one button or run one command when you are actually sure you want to build{:lint-as {reagent.core/with-let clojure.core/let}}
Which lives in project-root/.clj-kondo/config.edn
Everything had been working great with it.shadow-cljs run shadow.cljs.build-report app report.html to be about the same size as the target app.js I wonder? It’s falling short for me and so I’m trying to understand what I’m missing.jar | cljs/core.cljs | 750.5 KB:simple? or pseudo-names?jsonwebtoken. The problem is when I build my lambda for prod the node_modules are not included in the output folder so just uploading the index.js file leads to a runtime error that jsonwebtoken could not be found. I copied node_modules manually and zipped it all up which worked but is tedious.
Is this expected?
I feel like I am doing something wrong and shadow-cljs would take care of that for me.
shadow-cljs.edn:
{:source-paths
["src"]
:dependencies []
:builds
{:wallet-lambda {:target :node-library
:output-to "./dist/wallet_lambda/index.js"
:exports {:handler com.ye-olde-shoppe.wallet.main/handler}
:compiler-options {:infer-externs :auto}}}}
package.json
{
"name": "yos-backend",
"version": "0.0.1",
"private": true,
"devDependencies": {
"shadow-cljs": "2.12.5"
},
"dependencies": {
"jsonwebtoken": "^8.5.1"
},
"scripts": {
"build-wallet": "shadow-cljs release :wallet-lambda",
"assemble-wallet": "npm run build-wallet && cd dist/wallet_lambda && zip ../wallet_lambda.zip *"
}
}:output-to file with something like https://github.com/vercel/nccnpm install --productionnode_modulesyarn install --production I also used https://github.com/ModClean/modclean to get the zipped image with node_modules to less than 30MB.npx shadow-cljs release :lambda-viewer npx shadow-cljs release :lambda-origininto just
npx shadow-cljs release lambda-viewer lambda-origin
ERROR shadow-cljs - remote-error {"isTrusted": false, "message": "CLEARTEXT communication to 10.212.134.68 not permitted by network security policy"}
WARN shadow-cljs: giving up trying to connect to
I think the problem here is that the IP above is not my local IP (192.168.0.184).
When I search for 10.212.134.68 in my project, I found a matching text in target/index.js file
Here is the first 5 lines of code
var $CLJS = global;
var shadow$start = new Date().getTime();
var shadow$provide = global.shadow$provide = {};
var goog = global.goog = {};
global.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.reload_strategy":"optimized","shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":true,"shadow.cljs.devtools.client.env.proc_id":"b2dc811d-cc6d-467e-81bf-e8f4eae2709a","shadow.cljs.devtools.client.env.use_document_protocol":false,"goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9630,"shadow.cljs.devtools.client.env.server_token":"d98f5299-1231-4718-8262-3736140c13f2","shadow.cljs.devtools.client.env.use_document_host":true,"shadow.cljs.devtools.client.env.module_format":"goog","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"app","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"cljs.core._STAR_target_STAR_":"react-native","shadow.cljs.devtools.client.env.log":true,"shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"10.212.134.68","shadow.cljs.devtools.client.env.worker_client_id":2,"goog.TRANSPILE":"never"};
When I change the hardcoded IP in target/index.js file, the websocket connection is working and I'm getting a message
LOG dev init time 839
LOG Running "Limeray" with {"rootTag":201}
LOG date is null
LOG #6 ready!
My question is, is there a way to configure shadow-cljs to use specific IP for websocket? In my case
Previously when I encountered this issue, I was able to configure like below. But now, it does not seem to work
{:deps true
;; local network IP in order for websocket to send repl command over-the-network
:http {:host "192.168.0.184"}
:builds
{:app {:target :react-native
:init-fn limeray.mobile.main/init
:output-dir "target"
:js-options {:js-package-dirs ["node_modules"]}}}}~/.shadow-cljs/config.edn you can configure :local-ip "192.168.0.184" (or in your shadow-cljs.edn local config as well)npx create-cljs-project only generates the very bare bone project skeleton. I don't know what you are going to build. might be a node script, might be a react-native app, might be browser-based app. not all of them require html files.import {getAuth} from "firebase/auth" as ["firebase/auth" :refer [getAuth]], which should import only that function. Instead it seems that everything is being imported, as it was in the previous (non-tree-shakeable) version. Is there anything else I ought to be doing here, or is this a case of Closure compiler not being able to use the same strategy as Rollup/Webpack would?:browser build<script src=":port/script.js"> into the page from the script:asset-path and :devtools-url though(ns main
(:require ["@aws-sdk/client-dynamodb" :refer [DynamoDBClient ListTablesCommand]]))
(DynamoDBClient. #js {:region "eu-west-2"})
The error I am getting is:
shadow.js.shim.module$$aws_sdk$client_dynamodb.DynamoDBClient is not a constructor
I translated this from https://www.npmjs.com/package/@aws-sdk/client-dynamodb
import { DynamoDBClient, BatchExecuteStatementCommand } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({ region: "REGION" });:as to the :require and logging that to see what it is(get-in @env/*compiler* [:options :closure-defines])npx create-cljs-project my-project
does not include any index.html` (or a folder for CSS, as far as I can tell), how should I add it? I mean where? Somewhere in the project folder? If so, then do I need to add any pointer to where it is anywhere? And would I need to manually have it point it at wherever my main output JS file is for a given build (test vs develop vs release)?public/css/foo.css and link it in your html via <link rel="stylesheet" href="/css/foo.css">public foldershadow-clj with a backend server that runs on the JVM? I have looked through the documentation at https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http but cant find a good answer to thiswatch server directlyshadow-cljs.edn is in/, you may use that but that would make it an absolute path outside your project folder/public/js would be c:\public\js on windows or just /public/js in linux/a/b/c does NOT mean ~/a/b/cpublic everywhere. other people prefer resources/public. others use dist, target, web or whatever else may fittest-dir folder: index.html - If and only if there was not already an index.html file present. By default the generated file loads the tests and runs init in the :runner-ns. You may edit or add a custom version that will not be overwritten.
create-cljs-project by intention is minimal and does NOT provide and target specific thingsnpx create-cljs-projectnpx is part of npm which comes with node.shadow-cljs/builds folder manually or otherwise I have a console full of errors on the screenshot below. It sometimes burps on optimized builds also, but if I clean the build folder everything is fine. Is it necessary to clean the build folder before each start? I don't remember doing this for my last project.npx shadow-cljs watch app and then kill it with Ctrl-c once I'm done working.shadow-cljs restart when I want to start, because with wsl I often can't cleanly exit. I run this manually, but an npm script should work. Then I start the web interface to shadow-cljs on 9630 and press watch there.shadow-cljs and have started shadow-cljs watch :app in the terminal, which has run through successfully to Build completed. but I'm having troubling jacking into cljs via cider with the option shadow for repl-type and :app for the cljs build selection:
;; ClojureScript REPL type: shadow ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app)) ;; Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). shadow-cljs has not been started yet! In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it. If you have a shadow-cljs server or watch running then you are not connected to that process.would welcome some advice on how to proceed. This is with
CIDER 1.1.0 (package: 20210422.802) (Plovdiv)cider-connect-sibling-cljs to localhost:9123 followed by shadow-select and :app build then I just see:
:missing-nrepl-middlewareuser>Confused
(eval . (progn
(make-variable-buffer-local 'cider-jack-in-nrepl-middlewares)
(add-to-list 'cider-jack-in-nrepl-middlewares "shadow.cljs.devtools.server.nrepl/middleware")))
in my .dir-locals I just land on the same issue:
;; ClojureScript REPL type: shadow-select ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :app)) ;; Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). shadow-cljs has not been started yet! In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it. If you have a shadow-cljs server or watch running then you are not connected to that process.
cider-connect-cljs to `localhost:9123` followed by `shadow-select` and `:app` however does gives me a REPL, I can (js/alert ...) etc, but working on a cljs file and jumping to REPL still gives cider--no-repls-user-error: No cljs REPLs in current session "Farillio/app:localhost:9123" and #?(:cljs ...) code in cljc files is still grayed out (no syntax highlighting) 😢shadow-cljs watch... in a terminal, add
(cider-default-cljs-repl . shadow)
(cider-shadow-default-options . "app")
to my dir-locals.el and then just cider-jack-in-clj&cljs - should/could it be that simple?cider-nrepl middleware to your dependencies. when you run shadow-cljs watch separately cider cannot inject it automatically so you need to add it manually. don't know how jack-in stuff works these days, but connecting remotely is totally fine and even what I'd recommend doingcider-nrepl dependencies are auto-injected by cider - I'm making some progress with:
(cider-default-cljs-repl . custom)
(cider-custom-cljs-repl-init-form . "(do (user/cljs-repl))")
(eval . (progn
(make-variable-buffer-local 'cider-jack-in-nrepl-middlewares)
(add-to-list 'cider-jack-in-nrepl-middlewares "shadow.cljs.devtools.server.nrepl/middleware")))
and:
;; (defn cljs-repl ([] (cljs-repl :app)) ([build-id] (server/start!) (shadow/watch build-id)in
user.clj I'm seeing the following on cider-jack-in-clj&cljs and I can force (re)compiles with shadow-cljs to debugshadow-cljs watch you started separatelycider-jack-in-clj with clojure-cli to run the backend, then separately cider-jack-in-cljs (no piggy-backing) with shadow-cljsclj|cljs buffers for jump-to-repl purposes - removed all hacks in dir-locals.el and user.clj 🎉component.cljs:127 Error rendering component (in app.hello.hello)
reagent$impl$component$do_render @ component.cljs:127
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
renderRoot @ react-dom.development.js:19436
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 2 more frames
component.cljs:127 Error rendering component (in app.hello.hello)
reagent$impl$component$do_render @ component.cljs:127
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 6 more frames
core.cljs:56 Uncaught Error: Assert failed: Component must not be nil
c
at Object.reagent$core$adapt_react_class [as adapt_react_class] (core.cljs:56)
at $hello$hello [as reagentRender] (hello.cljs:15)
at eval (component.cljs:86)
at Object.reagent$impl$component$wrap_render [as wrap_render] (component.cljs:91)
at Object.reagent$impl$component$do_render [as do_render] (component.cljs:121)
at eval (component.cljs:271)
at Object.reagent$ratom$in_context [as in_context] (ratom.cljs:44)
at Object.reagent$ratom$deref_capture [as deref_capture] (ratom.cljs:57)
at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (ratom.cljs:539)
at cmp.reagent$impl$component$wrap_funs_$_render [as render] (component.cljs:271)
reagent$core$adapt_react_class @ core.cljs:56
app$hello$hello @ hello.cljs:15
eval @ component.cljs:86
reagent$impl$component$wrap_render @ component.cljs:91
reagent$impl$component$do_render @ component.cljs:121
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 10 more frames
react-dom.development.js:17118 The above error occurred in the <app.hello.hello> component:
in app.hello.hello
Consider adding an error boundary to your tree to customize error handling behavior.
Visit to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:1840
main.js:1673 Error: Assert failed: Component must not be nil
c
at Object.reagent$core$adapt_react_class [as adapt_react_class] (core.cljs:56)
at $hello$hello [as reagentRender] (hello.cljs:15)
at eval (component.cljs:86)
at Object.reagent$impl$component$wrap_render [as wrap_render] (component.cljs:91)
at Object.reagent$impl$component$do_render [as do_render] (component.cljs:121)
at eval (component.cljs:271)
at Object.reagent$ratom$in_context [as in_context] (ratom.cljs:44)
at Object.reagent$ratom$deref_capture [as deref_capture] (ratom.cljs:57)
at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (ratom.cljs:539)
at cmp.reagent$impl$component$wrap_funs_$_render [as render] (component.cljs:271)(ns app.hello
(:require [reagent.core :as r]
["react-data-grid" :refer [ReactDataGrid]]))[(r/adapt-react-class ReactDataGrid)
{:columns [{:key 0 :name "test"}] :rows [{:id 1 :title "two"}]} ""](ns app.hello
(:require [reagent.core :as r]
["react-data-grid" :default ReactDataGrid]))import ReactDataGrid from 'react-data-grid'; so the :default should be correctadapt-react-class[:> ReactDataGrid {...}] should be okshadow-cljs workflow arranged with a large clj|cljc|cljs project https://github.com/clojure-emacs/cider/issues/2946sesman-link-with-project and separate cider jack-ins for tool.deps backend and shadow front-end to get something work-able[:admin] Compiling ...
[:admin] Build failure:
package in /webapp/cljs/admin/node_modules/nouislider specified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["distribute/nouislider.js"], :package-dir #object[java.io.File 0x669ecd61 "/webapp/cljs/admin/node_modules/nouislider"]}
ExceptionInfo: package in /webapp/cljs/admin/node_modules/nouislider specified entries but they were all missing
shadow.build.npm/find-package-main (npm.clj:186)
shadow.build.npm/find-package-main (npm.clj:159)
shadow.build.npm/find-package-require* (npm.clj:200)
shadow.build.npm/find-package-require* (npm.clj:194)
I guess I've updated nouislider here. I also started to delete the .shadow-cljs dir to make sure everything is fresh"main":"./foo.js" or so but foo.js does not exist in the package (in your case distribute/nouislider.js)2.12.5 on macOS 10.15.6 (Catalina) when running a watch process for a browser target I'm seeing builds go into an infinite loop:
[:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.46s)
[:app] Compiling ...
[:app] Build completed. (1341 files, 270 compiled, 0 warnings, 15.65s)
[:app] Compiling ...
[:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.27s)
[:app] Compiling ...
[:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.69s)
[:app] Compiling ...
as soon as the compilation is complete it starts again, and the shadow jvm process spikes the CPU::output-dir into something that is also a :source-paths entrynode-library target, is there a way to include all dependencies from node_modules in the target JS file? (asking because that would be useful in the context of cloud function setups like AWS Lambda):output-to with https://github.com/vercel/ncc or just include the proper node_modules for awsncc does seem nice. One problem I’m seeing with it is that the source maps probably wouldn’t be accurate anymore(?) did anyone run into that?npm install --productionnode_modules should be much smaller:output-dir "that-folder/lib.js" and just zip and deploy that-folderncc + advanced + zip I get pretty tiny lambdas (25kb) and the deployment story of a single JS file just seems more straightforward.yarn. I started using it 2 years ago and now I now that I will never go back npm. Regarding performance it should not vary much where dependencies are stored. I'm already doing the same for babashka runtime and I'm happy with the results. If your lambdas are 25kb it's probably not worth trying layers though.
For deployment and resource automation I'm using AWS SAM. I have already used Serverless Framework and I find AWS SAM the simplest and the best solution. I have never tried Architect , but for me it's just a sugar around AWS SAM and cloudformation.
For me having all resources of the stack in template.yml is super simple.
https://github.com/FieryCod/holy-lambda/blob/master/examples/bb/native/sqs.example/template.yml
Btw I'm planning to add support for Node.js in holy-lambda, so if you would like to help me out it would be lovely.curl -fsSL | bash -s doc/cljdoc.edn
ncc source maps situation https://clojurians.slack.com/archives/C6N245JGG/p1620472416489100shadow-cljs watch :app. About piggieback. My deps.edn looks like so:
{:paths ["src/main"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
com.fulcrologic/fulcro {:mvn/version "3.4.21"}}
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.742"}
thheller/shadow-cljs {:mvn/version "2.12.5"}
binaryage/devtools {:mvn/version "0.9.10"}}}}}
shadow-cljs.edn:
{:deps {:aliases [:dev]}
:builds
{:app
{:target :react-native
:init-fn
:output-dir "app"
:devtools {:autoload true
:preloads [shadow.expo.keep-awake]}}}}
The exception:
~/Projects/rn-fulcro-shadow(main|✚3…) % npx shadow-cljs watch :app
shadow-cljs - config: /Users/pez/Projects/rn-fulcro-shadow/shadow-cljs.edn
shadow-cljs - starting via "clojure"
WARNING: When invoking clojure.main, use -M
[2021-05-08 18:43:55.123 - WARNING] TCP Port 9630 in use.
[2021-05-08 18:43:55.363 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
clojure.lang.Compiler.macroexpand (Compiler.java:7075)
clojure.lang.Compiler.eval (Compiler.java:7161)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:459)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
Caused by:
ExceptionInInitializerError
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:468)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForName (RT.java:2220)
clojure.lang.RT.loadClassForName (RT.java:2239)
clojure.lang.RT.load (RT.java:449)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
Caused by:
ClassNotFoundException com.google.javascript.jscomp.AnonymousFunctionNamingPolicy
jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:606)
jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:168)
java.lang.ClassLoader.loadClass (ClassLoader.java:522)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:468)
clojure.lang.RT.classForName (RT.java:2211)
clojure.lang.RT.classForNameNonLoading (RT.java:2224)
cljs.closure/loading--5569--auto----3990 (closure.clj:9)
cljs.closure__init.load (:9)
cljs.closure__init.<clinit> (:-1)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:468)2.12.x requires 1.10.844shadow-cljs plus tools.deps project working well with cider after transitioning over from years of clojure-cli plus figwheel-main https://github.com/codeasone/starter-cider-tools-deps-shadow - it was certainly more painful than I'd like it to have been.watch in a terminal, and establish a sibling cljs REPL connection, but I can't make that workclj cljc and cljs code and having it target the correct REPL is essential for my workflowM-x cider-connect-sibling-cljs which would have been ideal, but as I say didn't work out due to the way REPL sessions are managed.lein repl. then I start shadow-cljs server separately..nrepl-port for my CLJ REPL and .shadow-cljs/nrepl.port for the CLJS REPLsshadow.user ns, and whether my usage is misuse, but I defer to your advice of course.1. Unhandled clojure.lang.ExceptionInfo shadow-cljs has not been started yet! In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it. If you have a shadow-cljs server or watch running then you are not connected to that process.
shadow-cljs watch will start a new JVM process, instead you are supposed to run (shadow.cljs.devtools.server/start!) in whatever JVM you were connected to when you got that errorfigwheel I just invoke vanilla cider-jack-in-clj&cljs and it just works, clj REPL spins up - I (start)the backend server and figwheel is piggybacked in to the same cider session, all orchestrated by Emacs(start)? I'm guessing thats a user.clj function you have in your codebase that starts figwheel in embedded mode(start) is just something to bring up the backend - just an example of something you might type into the REPL to start the HTTP server for instanceclj some cljccode and some cljs code so I could ensure I could eval forms and the appropriate REPL would be targettedshadow-cljs and understand it's capabilities in the process(start) you also call (shadow.cljs.devtools.server/start!)(start) do that for you wherever that was coming from. I assume you did something like that with figwheelshadow-cljs watch separately you'll get a second JVM instance with its own nrepl server.cider-jack-in-clj&cljs control everything - it's also really simple to bring everything up with one key bindingimport {remote} from "electron";
when i import it ,it outputs
An error occurred when loading app.renderer.core.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2005
renderer.js:1563 TypeError: exports.existsSync is not a function
at Object.shadow$provide.module$node_modules$electron$index (index.js:9)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at eval (js/cljs-runtime/app.renderer.core.js:3)
at eval (<anonymous>)
at Object.goog.globalEval (renderer.js:497)
at Object.env.evalLoad (renderer.js:1560)
at renderer.js:2005
env.evalLoad @ renderer.js:1563
(anonymous) @ renderer.js:2005
js/cljs-runtime/shadow.module.renderer.append.js:4 An error occurred when calling (app.renderer.core/start!)
eval @ js/cljs-runtime/shadow.module.renderer.append.js:4
goog.globalEval @ renderer.js:497
env.evalLoad @ renderer.js:1560
(anonymous) @ renderer.js:2006
renderer.js:1562 An error occurred when loading shadow.module.renderer.append.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2006
renderer.js:1563 TypeError: app.renderer.core.start_BANG_ is not a function
at eval (js/cljs-runtime/shadow.module.renderer.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (renderer.js:497)
at Object.env.evalLoad (renderer.js:1560)
at renderer.js:2006
existsSync on something but I can't guess the code doing that.const fs = require('fs');
const path = require('path');
const pathFile = path.join(__dirname, 'path.txt');
function getElectronPath () {
if (fs.existsSync(pathFile)) {
const executablePath = fs.readFileSync(pathFile, 'utf-8');
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath);
}
return path.join(__dirname, 'dist', executablePath);
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
}
}
module.exports = getElectronPath();
i found it in node_modules/electron/index.jsThe required JS dependency "entities/maps/entities.json" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js". Dependency Trace: tung_frontend/devcards/core.cljs tung_frontend/devcards/text_chat.cljs node_modules/stream-chat-react/dist/index.js node_modules/react-markdown/with-html.js node_modules/react-markdown/lib/with-html.js node_modules/react-markdown/lib/plugins/html-parser.js node_modules/html-to-react/index.js node_modules/html-to-react/lib/parser.js node_modules/htmlparser2/lib/index.js node_modules/htmlparser2/lib/Parser.js node_modules/htmlparser2/lib/Tokenizer.js Searched for npm packages in: /home/anonimito/work/pegleg/clojure/eviota-frontend/node_modules See:I found this old shadow-cljs thread that contains this exact error message https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-20/1598004360.046400 but it doesn't seem to work for me. Relevant config:
:devcards {:asset-path "js/devcards"
:modules {:main {:init-fn tung-frontend.devcards.core/main}}
:compiler-options {:devcards true}
:output-dir "resources/public/js/devcards"
;; :devtools {:httop-root "resources/public" :http-port 8281}
:target :browser
:build-options {:ns-aliases {devcards-marked
tung-frontend.devcards.cljsjs.marked
devcards-syntax-highlighter
tung-frontend.devcards.cljsjs.highlight}}
;; See
:js-options {:resolve {"entities/maps/entities.json"
{:target :npm
:require "entities/lib/maps/entities.json"}}}}
I'm using thheller/shadow-cljs "2.11.4"htmlparser2 manually seems to solve it. 😕yarn why)
=> Found "
shadow-cljs watch app , then he changes a view file, but shadow doesn’t recompile.
Perhaps may be some WSL issue.
If shadow-cljs build is re-launched – then it updates the view.
----
UPD: My client found this https://stackoverflow.com/questions/66055215/emacs-cider-with-shadow-cljs-browser-settings-on-windows-wsl2-hot-code-reload/66061927#66061927, so suspicion moves strongly towards WSL conf.
----
UPD2: Fixed with SO instructionswatch app but when I release with release app it gives some failed to loaderrors. How can I solve such problem.$jscomp not too long ago:compiler-options {:output-feature-set :es6} or even higher :es7, :es8.shadow-cljs/builds cache+shadow-cljs setting.
I've added d3-dag to my :npm-deps in project.clj. I've also tried installing d3-dag manually from the command line.
However, when I try to require it like this:
(require '["d3-dag" :as d3])I get the error:
[:app] Compiling ... [:app] Build failure: IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError clojure.lang.Reflector.getInstanceField (Reflector.java:397) clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440) shadow.build.closure/js-error-xf/fn--45167 (closure.clj:536) clojure.core/map/fn--5862/fn--5863 (core.clj:2742) clojure.core.protocols/iter-reduce (protocols.clj:49) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/transduce (core.clj:6884) clojure.core/into (core.clj:6899) clojure.core/into (core.clj:6887) shadow.build.closure/throw-errors! (closure.clj:1093) shadow.build.closure/throw-errors! (closure.clj:1088) shadow.build.closure/convert-sources-simple* (closure.clj:1843) shadow.build.closure/convert-sources-simple* (closure.clj:1703) shadow.build.closure/convert-sources-simple (closure.clj:1989) shadow.build.closure/convert-sources-simple (closure.clj:1941) shadow.build.compiler/maybe-closure-convert (compiler.clj:1082) shadow.build.compiler/maybe-closure-convert (compiler.clj:1075) shadow.build.compiler/compile-all (compiler.clj:1333) shadow.build.compiler/compile-all (compiler.clj:1194) shadow.build.api/compile-sources (api.clj:256) shadow.build.api/compile-sources (api.clj:248) shadow.build/compile (build.clj:398) shadow.build/compile (build.clj:389) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:314) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:300) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:936) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:899) shadow.cljs.devtools.server.util/server-thread/fn--48207/fn--48208/fn--48216 (util.clj:285) shadow.cljs.devtools.server.util/server-thread/fn--48207/fn--48208 (util.clj:284) shadow.cljs.devtools.server.util/server-thread/fn--48207 (util.clj:257) java.lang.Thread.run (Thread.java:831)Any hints on how to start debugging this would be appreciated. The error is specific to the
d3-dag package, since requiring ["react" :as r] works.shadow-cljs though). Will fix it and see if they disappear. Do you think these error messages might have the same cause? https://clojurians.slack.com/archives/C053AK3F9/p1620220881170500npx shadow-cljs server and npx shadow-cljs watch app both supposed to tie up the CLI window (I'm running this in WSL2) and require opening a new one for subsequent commands?google-chrome does as well? I've opened my 4th window now..., another server at , and an nREPL server "on port 35301". I can navigate to the first two servers in my WSL2 browser (and even in a Windows browser), but I don't know what to make of the third. Actually, since it was telling me a REPL was being started I was kind of waiting for a REPL prompt to show up (but no).npx shadow-cljs watch app process in https://github.com/shadow-cljs/quickstart-browser supposed to cover index.html (and CSS files, I should ask) for live updating? ...or is there a way to get it to? The browser is not reacting to changes to it. I can hit F5, but I thought that was not supposed to be required with hot reloading.(-> js/document (.getElementsByTagName "h1" 0) (.-innerHTML) (set! "Live reloaded"))
4. (set! (.-innerHTML .getElementsByTagName "h1" "0" js/document) "Live reloaded")
5.`(def heading1 (.getElementsByTagName "h1" 0 js/document)) (set! (.-innerHTML "Live reloaded"))`
6. (def heading1 ([0] "h1" .getElementsByTagName js/document)) ;(set! (.-innerHTML "Live reloaded"))
...and I do realize state should be dealt with differently, like by using atoms and/or learning reagent, but for now I just want to try to get some kind of live reloading working. Thanks.(let [el (-> (js/document.getElementsByTagName "h1")
(aget 0))]
(set! (.-innerHTML el) "yo"))(set! (.-innerHTML (-> (js/document.getElementsByTagName "h1") (aget 0)) "Equivalent one-liner wihout 'let'?"))
Not sure how half of the example working code I found out there was one-liners (again, at least for things referenced by Id---I wonder if not having to deal with that '0' makes the difference).(set! (.-innerHTML (-> (js/document.getElementsByTagName "h1") (aget 0))) "Equivalent one-liner wihout 'let'?")(-> (js/document.getElementsByTagName "h1") (aget 0) (set! -innerHTML "Equivalent one-liner wihout 'let'!"))also works
js/document.getElementsByTagName returns an array, aget gets the nth element of that arrayjs/document.getElementById only returns a singular element, not an arrayvariable module is undeclared warning from Resource: com/cognitect/transit.js:649:8 when I do release and I am not sure why, any pointer would be appreciated to what this is about.module to get rid of it but it is safe to ignorestop function you can call to achieve this - I'm looking for the shadow equivalent. thanks(shadow/watch-set-autobuild! :the-build-id true|false):modules
{:organization
{:entries #{app.components.organization.init}
:output-to "target/cljsbuild/public/js/out/organization.js"}
:home
{:entries #{app.components.home.init}
:output-to "target/cljsbuild/public/js/out/home.js"}
:user-management
{:entries #{app.components.organization.users.init}
:output-to "target/cljsbuild/public/js/out/user-management.js"}
:settings
{:entries #{app.components.organization.settings.init}
:output-to "target/cljsbuild/public/js/out/settings.js"}}.js file is generated:depends-on
ExceptionInfo: two modules without deps, please specify which one is the default
:shared {:entries []} and then all the other :depends-on #{:shared}:output-to per modulecljs.pprint was in their build 😉:module-loader :no-injectBased on code https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj should be ok:
;; true to inject the loader data (which changes the signature)
;; any other true-ish value still generates the module-loader.edn data files
;; but does not inject (ie. change the signature)
(true? module-loader)
(inject-loader-setup-release config)
But spec for module loader forces bolean (s/def ::module-loader boolean?)
What is missing in my setup to avoid inclusion of module loader in js?:module-loader false? what are you trying to achieve? that comment refers to old code that doesn't exist anymoreMODULES:
:main {:entries [:react, :material-ui]}
:feature-1 {:entries [alpha/feature-1]}
App 2:
MODULES:
:main {:entries [:react, :material-ui]}
:feature-2 {:entries [alpha/feature-2]}
App 3:
MODULES:
:main {:entries [:react, :material-ui]}
:feature-3 {:entries [alpha/feature-3]}
Then I would be able to load javascript produced from :feature-1 and :feature-2 modules into APP3 .
All of them are compiled using :simple optimization and are forcing for all shared deps to be in main module.
My assumption here was that I will be able to override loadig of modules and put in :feature-1 and :feature-2 modules inside
var shadow$modules = {"uris":{"main":[],
"feature-1":[""]},
"feature-2":[""]},
"infos":{"main":null,"feature-3":["main"]}};:advanced builds are not compatible with each other:simple is also gigantic:module-loader-init false in your build configshadow.loader/init yourself. you can change the shadow$modules however you want before that:simple is a dealbreaker:simple some code is rewritten in incompatible ways:js-provider :external:modules will end up in trouble at some point(defmacro reg-event-assoc-in [name seq-of-kw]
`(re-frame/reg-event-db
~name
(fn [db# [_ value#]]
(assoc-in db# ~seq-of-kw value#))))(utils-events/reg-event-assoc-in ::accounts-dropdown-selected-option
[:accounts-dropdown :the-selected-option])
4 | (utils-events/reg-event-assoc-in ::enable-new-project-modal?
-------^------------------------------------------------------------------------
Syntax error macroexpanding cljs.core/fn.
Call to cljs.core/fn did not conform to spec.
-- Spec failed --------------------
((clojure.core/apply
clojure.core/vector
(clojure.core/seq
(clojure.core/concat
(clojure.core/list 'quagga.utils.events/db__31345__auto__)
(clojure.core/list
(clojure.core/apply
clojure.core/vector
(clojure.core/seq
(clojure.core/concat
(clojure.core/list 'quagga.utils.events/_)
(clojure.core/list
'quagga.utils.events/value__31346__auto__)))))))) ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
should satisfy
vector?
or value
((clojure.core/apply ... ...) ...)
^^^^^^^^^^^^^^^^^^
should satisfy
vector?
-- Relevant specs -------
:shadow.cljs.devtools.cljs-specs/param-list:
(clojure.spec.alpha/and
clojure.core/vector?
(clojure.spec.alpha/cat
:params
(clojure.spec.alpha/* :shadow.cljs.devtools.cljs-specs/binding-form)
:var-params
(clojure.spec.alpha/?
(clojure.spec.alpha/cat
:ampersand
#{'&}
:var-form
:shadow.cljs.devtools.cljs-specs/binding-form))))
:shadow.cljs.devtools.cljs-specs/params+body:
(clojure.spec.alpha/cat
:params
:shadow.cljs.devtools.cljs-specs/param-list
:body
(clojure.spec.alpha/alt
:prepost+body
(clojure.spec.alpha/cat
:prepost
clojure.core/map?
:body
(clojure.spec.alpha/+ clojure.core/any?))
:body
(clojure.spec.alpha/* clojure.core/any?)))_ is the problem, use ignored# or so instead(defn reg-event-assoc-in [name seq-of-kw]
(re-frame/reg-event-db name
(fn [db [_ value]]
(assoc-in db seq-of-kw value)))):node-test already takes CLI arguments--help, or --test=a.single.ns or --test=a.single.ns/test-namenode the-test-file.js --helpTEST_DATA=foo.txt node the-test-file.js --test=that.one/test-thing(fs/readFileSync js/process.env.TEST_DATA) or whatever{:js-options {:js-provider :require}} the luminus landing page tells me that the javascript has not compiled and I get these errors in the developer console:
app.js:1672 An error occurred when loading shadow.js.shim.module$react.js
env.evalLoad @ app.js:1672
app.js:1673 ReferenceError: require is not defined
at eval (:3000/js/cljs-runtime/shadow.js.shim.module$react.js:3)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:577)
at Object.env.evalLoad (app.js:1670)
at app.js:1773
env.evalLoad @ app.js:1673
app.js:1672 An error occurred when loading shadow.js.shim.module$react_dom.js
env.evalLoad @ app.js:1672
app.js:1673 ReferenceError: require is not defined
at eval (:3000/js/cljs-runtime/shadow.js.shim.module$react_dom.js:3)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:577)
at Object.env.evalLoad (app.js:1670)
at app.js:1811
env.evalLoad @ app.js:1673
util.cljs:187 Installing CLJS DevTools 1.0.3 and enabling features :formatters :hints :async
app.js:1672 An error occurred when loading everclear.app.js
env.evalLoad @ app.js:1672
app.js:1673 TypeError: Cannot read property 'prototype' of undefined
at Object.reagent$impl$component$create_class [as create_class] (component.cljs:323)
at Object.reagent$impl$component$fn_to_class [as fn_to_class] (component.cljs:373)
at Object.reagent$impl$component$as_class [as as_class] (component.cljs:379)
at reagent$impl$template$reag_element (template.cljs:159)
at Object.reagent$impl$template$vec_to_elem [as vec_to_elem] (template.cljs:284)
at Object.reagent$impl$template$as_element [as as_element] (template.cljs:288)
at Object.eval [as reagent$impl$protocols$Compiler$as_element$arity$2] (template.cljs:305)
at Object.reagent$impl$protocols$as_element [as as_element] (protocols.cljs:5)
at f (dom.cljs:47)
at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:19)
env.evalLoad @ app.js:1673
This happens even though lein shadow watch app builds and compiles just fine. Any hints for how to debug it?[:app] Compiling ... [:app] Build failure: Closure compilation failed with 2 errors --- node_modules/d3-array/dist/d3-array.js:280 This code cannot be converted from ES6. extending native class: Map --- node_modules/d3-array/dist/d3-array.js:300 This code cannot be converted from ES6. extending native class: Set
:require it compiles (but does not work in the browser):compiler-options {:output-feature-set :es6} not :js-provider:js-provider :require shadow-cljs will NOT process any JS dependencies and instead expect a separate tool to do that. this is not what you want:output-feature-set is :es5 but as the error is telling you the d3 code cannot be converted "down". so by setting a "higher" feature set that problem goes away:js-provider :shadow is the default for :browser builds, do not change it unless you know what you are doing.:resolve either, that is not relevant here.:es6. really doesn't make sense to have :es5 still.:es5 then, right?:ecmascript6 . Is that correct?shadow-cljs release node wasn't working, even though
shadow-cljs compile node was.
Following advice in the troubleshooting guide, I compared versions of the major dependent libraries across working and non-working projects and noticed that the com.google.javascript/closure-compiler version was different, someone had pinned it in the deps.edn with a note about "enable for node", I also noted that there is a specified shadow-cljs version in the deps.edn
it eventually worked only when I both installed the specified version of shadow-cljs (through npm, how I'd originally installed), and unpinned the versions of
com.google.javascript/closure-compiler and org.clojure/google-closure-library which had both been pinned under a note.
The things I remain confused about:
do aliases like:
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.10.21"}
enforce shadow-cljs version? From my troubleshooting, I guess not if you install via npm, therefore I should be installing via lein?
Does anyone have an idea why these libraries have to be pinned, and shadow-cljs has to be an older version? the errors I got with the newer version were like this:
No matching field found: getSourceName for class com.google.javascript.jscomp.JSError and
The result of a goog.define call must be assigned as an isolated statement.
one for pinned and one for unpinned closure compiler versionsdeps.edn and have a true-ish :deps key in shadow-cljs.edn then ONLY deps.edn controls the version for shadow-cljs you getpackage.json then only controls the version of the shadow-cljs command line toolscljs to a specific folder from where I'm serving them with a different HTTP server. Everything seems to work ok... code compiles on save and hot reloads on the browser 😃. However, I do not get a browser repl after the code is compiled when I run shadow-cljs watch app;; :dev-http {3000 "public"} in my shadow-cljs.edn file because my server is running on the same portshadow-cljs cljs-repl app will give you the REPLshadow.loader/load but the XHR request it makes has this undefined segment in the url <correct shadow-cljs.edn asset path> and I’m not sure why = goog.module.ModuleManager.getInstance();shadow.loader/init without an argument that might be the undefined?.execOnLoad(id, cb)shadow.loader/load
shadow.loader.load = function(id, cb) {
shadow.loader.ensureInitWasCalled();
id = shadow.loader.string_id(id);
if (cb) {
shadow.loader.mm.execOnLoad(id, cb);
}
return shadow.loader.mm.load(id);
};:init-fn in the module configshadow.lazy or the example from here https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html["blog"
{:name :,
:weight 5,
:view #'deli-pages-blog/render,
:label "blog",
:controllers
[{:identity
(clojure.core/juxt :parameters :path-params :query-params),
:start #(rf/dispatch [:fetch-blog])}]}]
the only reason it’s all bundled together is for importing the namespace and passing it to that :view keyword, so if I can just lazy reference that, bingo:source-paths ["src/main" "src/test"]
:builds {
:test {:target :karma
:output-to "target/ci.js"}}
$ npx shadow-cljs compile test shadow-cljs - config: /home/stuart/Source/cljs/cljs-asm/shadow-cljs.edn shadow-cljs - connected to server [:test] Compiling ... [:test] Build completed. (62 files, 1 compiled, 0 warnings, 0.45s)This puts a file
ci.js in a folder named target
I have a karma.conf.js
module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
// The directory where the output file lives
basePath: 'target',
// The file itself
files: ['ci.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
})
};
When I run karma start --single-run
I see this:
13 05 2021 20:11:24.219:INFO [karma-server]: Karma v6.3.2 server started at 13 05 2021 20:11:24.222:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited 13 05 2021 20:11:24.230:INFO [launcher]: Starting browser ChromeHeadless 13 05 2021 20:11:24.539:INFO [Chrome Headless 90.0.4430.212 (Linux x86_64)]: Connected on socket 63Mi3R7buKBGnu2WAAAB with id 43705700 Chrome Headless 90.0.4430.212 (Linux x86_64): Executed 0 of 0 SUCCESS (0.003 secs / 0 secs) TOTAL: 0 SUCCESSMy tests are namespaced like this
(ns exfn.parser-test (:require [cljs.test :refer-macros [deftest is testing run-tests]]))anyone any ideas why its not finding my tests?
npx shadow-cljs watch app npx shadow-cljs release appetc
shadow-cljs - config: /home/stuart/Source/cljs/cljs-asm/shadow-cljs.edn === Version jar: 2.11.22 cli: 2.11.22 deps: 1.3.2 config-version: 2.11.22
:lein or :deps key in your shadow-cljs.edn?;; shadow-cljs configuration
{:source-paths
["src/main"
"src/test"]
:dependencies
[[binaryage/devtools "0.9.10"]
[reagent "1.0.0"]
[re-frame "1.2.0"]
[day8.re-frame/re-frame-10x "1.0.1"]
[org.clojars.ertucetin/re-frame-flow "0.1.1"]
[bidi "2.1.6"]
[com.rpl/specter "1.1.3"]]
:nrepl {:port 3333}
:dev-http {8080 "public"}
:builds {:app {:target :browser
:output-dir "public/js"
:modules {:main {:init-fn }}
:dev {:compiler-options {:closure-defines {re-frame.trace/trace-enabled? true
day8.re-frame.tracing/trace-enabled? true}}}
:devtools {:http-root "public"
:http-port 3000
:preloads [day8.re-frame-10x.preload
re-frame-flow.preload]}
:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true}
:silence-optimizations-warning true
;; in production so you can do an :advanced compile.
:optimizations :simple}
:release {:build-options {:ns-aliases {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}
:release {:target :browser
:output-dir "release/js"
:modules {:main {:init-fn }}
:compiler-options {:silence-optimizations-warning true
:optimizations :advanced}}
:test {:target :karma
:ns-regexp "-test$"
:output-to "target/ci.js"}}}:release build but thats not relevant to the testdeftest in your test file? with actual is assertions?src/test/interpreter-tests.cljs src/test/parser-tests.cljsA test looks like
(deftest is-register-tests? (is (true? (is-register? ":x"))) (is (false? (is-register? "5"))) (is (false? (is-register? "foo"))) (is (false? (is-register? "b_010101"))))
:silence-optimizations-warning from but that config option does not exist(ns exfn.parser-test ... needs to be in src/test/exfn/parser_test.cljs:ns-regexp "-test$" which does not match parser-testscreate-cljs-app so that’s the structure.lein for all my CLJ needs so I'll have a project.clj for that with the proper dependencies. so I'll have a shadow-cljs.edn for everything CLJS related and a project.clj for CLJ stufflein new app server
(defproject server "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url ""}
:dependencies [[org.clojure/clojure "1.10.1"]]
:main ^:skip-aot server.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
how much of this is relevant pr meeds to be changed? (thanks for the hand holding).Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:581). jdk.vm.ci.services.Servicesafter upgrading from version 2.12.5 to 2.13.0. I start the watch process with
npx shadow-cljs watch :main.
Is there something that I need to change in shadow-cljs.edn or the way that I'm starting Shadow CLJS in watch mode?{:clojure.main/message
"Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:606).\njdk.vm.ci.services.Services\n",
:clojure.main/triage
{:clojure.error/class java.lang.ClassNotFoundException,
:clojure.error/line 606,
:clojure.error/cause "jdk.vm.ci.services.Services",
:clojure.error/symbol
jdk.internal.loader.BuiltinClassLoader/loadClass,
:clojure.error/source "BuiltinClassLoader.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.util.ServiceConfigurationError,
:message
"org.graalvm.polyglot.impl.AbstractPolyglotImpl: Provider com.oracle.truffle.polyglot.PolyglotImpl could not be instantiated",
:at [java.util.ServiceLoader fail "ServiceLoader.java" 584]}
{:type java.lang.NoClassDefFoundError,
:message "jdk/vm/ci/services/Services",
:at [org.graalvm.libgraal.LibGraal <clinit> "LibGraal.java" 46]}
{:type java.lang.ClassNotFoundException,
:message "jdk.vm.ci.services.Services",
:at
[jdk.internal.loader.BuiltinClassLoader
loadClass
"BuiltinClassLoader.java"
606]}],
:trace
[[jdk.internal.loader.BuiltinClassLoader
loadClass
"BuiltinClassLoader.java"
606]
[jdk.internal.loader.ClassLoaders$AppClassLoader
loadClass
"ClassLoaders.java"
168]
[java.lang.ClassLoader loadClass "ClassLoader.java" 522]
[org.graalvm.libgraal.LibGraal <clinit> "LibGraal.java" 46]
[org.graalvm.compiler.truffle.runtime.hotspot.libgraal.LibGraalTruffleRuntimeAccess
getPriority
"LibGraalTruffleRuntimeAccess.java"
44]
[com.oracle.truffle.api.Truffle
selectTruffleRuntimeAccess
"Truffle.java"
89]
[com.oracle.truffle.api.Truffle access$000 "Truffle.java" 57]
[com.oracle.truffle.api.Truffle$1 run "Truffle.java" 122]
[com.oracle.truffle.api.Truffle$1 run "Truffle.java" 107]
[java.security.AccessController
doPrivileged
"AccessController.java"
312]
[com.oracle.truffle.api.Truffle initRuntime "Truffle.java" 107]
[com.oracle.truffle.api.Truffle <clinit> "Truffle.java" 62]
[com.oracle.truffle.api.impl.Accessor getTVMCI "Accessor.java" 1092]
[com.oracle.truffle.api.impl.Accessor
access$000
"Accessor.java"
117]
[com.oracle.truffle.api.impl.Accessor$Constants
<clinit>
"Accessor.java"
974]
[com.oracle.truffle.api.impl.Accessor
nodeSupport
"Accessor.java"
1025]
[com.oracle.truffle.api.LanguageAccessor
<clinit>
"LanguageAccessor.java"
79]
[com.oracle.truffle.api.TruffleLogger$LoggerCache
<clinit>
"TruffleLogger.java"
957]
[com.oracle.truffle.api.TruffleLogger
getLogger
"TruffleLogger.java"
154]
[com.oracle.truffle.api.TruffleLogger
getLogger
"TruffleLogger.java"
138]
[com.oracle.truffle.polyglot.PolyglotContextImpl
<clinit>
"PolyglotContextImpl.java"
101]
[com.oracle.truffle.polyglot.HostException
<init>
"HostException.java"
58]
[com.oracle.truffle.polyglot.PolyglotImpl
<clinit>
"PolyglotImpl.java"
92]
[jdk.internal.reflect.NativeConstructorAccessorImpl
newInstance0
"NativeConstructorAccessorImpl.java"
-2]
[jdk.internal.reflect.NativeConstructorAccessorImpl
newInstance
"NativeConstructorAccessorImpl.java"
64]
[jdk.internal.reflect.DelegatingConstructorAccessorImpl
newInstance
"DelegatingConstructorAccessorImpl.java"
45]
[java.lang.reflect.Constructor
newInstanceWithCaller
"Constructor.java"
500]
[java.lang.reflect.Constructor newInstance "Constructor.java" 481]
[java.util.ServiceLoader$ProviderImpl
newInstance
"ServiceLoader.java"
782]
[java.util.ServiceLoader$ProviderImpl get "ServiceLoader.java" 724]
[java.util.ServiceLoader$3 next "ServiceLoader.java" 1396]
[org.graalvm.polyglot.Engine$1
searchServiceLoader
"Engine.java"
747]
[org.graalvm.polyglot.Engine$1 run "Engine.java" 733]
[org.graalvm.polyglot.Engine$1 run "Engine.java" 707]
[java.security.AccessController
doPrivileged
"AccessController.java"
312]
[org.graalvm.polyglot.Engine initEngineImpl "Engine.java" 707]
[org.graalvm.polyglot.Engine access$000 "Engine.java" 106]
[org.graalvm.polyglot.Engine$ImplHolder <clinit> "Engine.java" 115]
[org.graalvm.polyglot.Engine getImpl "Engine.java" 304]
[org.graalvm.polyglot.HostAccess$Builder
targetTypeMapping
"HostAccess.java"
913]
[com.oracle.truffle.js.scriptengine.GraalJSScriptEngine
createNashornHostAccess
"GraalJSScriptEngine.java"
104]
[com.oracle.truffle.js.scriptengine.GraalJSScriptEngine
<clinit>
"GraalJSScriptEngine.java"
99]
[com.oracle.truffle.js.scriptengine.GraalJSEngineFactory
getScriptEngine
"GraalJSEngineFactory.java"
180]
[com.oracle.truffle.js.scriptengine.GraalJSEngineFactory
getScriptEngine
"GraalJSEngineFactory.java"
57]
[javax.script.ScriptEngineManager
getEngineByName
"ScriptEngineManager.java"
241]
[shadow.cljs.devtools.server.npm_deps$make_engine
invokeStatic
"npm_deps.clj"
16]
[shadow.cljs.devtools.server.npm_deps$make_engine
invoke
"npm_deps.clj"
11]
[shadow.cljs.devtools.server.npm_deps$fn__17754$fn__17755
invoke
"npm_deps.clj"
28]
[clojure.lang.Delay deref "Delay.java" 42]
[clojure.core$deref invokeStatic "core.clj" 2324]
[clojure.core$deref invoke "core.clj" 2310]
[shadow.cljs.devtools.server.npm_deps$fn__17754$fn__17757
invoke
"npm_deps.clj"
34]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_
invokeStatic
"npm_deps.clj"
201]
[shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_
invoke
"npm_deps.clj"
195]
[shadow.cljs.devtools.server.npm_deps$main$fn__17849
invoke
"npm_deps.clj"
221]
[clojure.core$complement$fn__5686 invoke "core.clj" 1443]
[clojure.core$filter$fn__5911 invoke "core.clj" 2825]
[clojure.lang.LazySeq sval "LazySeq.java" 42]
[clojure.lang.LazySeq seq "LazySeq.java" 51]
[clojure.lang.RT seq "RT.java" 535]
[clojure.core$seq__5419 invokeStatic "core.clj" 139]
[clojure.core$seq__5419 invoke "core.clj" 139]
[shadow.cljs.devtools.server.npm_deps$main
invokeStatic
"npm_deps.clj"
223]
[shadow.cljs.devtools.server.npm_deps$main
invoke
"npm_deps.clj"
210]
[shadow.cljs.devtools.cli_actual$main
invokeStatic
"cli_actual.clj"
141]
[shadow.cljs.devtools.cli_actual$main doInvoke "cli_actual.clj" 132]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 671]
[clojure.core$apply invoke "core.clj" 662]
[shadow.cljs.devtools.cli_actual$_main
invokeStatic
"cli_actual.clj"
219]
[shadow.cljs.devtools.cli_actual$_main
doInvoke
"cli_actual.clj"
217]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$apply invoke "core.clj" 662]
[shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 75]
[shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 67]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause "jdk.vm.ci.services.Services"}}-Streeorg.clojure/data.json 2.2.3
org.clojure/clojure 1.10.3
. org.clojure/spec.alpha 0.2.194
. org.clojure/core.specs.alpha 0.2.56
org.clojure/tools.logging 1.1.0
expound/expound 0.8.9
compojure/compojure 1.6.2
. org.clojure/tools.macro 0.1.5
. clout/clout 2.2.1
. instaparse/instaparse 1.4.8
. medley/medley 1.3.0
X ring/ring-core 1.8.1 :use-top
X ring/ring-codec 1.1.2 :superseded
X commons-codec/commons-codec 1.11 :parent-omitted
org.slf4j/jcl-over-slf4j 1.7.30
X org.slf4j/slf4j-api 1.7.30 :use-top
com.google.cloud/google-cloud-logging-logback 0.119.0-alpha
X ch.qos.logback/logback-classic 1.2.3 :use-top
. ch.qos.logback/logback-core 1.2.3
. com.google.cloud/google-cloud-logging 2.0.1
. com.google.guava/failureaccess 1.0.1
. com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
. com.google.code.findbugs/jsr305 3.0.2
. org.checkerframework/checker-compat-qual 2.5.5
. com.google.errorprone/error_prone_annotations 2.4.0
. com.google.j2objc/j2objc-annotations 1.3
. io.grpc/grpc-api 1.34.0
. io.grpc/grpc-context 1.34.0
. org.codehaus.mojo/animal-sniffer-annotations 1.19
. io.grpc/grpc-stub 1.34.0
. io.grpc/grpc-protobuf 1.34.0
. io.grpc/grpc-protobuf-lite 1.34.0
. javax.annotation/javax.annotation-api 1.3.2
. com.google.auto.value/auto-value-annotations 1.7.4
. com.google.protobuf/protobuf-java 3.14.0
. com.google.protobuf/protobuf-java-util 3.14.0
. com.google.code.gson/gson 2.8.6
. com.google.api.grpc/proto-google-common-protos 2.0.1
. com.google.api.grpc/proto-google-cloud-logging-v2 0.85.1
. com.google.api/gax 1.60.1
. io.opencensus/opencensus-api 0.24.0
. com.google.api/gax-grpc 1.60.1
. io.grpc/grpc-auth 1.34.0
. com.google.auth/google-auth-library-credentials 0.22.0
. io.grpc/grpc-netty-shaded 1.34.0
. io.grpc/grpc-alts 1.34.0
. io.grpc/grpc-grpclb 1.34.0
X org.apache.commons/commons-lang3 3.5 :superseded
. org.conscrypt/conscrypt-openjdk-uber 2.5.1
. org.threeten/threetenbp 1.5.0
. com.google.cloud/google-cloud-core-grpc 1.94.0
. com.google.http-client/google-http-client-jackson2 1.38.0
. com.fasterxml.jackson.core/jackson-core 2.12.0
. com.google.http-client/google-http-client 1.38.0
. org.apache.httpcomponents/httpclient 4.5.13
. commons-logging/commons-logging 1.2
X commons-codec/commons-codec 1.11 :superseded
X org.apache.httpcomponents/httpcore 4.4.13 :superseded
. io.opencensus/opencensus-contrib-http-util 0.24.0
. io.grpc/grpc-core 1.34.0
. com.google.android/annotations 4.1.1.4
. io.perfmark/perfmark-api 0.19.0
. com.google.api.grpc/proto-google-iam-v1 1.0.3
X org.slf4j/slf4j-api 1.7.30 :use-top
. com.google.api/api-common 1.10.1
. com.google.cloud/google-cloud-core 1.94.0
. com.google.auth/google-auth-library-oauth2-http 0.22.0
X com.google.guava/guava 30.0-android :use-top
org.apache.logging.log4j/log4j-to-slf4j 2.14.1
X org.slf4j/slf4j-api 1.7.25 :use-top
. org.apache.logging.log4j/log4j-api 2.14.1
com.cognitect/anomalies 0.1.12
ring-cors/ring-cors 0.1.13
ring/ring-defaults 0.3.2
X ring/ring-core 1.6.3 :use-top
. ring/ring-ssl 0.3.0
X ring/ring-core 1.6.0 :use-top
. ring/ring-headers 0.3.0
X ring/ring-core 1.6.0 :use-top
. ring/ring-anti-forgery 1.3.0
. crypto-random/crypto-random 1.2.0
. crypto-equality/crypto-equality 1.0.0
X hiccup/hiccup 1.0.5 :use-top
. javax.servlet/javax.servlet-api 3.1.0
com.cognitect/transit-cljs 0.8.269
. com.cognitect/transit-js 0.8.874
thheller/shadow-cljs 2.12.6
X org.clojure/data.json 2.2.1 :use-top
X org.clojure/tools.cli 1.0.194 :superseded
. org.clojure/tools.reader 1.3.5
. nrepl/nrepl 0.8.3
. cider/piggieback 0.5.2
X com.cognitect/transit-clj 1.0.324 :use-top
X com.cognitect/transit-cljs 0.8.264 :use-top
. org.clojure/core.async 1.3.610
. org.clojure/tools.analyzer.jvm 1.1.0
. org.clojure/tools.analyzer 1.0.0
. org.clojure/core.memoize 1.0.236
. org.clojure/core.cache 1.0.207
. org.clojure/data.priority-map 1.0.0
X org.ow2.asm/asm 5.2 :superseded
X org.clojure/tools.reader 1.3.2 :older-version
X org.clojure/clojurescript 1.10.844 :use-top
. com.google.javascript/closure-compiler-unshaded v20210302
. org.clojure/google-closure-library 0.0-20201211-3e6c510d
. org.clojure/google-closure-library-third-party 0.0-20201211-3e6c510d
. org.clojure/google-closure-library-third-party 0.0-20201211-3e6c510d
. thheller/shadow-util 0.7.0
X hiccup/hiccup 1.0.5 :use-top
. thheller/shadow-client 1.3.3
X org.clojure/core.async 0.3.443 :older-version
X hiccup/hiccup 1.0.5 :use-top
. thheller/shadow-undertow 0.1.0
. org.clojure/core.async 1.3.610
. io.undertow/undertow-core 2.2.4.Final
. org.jboss.logging/jboss-logging 3.4.1.Final
. org.jboss.xnio/xnio-api 3.8.0.Final
. org.wildfly.common/wildfly-common 1.5.2.Final
. org.wildfly.client/wildfly-client-config 1.0.1.Final
X org.jboss.logging/jboss-logging 3.3.1.Final :older-version
X org.wildfly.common/wildfly-common 1.2.0.Final :older-version
. org.jboss.xnio/xnio-nio 3.8.0.Final
. org.jboss.xnio/xnio-api 3.8.0.Final
X org.jboss.threads/jboss-threads 2.3.3.Final :older-version
. org.jboss.threads/jboss-threads 3.1.0.Final
. org.jboss.logging/jboss-logging 3.4.1.Final
X hiccup/hiccup 1.0.5 :use-top
X ring/ring-core 1.9.2 :use-top
. org.graalvm.js/js 21.0.0.2
. org.graalvm.regex/regex 21.0.0.2
. org.graalvm.truffle/truffle-api 21.0.0.2
. org.graalvm.truffle/truffle-api 21.0.0.2
. org.graalvm.sdk/graal-sdk 21.0.0.2
. org.graalvm.sdk/graal-sdk 21.0.0.2
. com.ibm.icu/icu4j 67.1
. org.graalvm.js/js-scriptengine 21.0.0.2
. org.graalvm.sdk/graal-sdk 21.0.0.2
X expound/expound 0.8.5 :use-top
X fipp/fipp 0.6.23 :use-top
. com.bhauman/cljs-test-display 0.1.1
. com.wsscode/pathom 2.2.31
. com.wsscode/spec-inspec 1.0.0-alpha2
. spec-coerce/spec-coerce 1.0.0-alpha6
. com.wsscode/spec-inspec 1.0.0-alpha2
. edn-query-language/eql 0.0.9
X org.clojure/test.check 0.10.0-alpha3 :older-version
X org.clojure/spec.alpha 0.2.176 :older-version
X org.clojure/core.specs.alpha 0.2.44 :older-version
X org.clojure/core.async 0.4.474 :older-version
X org.clojure/test.check 0.10.0-alpha3 :older-version
. org.clojure/test.check 1.1.0
. thheller/shadow-cljsjs 0.0.21
org.clojure/clojurescript 1.10.844
X org.clojure/data.json 0.2.6 :use-top
X org.clojure/tools.reader 1.3.3 :older-version
X com.cognitect/transit-clj 0.8.309 :use-top
com.stuartsierra/component 1.0.0
. com.stuartsierra/dependency 1.0.0
fipp/fipp 0.6.23
. org.clojure/core.rrb-vector 0.1.1
aero/aero 1.1.6
org.slf4j/jul-to-slf4j 1.7.30
X org.slf4j/slf4j-api 1.7.30 :use-top
cljs-ajax/cljs-ajax 0.8.3
. cheshire/cheshire 5.10.0
X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
. com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.10.2
X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
. com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.10.2
X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
. tigris/tigris 0.1.2
X com.cognitect/transit-clj 1.0.324 :use-top
X com.cognitect/transit-cljs 0.8.264 :use-top
. org.apache.httpcomponents/httpasyncclient 4.1.4
X org.apache.httpcomponents/httpcore 4.4.10 :older-version
. org.apache.httpcomponents/httpcore-nio 4.4.10
X org.apache.httpcomponents/httpcore 4.4.10 :older-version
X org.apache.httpcomponents/httpclient 4.5.6 :older-version
. commons-logging/commons-logging 1.2
. org.apache.httpcomponents/httpcore 4.4.14 :newer-version
com.brunobonacci/mulog 0.6.5
. amalloy/ring-buffer 1.3.1
zprint/zprint 1.1.2
. rewrite-cljs/rewrite-cljs 0.4.5
X org.clojure/tools.reader 1.3.2 :older-version
X borkdude/edamame 0.0.11-alpha.28 :superseded
X org.clojure/tools.reader 1.3.4 :older-version
X borkdude/sci 0.2.1-alpha.1 :superseded
X borkdude/sci.impl.reflector 0.0.1 :parent-omitted
X borkdude/edamame 0.0.11-alpha.27 :parent-omitted
. rewrite-clj/rewrite-clj 0.6.1
X org.clojure/tools.reader 1.2.2 :older-version
hiccup/hiccup 1.0.5
org.apache.commons/commons-text 1.9
. org.apache.commons/commons-lang3 3.11 :newer-version
com.google.guava/guava 30.0-jre
. com.google.guava/failureaccess 1.0.1
. com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
. com.google.code.findbugs/jsr305 3.0.2
. org.checkerframework/checker-qual 3.5.0
X com.google.errorprone/error_prone_annotations 2.3.4 :older-version
. com.google.j2objc/j2objc-annotations 1.3
datalevin/datalevin 0.4.31
. org.clojure/tools.cli 1.0.206 :newer-version
. borkdude/sci 0.2.4 :newer-version
. borkdude/sci.impl.reflector 0.0.1
. borkdude/edamame 0.0.11-alpha.29 :newer-version
X org.clojure/tools.reader 1.3.4 :older-version
X com.cognitect/transit-clj 1.0.324 :use-top
. nrepl/bencode 1.1.0
. com.taoensso/nippy 3.1.1
X org.clojure/tools.reader 1.3.4 :older-version
. com.taoensso/encore 3.9.2
X org.clojure/tools.reader 1.3.3 :older-version
. com.taoensso/truss 1.6.0
. org.iq80.snappy/snappy 0.4
. org.tukaani/xz 1.8
. org.lz4/lz4-java 1.7.1
. persistent-sorted-set/persistent-sorted-set 0.1.2
. org.graalvm.nativeimage/svm 21.0.0.2
. org.graalvm.nativeimage/svm-hosted-native-linux-amd64 21.0.0.2
. org.graalvm.nativeimage/svm-hosted-native-darwin-amd64 21.0.0.2
. org.graalvm.nativeimage/svm-hosted-native-windows-amd64 21.0.0.2
. org.graalvm.sdk/graal-sdk 21.0.0.2
. org.graalvm.nativeimage/objectfile 21.0.0.2
. org.graalvm.compiler/compiler 21.0.0.2
. org.graalvm.nativeimage/pointsto 21.0.0.2
. org.graalvm.compiler/compiler 21.0.0.2
. org.graalvm.truffle/truffle-nfi 21.0.0.2
. org.graalvm.truffle/truffle-api 21.0.0.2
. org.graalvm.truffle/truffle-nfi-native-linux-amd64 21.0.0.2
. org.graalvm.truffle/truffle-nfi-native-linux-aarch64 21.0.0.2
. org.graalvm.truffle/truffle-nfi-native-darwin-amd64 21.0.0.2
. org.graalvm.compiler/compiler 21.0.0.2
. org.graalvm.sdk/graal-sdk 21.0.0.2
. org.graalvm.truffle/truffle-api 21.0.0.2
. org.lmdbjava/lmdbjava 0.8.1
. com.github.jnr/jnr-constants 0.9.15
. com.github.jnr/jnr-ffi 2.1.15
. com.github.jnr/jffi 1.2.23
. com.github.jnr/jffi$native 1.2.23
. org.ow2.asm/asm 7.1 :newer-version
. org.ow2.asm/asm-commons 7.1
. org.ow2.asm/asm 7.1
. org.ow2.asm/asm-tree 7.1
. org.ow2.asm/asm-analysis 7.1
. org.ow2.asm/asm-analysis 7.1
. org.ow2.asm/asm-tree 7.1
. org.ow2.asm/asm-tree 7.1
. org.ow2.asm/asm 7.1
. org.ow2.asm/asm-util 7.1
. org.ow2.asm/asm 7.1
. org.ow2.asm/asm-tree 7.1
. org.ow2.asm/asm-analysis 7.1
. com.github.jnr/jnr-a64asm 1.0.0
. com.github.jnr/jnr-x86asm 1.0.2binaryage/devtools 1.0.3
re-frame/re-frame 1.2.0
. reagent/reagent 1.0.0
X cljsjs/react 17.0.1-0 :excluded
X cljsjs/react-dom 17.0.1-0 :excluded
X cljsjs/react-dom-server 17.0.1-0 :excluded
. net.cgrand/macrovich 0.2.1
X org.clojure/tools.logging 1.1.0 :use-top
com.cognitect/transit-clj 1.0.324
. com.cognitect/transit-java 1.0.343
X com.fasterxml.jackson.core/jackson-core 2.8.7 :older-version
. org.msgpack/msgpack 0.6.12
. com.googlecode.json-simple/json-simple 1.1.1
. org.javassist/javassist 3.18.1-GA
X commons-codec/commons-codec 1.10 :older-version
. javax.xml.bind/jaxb-api 2.3.0
nano-id/nano-id 1.0.0
lambdaisland/glogi 1.0.106
org.slf4j/slf4j-api 1.7.30
metosin/reitit-frontend 0.5.13
. metosin/reitit-core 0.5.13
. meta-merge/meta-merge 1.0.0
ch.qos.logback/logback-classic 1.2.3
. ch.qos.logback/logback-core 1.2.3
X org.slf4j/slf4j-api 1.7.25 :use-top
ring/ring-mock 0.4.0
X cheshire/cheshire 5.8.1 :older-version
X ring/ring-codec 1.1.1 :older-version
org.slf4j/log4j-over-slf4j 1.7.30
X org.slf4j/slf4j-api 1.7.30 :use-top
ring/ring-core 1.9.3
. ring/ring-codec 1.1.3 :newer-version
. commons-codec/commons-codec 1.15 :newer-version
. commons-io/commons-io 2.6
. commons-fileupload/commons-fileupload 1.4
X commons-io/commons-io 2.2 :older-version
. crypto-random/crypto-random 1.2.0
X commons-codec/commons-codec 1.6 :older-version
. crypto-equality/crypto-equality 1.0.0
world.convex/convex /Users/pedro/Developer/convex-dev/convex-web/convex.jar
. org.apache.commons/commons-lang3 3.11
http-kit/http-kit 2.5.3.cpcache and 2.12.5 might be broken after too[org.graalvm.js/js "21.1.0"] and [org.graalvm.js/js-scriptengine "21.1.0"]. maybe those fix it too (newer versions than shadow-cljs currently uses)datalevin/datalevin {:mvn/version "0.4.31"
:exclusions [org.graalvm.nativeimage/svm]}
but Daletinv complains about a ClassNotFound.21.0.0.2`Boolean.getBoolean("com.oracle.graalvm.isaot")`?
bb -e '(clojure.pprint/pprint (into {} (System/getProperties)))'
{"babashka.version" "0.4.1-SNAPSHOT",
"org.graalvm.nativeimage.kind" "executable",
"path.separator" ":",
"user.dir" "/Users/borkdude/dre/DocSearch/app",
"java.vm.specification.vendor" "Oracle Corporation",
"java.vendor.url" "",
"java.specification.name" "Java Platform API Specification",
"line.separator" "\n",
"java.vm.version" "GraalVM 21.0.0 Java 11",
"java.vendor" "Oracle Corporation",
"java.specification.vendor" "Oracle Corporation",
"java.vm.specification.version" "11",
"java.io.tmpdir" "/var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/",
"java.class.path" "",
"java.vm.vendor" "Oracle Corporation",
"org.graalvm.nativeimage.imagecode" "runtime",
"java.vm.name" "Substrate VM",
"java.version" "11.0.10",
"os.arch" "amd64",
"user.home" "/Users/borkdude",
"java.specification.version" "11",
"java.ext.dirs" "",
"sun.jnu.encoding" "UTF-8",
"sun.arch.data.model" "64",
"java.class.version" "55.0",
"file.encoding" "UTF-8",
"os.name" "Mac OS X",
"os.version" "10.14.6",
"jdk.lang.Process.launchMechanism" "FORK",
"file.separator" "/",
"java.vm.specification.name" "Java Virtual Machine Specification",
"java.endorsed.dirs" "",
"java.library.path" "",
"user.name" "borkdude"}
"org.graalvm.nativeimage.kind" "executable""org.graalvm.nativeimage.imagecode" "runtime"org.graalvm.js/js {:mvn/version "21.1.0"}, will try to upgrade Shadow CLJS now.21.1.0 fails just downgrade to 20.1.0 which is what 2.12.5 and before usedorg.graalvm.js/js {:mvn/version "20.1.0"}
org.graalvm.js/js-scriptengine {:mvn/version "20.1.0"}Holding Code references in State I am generating the UI, kinda a must to hold it in the state at some point.Uncaught TypeError: Cannot read property 'cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3' of null(>! nil something)shadow-cljs is rather strict about namespace references
dunno, without the linter I wouldn't know half my imports are missing : D(swap! timeouts conj @timeouts ...). remove the @timeouts(fn [] ...)(when-some [msg (<! notification-chan] ... (recur))compile the code as Can't take the value of macro ...path-to-var what do I need to do here?(:require-macros [my.core.ns :refer [macro-var]) in top level(:require-macros [respondent.core]) in a respondent/core.cljs file, it requires the macros from its own namespace. I haven't done it in a .cljc file, but I guess you can just add it to the top there as well for :cljs.#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]]
[respondent.core :refer [behavior]]))
to the top and didnt workundefined for the macro https://github.com/wandersoncferreira/respondent/blob/main/src/respondent/behavior.cljsCan't take value of macro.. .. I tried two things 1) calling my macro inside #js {:behavior (behavior)} export map and it worked! and 2) added (println (identity behavior)) to the code and got the same error Can't take value of macro.... maybe I cannot export macros ?shadow-env but it seemed overly complicated so I assumed there was a simpler (better?) way.:closure-defines would be the build-config driven variant. see also https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configurationjs-waku
https://stackoverflow.com/questions/66309813/the-required-js-dependency-readable-stream-writable-js-is-not-available-it-wareadable-stream as suggested in SO solution
but get another error after that transpilation of BigInt is not supported:compiler-options {:output-feature-set :es2018} in your build config. maybe :es2019 or :es2020. not sure which language level bigints were:es2020 but still no dice 😞
I get failed to convert sources on a whole bunch of libraries:ex-next-in is the highest level possible, maybe that worksjs-waku is written in typeScript with compiler option esnextfailed to convert sources error
npx shadow-cljs watch frontend
shadow-cljs - config: /Users/yalu/Projects/nemonymous/shadow-cljs.edn
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.13.0 running at
shadow-cljs - nREPL server started on port 50869
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/object-assign/index.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.production.min.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.development.js"] [:shadow.build.npm/resource "node_modules/react/index.js"] .............................................RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. null Node(SHEQ): node_modules/bcrypto/lib/native/bn.js:3605:6 if ((y & 1n) === 0n) Parent(IF): node_modules/bcrypto/lib/native/bn.js:3605:2 if ((y & 1n) === 0n)
karma and I get this error:
user:shadow-quagga$ yarn karma start --single-run
yarn run v1.21.1
$ /home/user/work/node_modules/.bin/karma start --single-run
16 05 2021 09:13:28.366:INFO [karma-server]: Karma v6.3.2 server started at
16 05 2021 09:13:28.367:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
16 05 2021 09:13:28.371:INFO [launcher]: Starting browser ChromeHeadless
16 05 2021 09:13:28.623:INFO [Chrome Headless 90.0.4430.212 (Linux x86_64)]: Connected on socket BOp0uUsEZlSbo7HdAAAB with id 30514711
Chrome Headless 90.0.4430.212 (Linux x86_64) ERROR
ReferenceError: test is not defined
at eval (eval at <anonymous> (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:15)
at ContextKarma.start (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7)
at ContextKarma.loaded ()
at :ci {:target :karma
:output-to "out/ci.js"
:ns-regexp "-test$"}karma.conf.js looks like this
// See
module.exports = function(config) {
config.set({
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher', 'karma-junit-reporter'],
basePath: 'out',
// If you need to include custom JavaScript files, put them here.
files: [
// We serve all the JS files via Karma's webserver so that you can
// use :optimizations :none. Only test_suite.js is included because
// CLJS does its own module loading.
'ci.js'
],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ['quagga.runner-test.run'],
singleRun: true
},
// If you don't like the progress reporter, you could try 'dots'
reporters: ['progress', 'junit'],
// If you want to use other browsers, you need to install the launchers
// for them! E.g. npm install --save-dev karma-firefofx-launcher
browsers: ['ChromeHeadless'],
reportSlowerThan: 500, // ms
// We disable autoWatch, because it executes tests while the code is
// still comiling. We use :notify-command to trigger them instead.
autoWatch: false,
// Configuration for JUnit output. We care only about the output directory.
// This directory is relative to basePath, so the XML files will be
// in `target/out/reports`.
// <>
junitReporter: {
outputDir: 'reports'
}
});
}quagga.runner-test namespace I have a run function that looks like this
(defn ^:export run [karma] (karma/run-tests karma 'quagga.events-test))
quagga.events-test namespace
(ns quagga.events-test
(:require [cljs.test :refer-macros [deftest is testing run-tests]]))
(deftest first-test
(testing "hello world test"
(is (= 1 1))))_ was expected where I placed a -quagga.runner-test.run means quagga.runner MINUS test.runcljfmt with shadow-cljs.edn . Any tips?shadow-cljs run cljfmt.main{:target :node-library
:compiler-options {:infer-externs :auto}
:devtools {:repl-timeout 100000}:repl-timeout only controls how long shadow will wait for an result of a repl evaluationnode-repl is standalone, it is NOT controlled by any build configshadow-cljs cljs-repl node (assuming :node is the build id)shadow-cljs watch app --verbose--verbose and see if it helpsdeftest and friends in compilation process? I know I can use another target, but I'm doing some weird things and I want to control how to run specific tests so I'm using a target :node-script 😄:load-tests true on :compiler-options)shadow-cljs release app?:require in your namespaces. having extra :dependencies does not matter when they are not required in your build directly. generate a build report to see what ended up in your build and why https://shadow-cljs.github.io/docs/UsersGuide.html#build-report:module-hash-names?
<script src="/js/base.js"></script> tag already:asset-path + the module name:asset-path? what is your script src? and what is your :build-hooks config?src/index.html file that contains <script _src_="js/compiled/main.js" _type_="text/javascript"></script> tag. I have shadow-cljs.edn that has
:frontend
{:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
;; :compiler-options {
;; ;; add env vars
;; }
:build-hooks [(shadow-env.core/hook)
(shadow.html/copy-file
"public/src/index.html"
"public/index.html")]
:module-hash-names true
;; ;; :fingerprint true
;; :build-options {:manifest-name "manifest.json"}
:modules {:main
{:init-fn mytherapy.core/init!}}
;; :compiler-options {:externs ["public/js/plugins/"]}
}:asset-path "/js/compiled" but use script src="js/compiled/main.js"(not (= "/js/compiled" "js/compiled)) type of match?<script _src_="/js/compiled/main.js" _type_="text/javascript"></script> and :output-dir "public/js/compiled" and :asset-path "/js/compiled" they do not seem to affect the behaviour:asset-path "/js/compiled" and script src="/js/compiled/main.js":externs but i'm trying to add it to the dep (via deps.cljs in that jar) so that other projects can get it for free... but it isn't getting picked up that way. anyone know if this does or doesn't work? versions to use? pointers on debugging?{:externs ["file.js"]} is enough... or does it need foreign-libs to work? (from a jarred deps.cljs)"~:resources"), but the "~:externs" is just [] ... there aren't any other files in it though... it looks like it's treating it as a js module:externs^js hints when needed. that works in everything and is easier to maintain.--config-merge '{:closure-define { secretkey "s1234"}#shadow/env work for thisviews.cljs:328 Uncaught TypeError: module$node_modules$$yaireo$tagify$dist$tagify_min.default is not a constructor
at cmp.eval (views.cljs:328)
at cmp.reagent$impl$component$custom_wrapper_$_componentDidMount [as componentDidMount] (component.cljs:207)
at commitLifeCycles (react-dom.development.js:20664)
at commitLayoutEffects (react-dom.development.js:23427)
at HTMLUnknownElement.callCallback (react-dom.development.js:3946)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:3995)
at invokeGuardedCallback (react-dom.development.js:4057)
at commitRootImpl (react-dom.development.js:23152)
at exports.unstable_runWithPriority (scheduler.development.js:469)
at runWithPriority$1 (react-dom.development.js:11277)["@yaireo/tagify" :as Tagify]import Tagify from '@yaireo/tagify'(Tagify. html-input-element)["@yaireo/tagify" :as Tagify] does NOT correspond to import Tagify from '@yaireo/tagify'["@yaireo/tagify" :default Tagify]?:as. see the section about default exports in the link above["@yaireo/tagify/dist/react.tagify" :default Tagify]tagify with React that I didn't know aboutUncaught TypeError: Cra.initializeApp is not a function
Jra
<anonymous>
onload shadow-cljs watch appinitializeApp or what on?shadow-cljs release app --debugmaterial-ui library to my project. This specific library might be an overkill, really - I just knew that a friend of mine was using it on his project, so I wanted to try it. It's likely I'll not end up using it in the end.
Importing the library to my project was easy. But suddenly, even a tiny change in some label inside my namespace resulted in 5-6s compile time instead of sub-1s. No matter how tiny the change was. Would splitting my namespaces into more modules (such as :shared shown in user manual) help here? Or is there any other way of improving the compilation performance?:modules won't do anything regarding performance)(r/adapt-react-class to make react class adapters.npm install. that modifies a lot of files and sometimes shadow-cljs gets out of sync with that.shadow-cljs/builds but that usually does nothing. restart is enough.["@material-ui/core" :as mc], it's fine, but once I also add ["@material-ui/icons" :as mi] , the slowness starts.➜ myproject git:(master) ✗ find node_modules/@material-ui/icons -type f | wc -l 16674 ➜ myproject git:(master) ✗ du -sh node_modules/@material-ui/icons 201M node_modules/@material-ui/icons
(:require ["@material-ui/icons/ZoomIn" :default ZoomIn]) instead of (:require ["@material-ui/icons" :refer (ZoomIn)])shadow.loader do I still need to use cljs.loader/set-loaded! in my modules?(loaded? "module-name") to avoid loading modules more than once?shadow.lazy for everything. much simpler interface. either directly or with a wrapper as described here https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.htmlshadow.lazy, I’ll take a look at the article. Thanks for the pointer.shadow.lazy documented somewhere? I don’t see it mentioned on the Users Guidelein new reagent-frontend generatesshadow-cljs pom to generate it or created the project via project.clj (from lein) but didn't configure the shadow-cljs dependency theremonaco-editor into a chrome extension?
https://github.com/suren-atoyan/monaco-loader#config:dev-http {3000 "public"} the same as :builds {:app {:devtools {:http-root "public" :http-port 3000}}} ?cp -R node_modules/monaco-editor/** shells/chrome/lib/monaco-editor 😅:web_accessible_resources ["lib/*"] but that doesn't seem to do anything for me:dev-http. the http stuff in :devtools has been deprecated for a couple years now, not going to remove it but it is the old styleimport unified from 'unified';
import parse from 'uniorg-parse';
import uniorg2rehype from 'uniorg-rehype';
import extractKeywords from 'uniorg-extract-keywords';
import html from 'rehype-stringify';
import { toVFile } from 'to-vfile';
unified()
.use(parse)
.use(extractKeywords)
.use(uniorg2rehype)
.use(html)
.process(toVFile.readSync('src/posts/example.org'), function(err, file) {
console.log(file);
})
Now I’m trying to use the same libraries in clojurescript, and it doesn’t work at all.
(ns app.parser
(:require ["unified" :as unified]
["uniorg-parse" :as parse]
["uniorg-extract-keywords" :as extract-keywords]
["uniorg-rehype" :as uniorg2rehype]
["rehype-stringify" :as html]
["fs" :as fs]
["to-vfile" :refer (toVFile)]
[cljs-node-io.core :as io]))
(->
(unified)
(.use parse)
(.use extract-keywords)
(.use uniorg2rehype)
(.use html)
(.process (.readSync toVFile "src/posts/example.org")
(fn [err file]
(js/console.log file))))
When I run it I get errors like this:
app.parser => (-> (unified) (.use parse) (.use extract-keywords) (.use uniorg2rehype) (.use html) (.process (.readSync toVFile "src/posts/example.org") (fn [err file] (js/console.log file)))) Execution error (TypeError) at (<cljs repl>:1). Cannot read property 'readSync' of undefined :repl/exception! app.parser => (-> (unified) (.use parse) (.use extract-keywords) (.use uniorg2rehype) (.use html) (.process (toVFile "src/posts/example.org") (fn [err file] (js/console.log file)))) Execution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$to_vfile.toVFile is not a function :repl/exception!Mind you, I looked at the source of
to-vfile. It does in fact export the function toVFile. What could be going on here?(require '["to-vfile" :as x]) and x?(.. x (-toVFile) (readSync "src/posts/example.org"))app.parser> (require '["to-vfile" :as x])
nil
app.parser> x
#js {}
app.parser> (.. x (-toVFile) (readSync "src/posts/example.org")) Execution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$to_vfile._toVFile is not a function :repl/exception!
(js/require "to-vfile")?app.parser> (js/require "to-vfile") Execution error (Error) at (<cljs repl>:1). Must use import to load ES Module: /Users/main/Code/web/mysite/node_modules/to-vfile/index.js require() of ES modules is not supported. require() of /Users/main/Code/web/mysite/node_modules/to-vfile/index.js from /Users/main/Code/web/mysite/[stdin] is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/main/Code/web/mysite/node_modules/to-vfile/package.json. :repl/exception!
toVFile is so clearly a function.require to load npm stuff, can't remember if there was something you are supposed to set to enable thatimported instead of required.
From the https://github.com/vfile/to-vfile page for to-vfile.require then I need to either do a workaround or help fix shadow to add support for this.:target :esm https://clojureverse.org/t/generating-es-modules-browser-deno/6116:target :esm currently defaults to trying to bundle all dependencies, but there is :js-options {:keep-as-import #{"fs" "to-vfile" ...}} for stuff it shouldn't bundle(require '["to-vfile" :as x]), that just does a js/require under the hood207 | (def ui-player (comp/factory Player {:keyfn :player/id}))
-----------^--------------------------------------------------------------------
ui-player at line 207 is being replaced
? What is it being replaced by, where? (I have couple more def ui-player in this file but all precede this one and all are inside (comment ...) 🙏 Thank you!!!parser.js.
All I want really is to call the functions in the script from cljs, that way I can also debug the script somewhat interactively.
. ├── LICENSE ├── README.md ├── deps.edn ├── package.json ├── postcss.config.js ├── shadow-cljs.edn ├── src │ ├── app │ │ ├── components.cljs │ │ ├── core.cljs │ │ ├── data.cljs │ │ ├── index.clj │ │ └── parser.js │ ├── config │ │ └── site-data.edn │ ├── css │ │ ├── 404.css │ │ ├── main.css │ │ └── tailwind.css │ ├── lib │ └── posts │ ├── │ ├── │ ├── │ ├── blog-posts.edn │ └── ├── tailwind.config.js ├── yarn-error.log └── yarn.lock
shadow-cljs check the-build but that is very noisy:node-script you have :output-to "out/script.js" and :output-dir "out". you somehow make the out directory available on the pi and run it there via node script.js or so:devtools {:devtools-url ""} in your build confignode-repl that will run on the dev boxout directory(shadow/watch-set-autobuild! :the-build false) and then trigger a compile via (shadow/watch-compile! :the-build).js/Keycloak? if this is just for your code and not a public library then put the shim file onto your classpath. no need for it to be in shadow-cljsjs(:require ["keycloak-js" :as keycloak-js] in your code and use keycloak-js instead of js/Keycloak?(:require ["keycloak-js" :as keycloak-js]) works great for me. If you have any specific questions about it I'd be glad to answer them.(shadow/repl :app). Can I set this up to run that command by default when I connect to the remote repl?shadow-cljs watch app :
11:22 $ shadow-cljs watch app
------------------------------------------------------------------------------
WARNING: shadow-cljs not installed in project.
See
------------------------------------------------------------------------------
shadow-cljs - config: /Users/rqf595/Code/louis-hjelmslev/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------
This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.
You are using shadow-cljs version: 2.14.0
The important dependencies are:
org.clojure/clojure "1.10.3"
org.clojure/clojurescript "1.10.866"
com.google.javascript/closure-compiler-unshaded "v20210505"
Please verify that you are loading these versions.
You can find all required dependencies here:
Please refer to the Guide for more information:
-----------------------------------------------------
The error encountered was:
Syntax error macroexpanding at (closure.clj:78:5).
at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1742)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
at clojure.lang.Compiler.eval(Compiler.java:7186)
at clojure.lang.Compiler.load(Compiler.java:7640)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6856.invoke(core.clj:6115)
at clojure.core$load.invokeStatic(core.clj:6114)
at clojure.core$load.doInvoke(core.clj:6098)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5897)
at clojure.core$load_one.invoke(core.clj:5892)
at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
at clojure.core$load_lib.invokeStatic(core.clj:5936)
at clojure.core$load_lib.doInvoke(core.clj:5917)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$load_libs.invokeStatic(core.clj:5974)
at clojure.core$load_libs.doInvoke(core.clj:5958)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$require.invokeStatic(core.clj:5996)
at clojure.core$require.doInvoke(core.clj:5996)
at clojure.lang.RestFn.invoke(RestFn.java:551)
at shadow.build.js_support$eval11454$loading__6737__auto____11455.invoke(js_support.clj:1)
at shadow.build.js_support$eval11454.invokeStatic(js_support.clj:1)
at shadow.build.js_support$eval11454.invoke(js_support.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7181)
at clojure.lang.Compiler.eval(Compiler.java:7170)
...
...
...
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:40)
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:257)
...
...
...
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1735)
... 211 more
guavacom.google.common.collect.* is a guava packagedeps.edn :deps? might make sense to move them to a :server alias or soWARNING: shadow-cljs not installed in project. Seedoesn’t seem to lead anywhere (the #project-install part specifically).
ws for node builds or node-libs-browser for browser polyfills. can work without but may fail.(cljs.analyzer/resolve-var env sym nil false) triggers an error :
> Wrong number of args (2) passed to: shadow.build.cljs-hacks/shadow-resolve-var
Is this a known bug, is there a workaround or a better way ?:target :karma is used? Now I am getting
“Uncaught Error: shadow.loader API was called before shadow.loader.init!
You are probably calling module loader too early before shadow-cljs got fully initialized.”shadow.loader.init(""); somehow to the output, but have no idea how to do that properly:browser-test and only adding `
:module-loader truewas enough, without specifying modules. Also I’m requiring the namespace which should be loaded in tests directly, so maybe it is a reason why they are not failing
shadow.loader. otherwise you wouldn't get that error.:browser-test you can set :module-loader since it is built on the :browser target. :karma is not so that won't work there:browser-test still won't be able to actually use the shadow.loader api in any wayshadow.lazy/loadable is used in the function I’m testing that’s why error happens inside :karma while working fine inside :browser-test
I’ll open an issue in GitHub and will try to find some workaround in meanwhile. I think it would be nice to have some recipe to run tests when shadow.lazy is used inside(function () {
goog.global.shadow$modules = {infos: {test: null}, uris: {test: []}}
shadow.loader.init("");
})();
to karma.conf.js -> files(ns my.app-spec
(:require
[cljs.test :as ct :refer [deftest is]]
[shadow.loader :as sl]
[ :as app]
[my.core]))
(ct/use-fixtures :once
(fn [test]
(sl/init "")
(test)))
may also workmy.core), lazy loader works fine, so I think here is only a matter of not failing :karma target when modules are usedwith-redefs can be used somehow to stub parts of the lazy loaded namespaces in case we don’t want to require them explicitly❯ node_modules/.bin/shadow-cljs watch webapp shadow-cljs - config: /Users/wcalderipe/dev/foo-project/shadow-cljs.edn shadow-cljs - updating dependencies # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (sharedRuntime.cpp:531), pid=17169, tid=5635 # Error: ShouldNotReachHere() # # JRE version: OpenJDK Runtime Environment (16.0+14) (build 16+14) # Java VM: OpenJDK 64-Bit Server VM (16+14, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64) # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /Users/wcalderipe/dev/foo-project/hs_err_pid17169.log # # If you would like to submit a bug report, please visit: # # ===== ERROR ================= ENOENT: no such file or directory, open '/Users/wcalderipe/dev/foo-project/.shadow-cljs/classpath.edn' =============================os
macOS 11.4 (20F71)
shadow-cljs: 2.11.11
java
openjdk version "16" 2021-03-16 OpenJDK Runtime Environment (build 16+14) OpenJDK 64-Bit Server VM (build 16+14, mixed mode)
clj on the terminal. definitely not related to shadow-cljsjs/ for thisjs/ is for accessing global variables(:require [cljs-bean.core :refer [->clj ->js bean]]
;["firebase/app"]
;["firebase"]
;["firebase" :as firebase]
;["@firebase/app" :refer (firebase)]
{:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:nrepl {:port 7002
:middleware []}
:builds {:test {:target :browser-test
:test-dir "resources/public/js/test"
:ns-regexp "event2-test$"
;:runner-ns tests.client-test-main
:devtools {:http-port 8021
:http-root "resources/public/js/test"}}
:app { :git-inject {:version-pattern "^v/(.*)$"
:ignore-dirty? true}
:target :browser
:build-hooks [(shadow-git-inject.core/hook)]
:compiler-options {:closure-defines {app.system.config/version :shadow-git-inject/version}}
:output-dir "resources/app/js"
:asset-path "/js"
:module-hash-names 4
:modules {:main {:init-fn app.core/init!}}
:dev {:dependencies [#_[day8.re-frame/tracing-stubs "0.5.1"]]
:compiler-options {#_#_:output-feature-set :es6
:closure-defines {app.system.config/version :shadow-git-inject/version
app.system.config/build-time :shadow-git-inject/build-iso-date-time
"re_frame.trace.trace_enabled_QMARK_" true}}}
:release {:output-dir "resources/dist/js"
:compiler-options {#_#_:output-feature-set :es6
:closure-defines {app.system.config/version :shadow-git-inject/version
app.system.config/build-time :shadow-git-inject/build-iso-date-time}
:optimizations :simple
:infer-externs :auto}}
:devtools {;:preloads [day8.re-frame-10x.preload]
:after-load app.core/reload!
:http-port 8050
:http-root "resources/app"
:watch-dir "resources/app"}}}}
{:paths ["src/cljs"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.10.866"}
org.clojure/core.async {:mvn/version "1.3.610"}
thheller/shadow-cljs {:mvn/version "2.14.1"}
com.taoensso/timbre {:mvn/version "5.1.0"}
#_#_com.schpaa/schpaa {:mvn/version "0.2.0-SNAPSHOT"}
expound {:mvn/version "0.8.9"}
reagent {:mvn/version "1.0.0"}
re-frame {:mvn/version "1.1.2"}
kee-frame {:mvn/version "1.1.2"}
cljs-bean {:mvn/version "1.6.0"}
fork {:mvn/version "2.4.0"}
vlad {:mvn/version "3.3.2"}
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
thedavidmeister/cljs-i18n {:mvn/version "0.4.0"}
arco {:mvn/version "0.3.4"}
fipp {:mvn/version "0.6.23"}
mvxcvi/puget {:mvn/version "1.3.1"}
markdown-to-hiccup {:mvn/version "0.6.2"}
markdown-clj {:mvn/version "1.10.5"}
medley {:mvn/version "1.3.0"}
nrepl {:mvn/version "0.8.3"}
day8/shadow-git-inject {:mvn/version "0.0.4"}
;for codemirror
#_#_applied-science/js-interop {:mvn/version "0.2.5"}}
:aliases {:carve
{:extra-deps {borkdude/carve {:git/url ""
:sha "$LATEST_CARVE_SHA"}}
:main-opts ["-m" "carve.main"]}
:dev
{:extra-paths ["src/dev"]
:extra-deps {;nubank/workspaces {:mvn/version "1.0.15"}
;day8.re-frame/re-frame-10x {:mvn/version "1.0.2"}
;org.clojure/clojurescript {:mvn/version "1.10.773"}
binaryage/devtools {:mvn/version "1.0.2"}}}}}{
"dependencies": {
"create-react-class": "^15.7.0",
"firebase": "^8.6.2",
"firebase-auth": "^0.1.2",
"highlight.js": "10.7.1",
"image-conversion": "^2.1.1",
"marked": "^0.7.0",
"process": "^0.11.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-firebaseui": "^5.0.2",
"react-highlight.js": "1.0.7",
"react-virtualized": "^9.22.2"
},
"devDependencies": {
"highlight.js": "9.18.1",
"react-highlight.js": "1.0.7"
}
}npm install shadow-cljs maybenpm install shadow-cljs. so you don't rely on some global installmain.js:1552 TypeError: module$node_modules$firebase$app$dist$index_esm.initializeApp is not a function
at $system$database$core$init_BANG_ [as init_BANG_] (core.cljs:71)
at $core$init_BANG_ [as init_BANG_] (core.cljs:33)
at eval (shadow.module.main.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:486)
at Object.env.evalLoad (main.js:1549)
at main.js:2040["firebase/app" :as firebase] try ["firebase/app$default" :as firebase]import firebase from 'firebase';
["firebase" :default firebase] OR the new official variant ["firebase$default" :as firebase]env.evalLoad @ main.js:1551
(anonymous) @ main.js:1930
main.js:1552 RangeError: Maximum call stack size exceeded
at Object.eval [as cljs$core$ILookup$_lookup$arity$2] (core.cljs:6851)
at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:1959)
at Object.cljs$core$print_meta_QMARK_ [as print_meta_QMARK_] (core.cljs:10236)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10246)
at cljs$core$pr_writer (core.cljs:10339)
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (core.cljs:10191)
at Object.eval [as cljs$core$IPrintWithWriter$_pr_writer$arity$3] (core.cljs:692)
at Object.cljs$core$_pr_writer [as _pr_writer] (core.cljs:778)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10257)
at cljs$core$pr_writer (core.cljs:10339)(-> firebase .-app)
(js/console.log (-> firebase .-app)) should be ok, or tap> and the Inspect UI (probably rather limited, so use console) anywhere but the initializeApp I believe is the first thing you are supposed to call(defn ^:export init! []
(defn init! []
(log/info "widd/init!")
(reset! app (if (zero? (count (.-apps firebase)))
(-> firebase
(.initializeApp (->js appinfo-vakt)))
(.-app firebase)))
(when goog.DEBUG
(-> firebase
.database
(.useEmulator "localhost" 10008))
(-> firebase
.firestore
(.useEmulator "localhost" 10009))))@cljs.env/*compiler*, I think just [:options :closure-defines] but not sure:default, more here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports. that is a shadow-cljs only thing that was rejected from CLJS, instead it added the $default thing in the recent release. see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces$ really is just sugar for accessing properties directly, ["firebase" :as firebase] and firebase/default is also valid.require(‘firebase’).default variant, as does "firebase$default"deps.edn. I just tried to add nextjournal.clojure-mode and shadow-cljs on dependencies, configured a simple browser app, but I'm seeing the following error on console:
cljs$core$ExceptionInfo {message: "failed to encode relay msg", data: {…}, cause: null, name: "Error", description: undefined, …}
eval @ shared.cljs:229
eval @ shared.cljs:229
shadow$remote$runtime$api$relay_msg @ api.cljc:4
...2.12.7, the error is gone and the browser can connect to the running instance:devtools {:loader-mode :script} for the initial page load. for the REPL itself no, that always uses eval.[:div {:class "px-4 py-2 md:px-6"}] etc?git describe based version information derived at build time to be available as variable at runtime? I was thinking about using :closure-defines and #shadow/env together with a shell script… and was wondering if there is a more straight forward way? I’d like to have a git based version string to show in the app. The environment react-native. Android build.gradle and iOS Info.plist integration would be the icing on the cake but not mandatory 😉git describe from clojure at build time and you could include that information in the expanded code:infer-warnings popped up for code with js interop with npm modules. 2.13.0 can still correctly infer them and compile without those warnings"prosemirror-transform": "^1.2.8", "prosemirror-state": "1.3.3"this
(ns foo (:require ["prosemirror-state"])) (defn apply-tr [tr] (.getMeta tr nil))compiles without a warning with 2.13.0, but produces this warning with 2.14.0
2 | (:require ["prosemirror-state"])) 3 | 4 | (defn apply-tr [tr] 5 | (.getMeta tr nil)) ---------^---------------------------------------------------------------------- Cannot infer target type in expression (. tr getMeta nil)
some/thing.cljs to some\\thing.cljs. which wouldn't matter except that it breaks source maps and the build report. super fun time trying to figure out why and when that changed ... :face_vomiting:resources/public somewhere and that your link tags in the HTML use absolute pathsresources/public/whatever/foo.css would be /whatever/foo.css in the HTML:devtools-url "". don't know why you are doing that:watch-path "/foo" option (prefix)dev.local and the CSS reloading doesn't work. Then I go to dev.local:3449 and although I cannot reach my backend the frontend loads and then if I make a change to my css, it reloads correctly. Then finally, if I go back to dev.local again, the css loading works (with or without /css/style.css)./css/style.css in my html but shadow-cljs seems to be picking up my dynamic include. I can work around this as long as I visit :3449 first.~/.shadow-cljs/config.edn :js-options {:preferred-display-type :pprint}:infer-externs defaults to true, but I think it should say :auto now instead?import xlsx from 'node-xlsx';translated to this (https://shadow-cljs.github.io/docs/UsersGuide.html#npm)
["node-xlsx" :default xlsx]With this approach
xlsx is nil. With other approaches it returns an empty object but nothing that contains the build method mentioned in https://www.npmjs.com/package/node-xlsx:as instead of :default (as per 2nd paragraph in https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports)(.-build xlsx) => nil(js/require "node-xlsx"), there seem to some newer ESM only node packages that only work with import. those are not yet supported.// Or var xlsx = require('node-xlsx').default; example so should be fine?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9df3f2f9f8b0f0f2f9e8f1f8eeddf9fcf4f1e4b0fef2"}, :content ("[email protected]")} I first tried out doing the explicit file import as part of the require:
(:require ["@daily-co/daily-js/dist/daily-iframe-esm.js" :default DailyIframe])to see which one worked and then moved it into shadow-cljs:
:js-options
{:resolve {"@daily-co/daily-js" {:target :npm
:require "@daily-co/daily-js/dist/daily-iframe-esm.js"}}}
as per https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm(:require ["node-xlsx" :as xlsx]) so the basic import is working(:require ["node-xlsx" :as xlsx]) (js/console.log "XLSX: " (.-build xlsx))Produces the following in the console:
XLSX: λ[]
jsƒ (worksheets,options)
Using :default instead of :as works the same for me.unreachable code warnings when releasing? Seems it is not coming from cljs.analyzer/*cljs-warnings* as for example :warnings-as-errors true has no effect on it 🙂:compiler-options {:closure-warnings {:unreachable-code :off}}?[:front] Compiling ...
{:type :shadow.build.closure/invalid-closure-warning, :key :check-useless-code, :level :off, :shadow.build.log/level :warn}
and the warning is still printed :thinking_face:
build release config is:
:release {:compiler-options
{:warnings-as-errors true
:closure-warnings {:check-useless-code :off}}}
At least the ClojureScript docs says that :check-useless-code should be available. Hmm..:lein true and [thheller/shadow-cljs "2.14.1"] & [org.clojure/clojurescript "1.10.866"] , i will check the sources tomorrow unless you don’t have any idea from the top of your head, thx :thumbsup::useless-code or :uselessCode(DiagnosticGroups/getRegisteredGroups) and found from there that it is nowadays "uselessCode" -> :useless-code(empty-state) is missing cljs.core because when I eval (+ 1 1) I get
WARNING: Use of undeclared Var cljs.user/+ at line 1but when I clone the repo used in the example (which uses figwheel) it’s working, so just wondering if there is some compiler setting I might need
:dev-http with :ssl. The build is succesfull, and shadow-cljs logs “HTTP server available at https://localhost:3000”. I get curl: (35) error:14004410:SSL routines:CONNECT_CR_SRVR_HELLO:sslv3 alert handshake failure. My shadow-cljs.edn file looks like this:
{:dependencies [[reagent "1.0.0"]
[re-frame "1.2.0"]]
:source-paths ["src"]
:nrepl {:port 4444}
:ssl {}
:dev-http {3000 "public"}
:builds
{:app {:target :browser
:output-dir "public"
:asset-path "/"
:modules {:app {:init-fn hello.core/init}}}}}
Am I missing something?keytoolinvocation, I should just RTFM I guess - sorry:)'gen/Button.js'
...
import React from 'react';
export const Button = ({
primary = false,
label,
...props
}) => {
const mode = primary ? "text-primary" : "dark:text-white";
return /*#__PURE__*/React.createElement("button", _extends({
className: "font-extralight " + mode
}, props), label);
};
But this fails
import React from 'react';
import { Button } from './Button.js';
export const Header = ({
onCreateAccount
}) => /*#__PURE__*/React.createElement("header", null, /*#__PURE__*/React.createElement("div", {
className: "wrapper"
}, /*#__PURE__*/React.createElement(Button, {
primary: true,
size: "small",
onClick: onCreateAccount,
label: "Sign up"
})));
with the error
Header.js:8 Uncaught ReferenceError: Button$$module$gen$Button is not definedThis is all the cljs needed to cause the error
(:require ["../gen/Header.js" :refer (Header)])It all works from a JS project FWIW
babel --plugins @babel/plugin-transform-react-jsx src/components --out-dir src/gen --watch are here https://github.com/armincerf/clojurescript-serverless-framework/tree/build-failure-requiring-js-file/src/gen"rewrites": [
{
"source": "/",
"destination": "/index.html"
}, {
"source": "**",
"destination": "/trade.html"
}
]
So http://www.mysite.com/foo/bar rewrites to /trade.html on firebase but not in localhost. Any suggestions for how to fix this would be greatly appreciated!firebase emulators:start as opposed to
shadow-cljs watch app
:npm-module build? Such that I can get a URL to use in eg. an [:img {:src image-url}]?
I'm thinking of something like the Webpack(?) bundler(?) that lets one import { default as myImageUrl } from './my-image.png'; in Javascript.:target :storybook that outputs everything exactly in the format storybook wants but so far not too many people use storybook it seemsTypeError: Cannot read property 'CLOSURE_UNCOMPILED_DEFINES' of undefined
:target :storybook could make easier?:target :npm-module also supports :ns-regexp "stories$" so you don't have to list all :entries manually{:target :npm-module
:ns-regexp "stories$"
:output-dir "public/js/stories"}:target :storybook 😁 Sounded good to me. I have seen a few stabs at getting a minimal usage, I haven't had a chance to really dive into it yet.
But my interest is to use it as a way to document our internal UI Components and evolve to a design system. Ideally with the ability to leverage other things going on in the Storybook world (which may or may not really be possible if there are a lot of assumptions about having JS code be the main underlying "glue":target :storybook could do. there could be one if it was more complicated but it doesn't seem to be. I don't use storybook so no clue where the problems arerepl-load-file* thow exception that the file is not in class paththrow with an impl that supports files outside the classpath https://github.com/thheller/shadow-cljs/blob/e6c7d36dc4a870c0b64286e0b590e69c06c63d43/src/main/shadow/cljs/repl.clj#L2942.14.3script tag in another shadow-cljs project. The problem I am facing is that it seems that a shadow$provide global variable is created for each build, and because of this, the second variable overwrites the first one producing a Module not provided.
I've tried the :browser and the :node-library targets and both of them seem to have the same problem. What is the best way to get around this?cljs.core and all other dependencies leading to a lot of bloat. they also won't be compatible with each other and can't exchange CLJS datastructures. ideally make the library part of the compilation of the second one, like any other CLJS libs.shadow$provide more that doesn't fix all the other problems you'd have.:target :node-library or :target :npm-module, those by default don't bundle JS dependencies, only compiled CLJS codenpm publish:entries key is a list of clojurescript namespaces to include in the npm package?watch as in observe when the file changes yesprintf formatting in Clojurescript? I see posts on the web suggesting using goog.string.format but there are other posts discussing dead code elimination issues with that library. I have a minimal test app with
(ns stopwatch (:require [goog.string :as gs])) (println (gs/format "Hello %s" "world"))that works with shadow-cljs when building without optimizations. But if I use
:simple or :advanced, I get a runtime failure because goog.string is missing format.[goog.string.format] to your :require then it'll work. it lives in its own file/namespace so just importing goog.string is not enoughgoog.string/format or will I run into this with other APIs when I create release builds? I though the build system would automatically include all the transitive dependencies of the functions I refer to.goog.string.format just happens to be this special case that it is a separate namespace, not part of goog.string.["react-dates/initialize" :as init] ["react-dates" :as rd :refer [DateRangePicker SingleDatePicker DayPickerRangeController]]
(def DateRangePickerX (r/adapt-react-class DateRangePicker))or
[:> DateRangePicker.. but not really work..body {
margin: 0;
padding: 0;
font-family: sans-serif;
}deps.cljs in src, but including the dependency from clojars in a shadow project elsewhere didn't seem to install them.deps.cljs file actually included with the jar? what is the clojars lib?deps.cljs with {:npm-deps {"foo" "version"}} is the correct waysrc/deps.cljs in your casereact.development.js:316 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.:js-package-dirsdeps.cljs:js-packages-dirs ["node_modules" "bower_modules"] IIRC bower used that dir?name in package.json and npm publish:global-exports entry that will make this package compatible with shadow-cljs. but the boot task in cljsjs needs a map of sym=>sym for its :global-exports value. what should the value be here?
:global-exports '{"@sicmutils/mathbox2" MathBox
cljsjs.mathbox2 MathBox}@ symbol... but I don't want to stomp the global mathbox2 name, for when the original author pushes this out(:require ["@sicmutils/mathbox2" :as x]) not work?$ lein dev OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. shadow-cljs - config: /Users/ghaskins/sandbox/git/mcp-login-ui/shadow-cljs.edn shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. running: npm install --no-save
deps.cljs file with :npm-deps listedshadow-cljs.edn but thats about it. maybe the other project has older dependencies that didn't yet have deps.cljs?deps.cljs. many libs didn't do that for a while but nowadays most doimport 'leaflet/dist/leaflet.css'; from https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I understand it should be (:require ["leaflet/dist/leaflet.css"]) ? But think I'm doing something wrongnode_modules/leaflet/dist/leaflet.css to your public folder and include itnpm install for stuff listed in your package.json. that you have to do yourselfnpm install then they won't be installednpm install you'll need at leastshadow-cljs watch appdo?
shadow-cljs stop should shut it down completely:deps key in there then dependencies need to be added in deps.edn. if there is a :lein then it would be project.clj.shadow-cljs pomand re-imported the project in ide, which worked out.
resources/public/css/app.css, what path do I put in {:devtools {:watch-dir "???"}} option?resources/public assuming the file is accessed via /css/app.css in your htmlwatch for this to take effecttouch resources/public/css/app.css but not rebuild happenedlink tag you use to include it?resources/public/css/app.css is the OUTPUT file produced by postcss, not the input?<link href="/css/app.css" rel="stylesheet" type="text/css">:watch-dir will cause shadow to watch that directory and notify about file updates. the client will look for CSS matches by path and reload if foundload CSS message from shadow-cljs but css didn't update then your server likely caches stuff and didn't return the "new" versionload CSS shows up then it didn't match the paths properly(defn my-fn [x] (do-stuff-with-x)) that gets sent the method toString by some library code. How can I guarantee that toString returns the same value for every build? (I think toString is returning different values because advanced compilation is renaming the function).toString on a function?myFn.toString():advanced, at least as far as I'm aware:advanced or even :simple is never guaranteed to stay identical(defn ^:export my-fn [x] ...) and as .filter you use (js/Function. "function filterMe(x) { return _fn(x); }") 😛(js/Function. "x" "return _fn(x);"), can't remember precisely{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3253425b4b5d7253425b4b5d1f665a5b5c59625356"}, :content ("[email protected]")}{:app {:asset-path "/js/quagga"
:modules {:shared
{:entries []}
:organization
{:entries [quagga.components.organization.init]
:depends-on #{:shared}}
:home
{:entries [quagga.components.home.init]
:depends-on #{:shared}}
...}
:output-dir "resources/public/js/quagga/"
:target :browser
:devtools {:devtools-url ""}}:devtools option{:devtools-url ""}/shadow-cljs path that proxies requests to http://localhost:9630?:devtools-url at all assuming shadow-cljs is reachable on that location. you can test by just opening it in the browser, you should get the UI:devtools-url{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfdecfd6c6d0ffdecfd6c6d092ebd7d6d1d4efdedb"}, :content ("[email protected]")}shadow-cljs browser-repl instead. that'll open a browser on its own.shadow-cljs watch app already@react-three/drei library. When I require it ["@react-three/drei" :refer [Sky Environment]], I get this error:
Closure compilation failed with 2 errors --- node_modules/three-stdlib/index.cjs.js:2 Illegal variable reference before declaration: i --- node_modules/three-stdlib/index.cjs.js:2 Illegal variable reference before declaration: tI've tried a couple of
:js-options options did not work out:
{:js-provider :shadow
:keep-native-requires true
:output-feature-set :es6
:closure-output-charset "ascii"}
Here is my package.json:
"@pmndrs/branding": "^0.0.8", "@react-three/cannon": "2.1.2", "@react-three/drei": "6.0.2", "@react-three/fiber": "7.0.1", "@react-three/postprocessing": "2.0.4", "@types/three": "0.129.1", "lodash-es": "^4.17.21", "react": "^17.0.2", "react-dom": "^17.0.2", "three": "0.129.0",Any suggestions?
:default in :require that shadow-cljs enables. Does anyone know a way to tell codox to allow it? The error is:
Caused by: clojure.lang.ExceptionInfo: Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: ["react-bootstrap-table2-editor" :default cellEditFactory] at line 1 file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs {:file #object[java.net.URL 0x1835b24b "file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs"], :line 1, :column 1, :tag :cljs/analysis-error}
Or is my only painful alternative is to replace the very nice :default with :as and an alias?["react-bootstrap-table2-editor$default" :as cellEditFactory], see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces:default? I.e (cellEditFactory (clj->js {:mode "click"})) (without the /default)$default does(cellEditFactory (clj->js {:mode "click"})). for really simple JS objects like that just use #js eg. (cellEditFactory #js {:mode "click"})deftype and extending a protocol without any methods. Though IAtom doesn't cause these problems, any ideas?
(defprotocol IReactiveAtom) (deftype IRatom [bar] IAtom IReactiveAtom )
------ WARNING #1 - :infer-warning --------------------------------------------- File: /home/juho/tmp/your-project/src/your_project/core.cljs:30:1 -------------------------------------------------------------------------------- 27 | 28 | (defprotocol IReactiveAtom) 29 | 30 | (deftype Ratom [bar] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. IRatom -prototype) -your-project$core$IReactiveAtom$) -------------------------------------------------------------------------------- 31 | IAtom 32 | IReactiveAtom 33 | ) 34 | --------------------------------------------------------------------------------
cljs.main and (set! *warn-on-infer* true)Compiling /home/juho/Source/reagent/src/reagent/ratom.cljs to target/bundle-adv/resources/public/js/out/reagent/ratom.js WARNING: Cannot infer target type in expression (. c push derefed) at line 76 /home/juho/Source/reagent/src/reagent/ratom.cljs WARNING: Cannot infer target type in expression (. G__6105 push p2__6103#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs WARNING: Cannot infer target type in expression (. G__6105 push p3__6104#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs WARNING: Cannot infer target type in expression (. v -destroy) at line 328 /home/juho/Source/reagent/src/reagent/ratom.cljs WARNING: Cannot infer target type in expression (. a push f) at line 495 /home/juho/Source/reagent/src/reagent/ratom.cljsAnd shadow-cljs:
------ WARNING #1 - :infer-warning --------------------------------------------- File: /home/juho/Source/reagent/src/reagent/ratom.cljs:129:1 -------------------------------------------------------------------------------- 126 | 127 | (defprotocol IReactiveAtom) 128 | 129 | (deftype RAtom [^:mutable state meta validator ^:mutable watches] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. RAtom -prototype) -reagent$ratom$IReactiveAtom$) -------------------------------------------------------------------------------- 130 | ; IAtom 131 | IReactiveAtom 132 | 133 | IEquiv -------------------------------------------------------------------------------- ------ WARNING #2 - :infer-warning --------------------------------------------- File: /home/juho/Source/reagent/src/reagent/ratom.cljs:208:1 -------------------------------------------------------------------------------- 205 | (set! (.-reaction obj) r)) 206 | v)))) 207 | 208 | (deftype Track [f args ^:mutable reaction] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. Track -prototype) -reagent$ratom$IReactiveAtom$) -------------------------------------------------------------------------------- 209 | IReactiveAtom 210 | 211 | IDeref 212 | (-deref [this] -------------------------------------------------------------------------------- ------ WARNING #3 - :infer-warning --------------------------------------------- File: /home/juho/Source/reagent/src/reagent/ratom.cljs:250:1 -------------------------------------------------------------------------------- 247 | 248 | ;;; cursor 249 | 250 | (deftype RCursor [ratom path ^:mutable reaction -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. RCursor -prototype) -reagent$ratom$IReactiveAtom$) -------------------------------------------------------------------------------- 251 | ^:mutable state ^:mutable watches] 252 | IAtom 253 | IReactiveAtom 254 | -------------------------------------------------------------------------------- ------ WARNING #4 - :infer-warning --------------------------------------------- File: /home/juho/Source/reagent/src/reagent/ratom.cljs:358:1 -------------------------------------------------------------------------------- 355 | ;; - state 356 | ;; - watches 357 | ;; - watching 358 | (deftype Reaction [f ^:mutable state ^:mutable ^boolean dirty? ^boolean nocache? -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. Reaction -prototype) -reagent$ratom$IReactiveAtom$) -------------------------------------------------------------------------------- 359 | ^:mutable watching ^:mutable watches ^:mutable auto-run 360 | ^:mutable caught] 361 | IAtom 362 | IReactiveAtom --------------------------------------------------------------------------------
npm run release shows the warning, build.sh doesn't["mylib" :default/refer …] syntax is cljs/shadow specific, just wondering what (if any) equivalent there is.(defn foo-helper [a b] (that-npm-alias/do-stuff a b)). maybe even helps reducing the amount of code the macro generates.cljs.analyzer/resolve-var to get the actual alias if helper function is not an option(defcard xxx (wrap-theme comp)) but I think the arg capture confuses things.(defn theme
[x]
[:> ThemeProvider
x])
as well as another variant that returned an fn(:name (cljs.analyzer/resolve-var &env the-sym))shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running message when trying from Emacs cider-jackin-cljs.dir-locals.el looks like
((nil . ((cider-preferred-build-tool . shadow-cljs)
(cider-default-cljs-repl . shadow)
(cider-shadow-default-options . "app")
(cider-shadow-watched-builds . ("app"))))):modules or change :output-dir)shadow-cljs watch already running separately that would be your conflictnpx shadow-cljs watch app then cider-connect options to confirmreagent-react-native demo on windows I assume it works fine still 😉 IIRC I didn't use wsl though:ignore in :warnings-as-errors, but to disable output instead?
["date-fns-tz" :rename {format dtftz.format}]
...
(dtftz.format (js/Date.) "Europe/Berlin")
;;=>
module$node_modules$date_fns_tz$index is not definedthheller/shadow-cljs {:mvn/version "2.11.23"}
:target :browserconst output = format(zonedDate, pattern, { timeZone: 'Europe/Berlin' })npm install while shadow is running it sometimes gets confused["date-fns/format" :as format] also causes the same type of error(js-keys dtf-tz)to see if it even exists and what it has insidedtf-tz is undefined what module$node_modules$date_fns_tz$index is not defined basically meansmodule$...(js-keys dtf-tz);; => #js ["format" "getTimezoneOffset" "toDate" "utcToZonedTime" "zonedTimeToUtc"]
date-fns-tz has not been used anywhere elseeval then:js-options or so in your build config? anything electron related?shadow-cljs.edn so that I can call it?(ns app.data
(:require [clojure.edn :as edn]
[shadow.resource]
["/org_processor" :as org]
))deps.edn:
{:paths ["src" "scripts/js"]
...}[:app] Compiling ... [:app] Build failure: Closure compilation failed with 1 errors --- org_processor.js:3 Parse error. '}' expected
node some-script.js or so 😛shadow.resource just doesn’t suit my needs.(ns scripts.org-processor
(:require ["unified" :as unified]
["rehype-stringify" :as html]
["uniorg-parse" :as uniorg]
["uniorg-rehype" :as rehype]
["uniorg-extract-keywords" :refer (extractKeywords)]
[cljs-node-io.core :as io :refer [slurp spit file-seq]]
))
(def processor
(->
(unified)
(.use uniorg)
(.use extractKeywords)
(.use rehype)
(.use html)))
#_(def org-string "
#+title: Lorem Ipsum
#+subtitle: stuff test
#+date: 2021-04-15
#+tags: test
#+author: Christian Westrom
#+id: test-1
* Here's some stuff
* Here's more stuff
- more stuff")
(defn process-org
[org]
(.processSync processor org))
(defn org->html
[org-string]
(.-contents (process-org org-string)))
(defn org->data
[org-string]
(js->clj (.-data (process-org org-string))
:keywordize-keys true))
(defn blog-post
[org-string]
{:content (org->html org-string)
:data (org->data org-string)})
(defn ^:export all-posts
[path]
(js/console.log (map #(blog-post (slurp %)) (rest (file-seq path)))))
all-posts just outputs to the console for now, but I want to call it from my reagent site.shadow.resourcefile-seq in shadow-resource.js/fetchimport './App.css';
(defn f [& args] (def *debug args) (...)) ), they tend to disappear. I suppose that is because I do most of my coding inside a (comment ...) and when IntelliJ saves the file after any changes, Shadow reloads the code. I thought that vars would survive that (as they do in clj) but it seems they do not, at least sometimes.
Any tips? 🙏(defn foo []) to (defn bar []). I want to see warnings for all places still using foo ASAP. In Clojure I often only notice such things when I restart my process a couple hours/days later since foo will still be around and valid until then.def was defined from a REPL and keep those instead of resetting the entire ns(shadow/watch-set-autobuild! :app false)~ 9 ["ioredis" :as Redis] ~ 10 ["redlock" :as Redlock]
[:employee_record] Compiling ...
The required JS dependency "async_hooks" is not available, it was required by "node_modules/bluebird/js/release/util.js".
Dependency Trace:
shadow/umd_helper.cljs
user_auth_profile/employee_record/update.cljs
user_auth_profile/system_config.cljs
node_modules/redlock/redlock.js
node_modules/bluebird/js/release/bluebird.js
node_modules/bluebird/js/release/promise.js
node_modules/bluebird/js/release/util.js
Searched for npm packages in:
/Users/sproctor/guaranteed-rate/user-auth-profile/node_modules
See: async_hooks is part of NodeJS:target is your build? when building for the browser the native node packages are not available:node-library:js-provider :shadow in your build config?:employee_record {:target :node-library
43 :exports {:update user-auth-profile.employee-record.update/-main}
44 :source-map false
45 :output-dir "target/employee-record"
46 :output-to "target/employee-record/lambda.js"
47 :compiler-options {:infer-externs :auto
48 :externs ["externs/httpurr.js"]}
49 :js-options {:js-provider :shadow
50 :keep-native-requires true}
~ 51 :release {:compiler-options {:optimizations :simple}}}:keep-as-require #{"async_hooks"}:js-provider :shadow for node builds:js-provider :shadow is built and optimized for browser builds. that is works for node was due to some experimental changes and I decided this wasn't worth doing so didn't continue working on it.node_modules:require calls?:target :bundle :require is exactly identical and no CLJSJS is needed:foreign-libs to emulate the :requireIllegal variable reference before declaration: i we talked about a few days ago. Someone suggested me to use different module type https://github.com/pmndrs/three-stdlib/issues/69#issuecomment-862871876 and I applied but getting another king of errors and does not work. Do you have anything to add here?:js-options {:entry-keys ["module" "browser" "main"]}:target :file for npm packages{"three-stdlib" {:target :npm :require "three-stdlib/index.js"}
"@react-three/drei" {:target :npm :require "@react-three/drei/index.js"}
"@react-three/fiber" {:target :npm :require "@react-three/fiber/dist/react-three-fiber.esm.js"}
"@react-three/cannon" {:target :npm :require "@react-three/cannon/dist/index.js"}}:js-options {:entry-keys ["module" "browser" "main"]} and added ["regenerator-runtime"] as a dep and everything works now https://github.com/ertugrulcetin/racing-game-cljs(sh "cp" "-r" "from" "to") statements are not executed (it appears) when using shadow-cljs clj-run my.ns/build-fn? Other functions used in build-fn work as expected.three-mesh-bvh which I don't use, perhaps you could also add a resolve config for that library.:out and :err would tell you?:dependencies [[]] key in shadow-cljs.edn?npm install date-fns did the trick i think.shadow-cljs watch [buildname] I spin up a repl and everything, but it also seems to load the dependencies I specify.
It seems like it’s no different that if I ran shadow-cljs -A:test:dev watch test.
{...
:aliases {:dev {:extra-deps {thheller/shadow-cljs {:mvn/version "2.14.5"}
refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"}}}
:test {:extra-paths ["test"]}}}
I have two aliases.
In shadow-cljs.edn I’m referring to two aliases.
Does this mean I have the option of using these aliases before running shadow?
Or does it load all aliases regardless? I usually spin up a node-repl as opposed to loading a build.
{:deps {:aliases [:dev :test]}...
:builds {:script ...
:test ...}}
My expectation was that within each build I could have it point to an alias in deps.edn but there’s no documentation to suggest that’s possible, neither have I found any examples on github.clj -A:test -M -m shadow.cljs.devtools.cli compile test or whatever if you must have an alias per build:require are compiled. so having test on the classpath always doesn't matter since you never require your tests in your regular buidl anyways:dev/after-load is just a function that shadow-cljs calls. what it does is up to you, so I guess you'll have to figure out what resets them since that is your code doing it?npm-module target and things work pretty well
Even things like hot reload works in some how
Now I already ported most of the things to react-native target and etc
I'm just sharing that things in cljs/shadow are pretty stable and you can trust them 🙂
I still think that in 2019 I had the better/fastest code-reload/dev-experience available in react-native world.
And the setup to share code between native and web is WAY simpler than anything with webpack:module-hash-names true and when I do a release build I get the fingerprinted file. However, if I then remove the .shadow-cljs folder and do another release build I get a file which has a different fingerprint even though there have been no code or dependency changes. It appears that the munged variable names are different.
Q: is this expected? I assumed that the build process would produce identical output given identical input, but maybe that’s not the case?.shadow-cljs you are basically destroying the reproducible part 😉resource/public/js/app.js yes. it does not generate any HTML, so loading that file is up to you?========= Running Tests ======================= Testing uniorg-util.cli-test Testing uniorg-util.core-test Ran 8 tests containing 31 assertions. 0 failures, 0 errors. ===============================================
:node-test?:node-test. in case those exist 😛(js/alert "foo")? there is a difference here to figwheel. you need either a connection from your editor or shadow-cljs cljs-repl app in addition to shadow-cljs watch app firstcljs.user, and Shadow-cljs hot-reloads it, and I then try executing something in the repl, I get the following exception:
------ REPL Error while processing ---------------------------------------------
foo
no source by provide: cljs.user
{:provide cljs.user}
ExceptionInfo: no source by provide: cljs.user
shadow.build.data/get-source-id-by-provide (data.clj:186)
.....
Only seems to be the case for cljs.user[2021-06-22 22:07:23.472 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "foo", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form foo, :source "foo", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:501)
shadow.cljs.repl/process-read-result (repl.clj:475)
shadow.cljs.repl/process-input (repl.clj:659)
shadow.cljs.repl/process-input (repl.clj:637):deps {:aliases [:cljs]}, and then I have :paths ["src" "dev"] in my deps.edn, and cljs.user is in dev/cljs/user.cljscljs.user(ns cljs.user {:dev/once true} ...) meta to only load it once. not sure that fixes anything:repl-init-ns with another namespace - same problem with that namespace.
Anyway, I'll create a repro.import { Ziggy } from './ziggy.js';
:require ["./ziggy.js" :refer [Ziggy]]:js-options :resolve who seems perfect to avoid complected relative paths. 👍:resolve. if you have the file on the classpath (which you should) just use either the relative path or the full path (:require ["/some/file.js"]) following classpath rules["ziggy-js" :refer [route]] or ["ziggy-js" :default route]
["ziggy-js" :as route]Cannot use import statement outside a moduleTried
release and watch builds, both unsuccessfulimport statements anywhere. unless you are using :target :esm?["./surveyjs/widgets/RatingWidget.jsx" :refer [RatingWidget]]I get: > cannot identify as cljs resource
npx babel *.jsx --out-dir gen:asset-path controls thatimport React from "react";
import Select from "react-select";
import Survey from "survey-react";
const CustomSearchWidget = ({ choices, onChange }) => {
...
return (
<Select
...
/>
);
};
export const SearchWidget = {
...
render: (question) => {
return (
<CustomSearchWidget
...
/>
);
},
};
When I compile this using babel with npx babel *.jsx --out-dir gen and import this compiled file in a clojurescript file like so:
["./surveyjs/widgets/gen/SearchWidget.js" :refer [SearchWidget]]and use the SearchWidget in the application I get this error:
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: objectIf I return
<div/> instead of <Select/> this error does not occurimport React from "react";
import Select from "react-select";
import Survey from "survey-react";
const CustomSearchWidget = ({ choices, onChange }) => {
const handleChange = (option) => {
onChange(option.value);
};
const options = choices.map((choice) => {
return { label: choice, value: choice };
});
return (
<Select
className="basic-single"
classNamePrefix="select"
isClearable={true}
isSearchable={true}
name="color"
options={options}
onChange={handleChange}
/>
);
};
export const SearchWidget = {
name: "search dropdown",
title: "Dropdown with search",
isFit: function (question) {
return question.getType() === "searchdropdown";
},
activatedByChanged: function (activatedBy) {
Survey.JsonObject.metaData.addClass("searchdropdown", [], null, "text");
Survey.JsonObject.metaData.addProperties("searchdropdown", [
{ name: "choices", default: ["Click Me"] },
]);
},
render: (question) => {
return (
<CustomSearchWidget
choices={question.choices}
placeholder={question.title}
onChange={(val) => (question.value = val)}
/>
);
},
};(ns nl.mediquest.questionnaire-frontend.component.survey (:require ["./surveyjs/widgets/gen/SearchWidget.js" :refer [SearchWidget]] [survey-react :refer [Survey StylesManager CustomWidgetCollection]])) (.. CustomWidgetCollection -Instance (addCustomWidget SearchWidget "customtype"))
{
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/plugin-transform-react-jsx": "^7.14.5",
"shadow-cljs": "2.10.12"
},
"dependencies": {
"@fortawesome/fontawesome-pro": "^5.13.0",
"@fullhuman/postcss-purgecss": "^2.0.5",
"autoprefixer": "9.8.0",
"global": "^4.4.0",
"postcss-cli": "7.1.1",
"postcss-import": "^12.0.1",
"react": "^16.13.0",
"react-dom": "16.13.0",
"react-select": "^4.3.1",
"recharts": "1.8.5",
"survey-react": "^1.8.4",
"tailwindcss": "1.4.6"
},
"scripts": {
"build-css": "node_modules/postcss-cli/bin/postcss resources/public/css/tailwind.css -o resources/public/style.css"
}Select component, because when I turn it into <div/> the webpage renders and there are no errors... out a bunch of code so I cannot see what this SearchWidget actually is. from what you left in it is not a correct react component and that is what the error is telling you?export const SearchWidget = class extends React.Component {?export const SearchWidget = class extends React.Component { gives babel compilation error:
Unexpected token (28:6)
26 |
27 | export const SearchWidget = class extends React.Component {
> 28 | name: "search dropdown",
| ^
npx babel *.jsx --out-dir genReact.createClass({ name: ...})import Select from "react-select";to
const Select = require('react-select');
#js [] when placed anywhere within the form of a call to react/useState, breaks the hooks state preservation on hot reload.
For example test-state is preserved if I make a code change with this component:
(defnc test-component []
(let [[test-state set-test-state] (react/useState (do [] 1))]
($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
but if I tag the array inside the do form with a #JS like the following, the state of test-state is not preserved if I make a code change:
(defnc test-component []
(let [[test-state set-test-state] (react/useState (do #js [] 1))]
($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
maybe this is not a shadow-cljs issue, but any help would be much appreciated, thanks!do in the first place?useState is always lost, just like local state is normally lost. given that component type changes it should go through a full unmount/mount cycle(defnc test-component []
(let [a #js []
[test-state set-test-state] (react/useState (do a 1))]
($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
it works fine(defnc test-component []
(let [[test-state set-test-state] (react/useState (do (array) 1))]
($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
that's what makes me think it's either clojurescript or shadowdefnc does internallyExecution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.I copied the configs so not sure what's missing. my deps.edn
{:paths ["src/main" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
com.fulcrologic/fulcro {:mvn/version "3.5.0-RC3"}
#_[ com.fulcrologic/fulcro {:mvn/version "3.4.22"}]}
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.866"}
thheller/shadow-cljs {:mvn/version "2.14.5"}
binaryage/devtools {:mvn/version "1.0.3"}}}}}
my shadow-cljs.edn
{:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn mindjoin.client/init
:entries [mindjoin.client]}}
:devtools {:after-load mindjoin.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload]}}}}
[fulcroapp] npx shadow-cljs -v server master ✭ shadow-cljs - config: /home/deepe/projects/clojure/fulcroapp/shadow-cljs.edn shadow-cljs - starting via "clojure" WARNING: Specified aliases are undeclared: [:-A] Downloading: org/clojure/clojure/1.10.1/clojure-1.10.1.pom from ....(oteher deps)
2.14.4 of the npm package? the version in deps.edn can stayclj -version do you use? maybe thats too old?[fulcroapp] clj -version Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2). -version (No such file or directory)
clj --version?clj -Sdescribe?-versionversion "1.10.1.478" but that might just be from my deps?:bootstrap? you are controlling the compiler in the host-build, so you'd set them?[:client] Build failure:
ExecutionException: java.io.FileNotFoundException: C:\Shared\orgpad\resources\public\js\compiled\cljs-runtime\orgpad.client.effects.core.js.map (The requested operation cannot be performed on a file with a user-mapped section open)
java.util.concurrent.FutureTask.report (:-1)
java.util.concurrent.FutureTask.get (:-1)
clojure.core/deref-future (core.clj:2304)
clojure.core/deref (core.clj:2324)
clojure.core/deref (core.clj:2310)
clojure.core/run!/fn--8813 (core.clj:7717)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/run! (core.clj:7712)
clojure.core/run! (core.clj:7712)
shadow.build.async/wait-for-pending-tasks!/fn--10176 (async.clj:25)
clojure.lang.Atom.swap (Atom.java:37)
clojure.core/swap! (core.clj:2356)
clojure.core/swap! (core.clj:2349)
shadow.build.async/wait-for-pending-tasks! (async.clj:23)
shadow.build.async/wait-for-pending-tasks! (async.clj:19)
shadow.build/flush (build.clj:476)
shadow.build/flush (build.clj:467)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:531)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:486)
shadow.cljs.devtools.server.util/server-thread/fn--14066/fn--14067/fn--14075 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14066/fn--14067 (util.clj:283)
shadow.cljs.devtools.server.util/server-thread/fn--14066 (util.clj:256)
java.lang.Thread.run (:-1)
Caused by:
FileNotFoundException: C:\Shared\orgpad\resources\public\js\compiled\cljs-runtime\orgpad.client.effects.core.js.map (The requested operation cannot be performed on a file with a user-mapped section open)
java.io.FileOutputStream.open0 (:-2)
java.io.FileOutputStream.open (:-1)
java.io.FileOutputStream.<init> (:-1)
(io.clj:230)
(io.clj:230)
(io.clj:69)
(io.clj:166)
(io.clj:166)
(io.clj:69)
(io.clj:119)
(io.clj:104)
clojure.core/apply (core.clj:669)
clojure.core/spit (core.clj:6956)
clojure.core/spit (core.clj:6956)
shadow.build.output/generate-source-map-regular (output.clj:208)
shadow.build.output/generate-source-map-regular (output.clj:173)
shadow.build.output/generate-source-map (output.clj:222)
shadow.build.output/generate-source-map (output.clj:212)
shadow.build.output/flush-source/fn--10254 (output.clj:249)
shadow.build.output/flush-source (output.clj:245)
shadow.build.output/flush-source (output.clj:224)
shadow.build.output/flush-sources/fn--10274 (output.clj:257)
shadow.build.async/queue-task/fn--10171 (async.clj:15)
clojure.core/apply (core.clj:667)
clojure.core/with-bindings* (core.clj:1977)
clojure.core/with-bindings* (core.clj:1977)
clojure.core/apply (core.clj:671)
clojure.core/bound-fn*/fn--5767 (core.clj:2007)
java.util.concurrent.FutureTask.run (:-1)
java.util.concurrent.ThreadPoolExecutor.runWorker (:-1)
java.util.concurrent.ThreadPoolExecutor$Worker.run (:-1)
java.lang.Thread.run (:-1)
This can be fixed by kiling the process running on port 7000 which is nREPL for our development server. Is this something caused by Shadow-cljs or source maps handled by Chrome? I am running :loader-mode :eval in the Shadow-cljs config.shadow-cljs.edn, without such a file being consulted? Context is that I want to manipulate the relative filesystem paths (the node_modules and the outputs) to interoperate with a build process, while keeping the "normal" paths for use from the repl. So various other things such as middlewares or alternative paths to load the config from, would also help me out. thanks!shadow-cljs.edn so many things expect it. things will still function without it but you'll lose features. do you have an example config you'd like to generate compared to a normal one?:output-dir (at the same time again)?[org.graalvm.js/js-scriptengine "21.1.0"] [org.graalvm.js/js "21.1.0"] [com.ibm.icu/icu4j "68.2"] [org.graalvm.regex/regex "21.1.0"] [org.graalvm.sdk/graal-sdk "21.1.0"] [org.graalvm.truffle/truffle-api "21.1.0"]
--verbose flag mentioned in the documentationshadow-cljs watch app --verbosegoog.net.cookies is what reagent-utils uses but it is now goog.net.Cookies I guess?SameSite must be set by the server?js/React, it seems all’s well and I get a shadow bundle leaning on the React that Wordpress has already provided on js/window. See https://gist.github.com/rgm/9ebc632a19074dea1a69955336fd3c8cjs/React, it seems all’s well and I get a shadow bundle leaning on the React that Wordpress has already provided on js/window. See https://gist.github.com/rgm/9ebc632a19074dea1a69955336fd3c8c:dev-http then you need to configure :devtools {:watch-dir "foo/bar"}:dev-http logs all requests and automatically figures out which css files to watch. so when it knows about the paths once (by visiting 8080) it'll then also work for 8081. :watch-dir should fix it so it works without visiting 8080 firstshadow-cljs.edn :buildswatch-dir even tired targeting actual file but nothing:watch-dir likely needs to be "resources/public"/css work?resources/public/css the browser location localhost:8080/css/hax.css will actually ask for public/css/css/hax.css
is that right?resources/public. always the "root" + the full path used in the browserWhile resolving:I love node so much. Any suggestions? I was not crazy about using the
-force option.
Thx!AwesomeProject in that repo?npm fund for details
found 0 vulnerabilities
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: /cdn-cgi/l/email-protection
npm ERR! Found: /cdn-cgi/l/email-protection
npm ERR! node_modules/react
npm ERR! /cdn-cgi/l/email-protection"16.12.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer /cdn-cgi/l/email-protection"16.9.0" from /cdn-cgi/l/email-protection
npm ERR! node_modules/react-native
npm ERR! /cdn-cgi/l/email-protection"0.61.5" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/kennethtilton/paho.mqtt.javascript/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kennethtilton/paho.mqtt.javascript/.npm/logs/2021-07-01T1945_29_923Z-debug.log
Then I saw a note about how the the directory react-native got created and thought that was sth I should have done. So forget that. What about this npm madness? Can I just hack a json somewhere? I googled the error but quickly got depressed. 🙂npm install --legacy-peer-deps seems to do it. I guess something in npm change in how they handle dependency conflictsreact-native folder in that repo is ancient at this point. so probably best to recreate itemulator to run an emulator. run-ios does not work either. I'll try your other versions....react-native. I also have a recent Android Studio and have worked thru pure JS tutorials with emulators successfully, and also got an emulator up OK using https://github.com/PEZ/rn-rf-shadow, FWIW. But I am looking for a bare CLJS+RN "hello world" so I can apply my Matrix reactive library to come up with a new CLJS+RN framework. I thought your "plain" example sounded the "barest", but I can start from sth heftier.
Mind you, the Android Studio emulator CLI cannot bring up an emulator either. The emulator CLI says "cannot find emulator executable". I get a kick out of that. 🙂
I'll soldier on. Thx again for the quick and great support. I am saving that "legacy" incantation!which emulator returns?
🠶 which emulator /home/emak/Android/Sdk/emulator/emulator 🠶 emulator -list-avds Pixel_2_API_29 ;; Try to open the emulator before running `react-native run-android` 🠶 emulator -avd Pixel_2_API_29 &
$ which emulator /Users/kennethtilton/Library/Android/sdk/emulator/emulator ~/inonit/cantavi/songpark-platform/mqtt [dev] $ emulator -v emulator: Android emulator version 30.3.5.0 (build_id 7036990) (CL:N/A) emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'I think the problem may be on my end: emulators Android and IOS worked OK originally, but somewhere along the line I broke Android, leaving aside CLJS altogether. For now I am plowing ahead on iOS, making good headway with the https://github.com/PEZ/rn-rf-shadow project. Might have MatrixRN "hello world" by Monday. Thx for pitching in!
clj -A:dev?npx shadow-cljs server process running so I can more quickly start and stop watching builds as I switch between git branches in my project. But when I switch branches npx shadow-cljs watch app no longer detects the running server process. Is there a file somewhere or something that I need to keep around which watch app looks for to detect the server?.shadow-cljs dir? the detection is based on a file in that dir? otherwise it should be detected fine?TypeError: _system.keyframes is not a function at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple (TouchRipple.js:64)The related JS Code looks like this:
// file -- @material-ui/core/node/ButtonBase/TouchRipple.js
var _system = require("@material-ui/system");
const pulsateKeyframe = (0, _system.keyframes)`... stuff ...`
// file -- @material-ui/styled-engine/index.d.ts
export { ThemeContext, keyframes, css } from '@emotion/react';
// file -- @material-ui/system/index.js
Object.defineProperty(exports, "keyframes", {
enumerable: true,
get: function () {
return _styledEngine.keyframes;
}
});
I deleted old js output and the .shadow-cljs folder beforehand. (That usually fixes stuff like this. 🙂)
Disclaimer: I have no idea of JS or TS modules or shadow-cljs works. Sorry, if I am at the wrong place to ask.// file -- package.json // Relevant dependencies: "@emotion/react": "^11.4.0", "@emotion/styled": "^11.3.0", "@material-ui/core": "^5.0.0-beta.0",
app.js:1552 TypeError: module.keyframes is not a function
at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple
with various material ui versions including beta.0 (see my post). i wonder if it's a similar issue. i get it just upgrading shadow/cljs but can't seem to resolve itarttuka/reagent-material-ui "5.0.0-alpha.29-0" working with cljs 1.10.773 and shadow 2.11.24. Beyond that shadow version, it stopped working (not sure why). would be nice to be able to upgrade and add other packages, but i too am running out of ideas of how to debug such issuescom.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party
tried upgrading reagent/mui/other deps at the same time in virtually all combos i could think of, etc. but i cannot get rid of these errors and cannot get the front end working againlein-shadow. and there is way too much stuff I can't comb through. there should be no docker or anything of that sort to reproduce either.:mylo-app-production. it is the same build as :mylo-app and you can just use that. :preloads don't apply to release to in effect the config is identical.shadow-cljs.edn directly and i've been able to narrow down where the error starts to occur. when i upgrade the shadow-cljs version from 2.12.7 -> 2.13.0 or above, I get a bunch of errors and it seems unable to load and run the app or its components. i've also noticed the same thing with @U4VT24ZM3's demo app above. when i change the shadow version to 2.12.7, there is no more error in the console. when i go to 2.13.0, there's an error. i'm not sure if this helps narrow down the issue or not. it's possible the issue is with cljs or some other component that shadow depends on that also changes at that version. here's the diff for the demo repo that makes it work:
diff --git a/deps.edn b/deps.edn
index b072947..71a16bf 100644
--- a/deps.edn
+++ b/deps.edn
@@ -5,6 +5,5 @@
:aliases {;; See for Emacs support
:dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
- :extra-deps {org.clojure/clojurescript {:mvn/version "1.10.866"}
- thheller/shadow-cljs {:mvn/version "2.14.6"}
+ :extra-deps { thheller/shadow-cljs {:mvn/version "2.12.7"}
binaryage/devtools {:mvn/version "1.0.3"}}}}}
diff --git a/package.json b/package.json
index 9351cae..4aab757 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,6 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
- "shadow-cljs": "^2.14.6"
+ "shadow-cljs": "2.12.7"
}
}
:output-feature-set :es6. not sure why this would break anything but you can easily set the previous default by setting :compiler-options {:output-feature-set :es5} in your build configkeyframes thing existed but yet it failed complaining that it didn't exist. couldn't figure it out.:js-options {:entry-keys ["module" "browser" "main"]} to the shadow-cljs config resolves this.:js-options {:entry-keys ["module" "browser" "main"]} leads to other functions not found.
; my-lib/card.cljc (def content (log/spy :info (interop/react-factory #?(:cljs CardContent :clj nil)))) ; my-app/some-ns.cljs requireing [my-lib/card :as card] (log/spy :info CardContent) (log/spy :info (interop/react-factory CardContent)) (log/spy :info card/content)Prints this:
(interop/react-factory CardContent) => fn [props & children]
CardContent => {$$typeof: Symbol(react.forward_ref), propTypes: {…}, render: ƒ}
(interop/react-factory CardContent) => fn [props & children]
card/content => undefined
Any idea, how to circumvent this?module it'll require following what the modules actually export:as Thing to :default Thing. depends on what the libraries do, see the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages:js-options solution above does seem to work for the most part and i was able to upgrade shadow, mui, and react, but i've ran into other issues w/ a couple of the packages, @material-ui/data-grid and @material-ui/x-grid. they are basically the same library, w/ x grid having extra features. on the older version (4.0.0-alpha.21) which works w/ the old 2.12.7 shadow and older mui, i get this after the build completes, but the rest of the app works:
app.js:1551 An error occurred when loading neo.common.components.data_grid.js
env.evalLoad @ app.js:1551
(anonymous) @ app.js:2507
app.js:1552 TypeError: (0 , p.makeStyles) is not a function
at Object.shadow$provide.module$node_modules$$material_ui$x_grid$dist$index_esm (index-esm.js:2424)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at eval (neo.common.components.data_grid.js:2)
at eval (<anonymous>)
at Object.goog.globalEval (app.js:486)
at Object.env.evalLoad (app.js:1549)
at app.js:2507
but on versions i think above 4.0.0-alpha.23 or so, i get exceptions during the build itself, either of the below two. i also get this w/ the old shadow version 2.12.7.
[:mylo-app] Build failure:
babel failed?
{:file "/Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js"}
ExceptionInfo: babel failed?
shadow.build.babel/convert-source/fn--11641 (babel.clj:164)
shadow.build.babel/convert-source (babel.clj:156)
shadow.build.babel/convert-source (babel.clj:152)
shadow.build.resolve/make-babel-source-fn/fn--11715 (resolve.clj:202)
shadow.build.data/get-source-code (data.clj:319)
shadow.build.data/get-source-code (data.clj:306)
shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313/fn--11314 (closure.clj:1809)
shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313 (closure.clj:1808)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5419 (core.clj:139)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
clojure.core/reduce (core.clj:6830)
clojure.core/into (core.clj:6897)
clojure.core/into (core.clj:6889)
shadow.build.closure/convert-sources-simple* (closure.clj:1837)
shadow.build.closure/convert-sources-simple* (closure.clj:1804)
shadow.build.closure/convert-sources-simple (closure.clj:2098)
shadow.build.closure/convert-sources-simple (closure.clj:2050)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
shadow.build.compiler/compile-all (compiler.clj:1440)
shadow.build.compiler/compile-all (compiler.clj:1307)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:442)
shadow.build/compile (build.clj:432)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:439)
shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:428)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068/fn--14076 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068 (util.clj:283)
shadow.cljs.devtools.server.util/server-thread/fn--14067 (util.clj:256)
java.lang.Thread.run (Thread.java:834)
or (this was huge so i snipped out the middle which seems to be a bunch of dumped js):
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:7429
!0,Ei.Xa="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers117711",Ei.Gb=function(b){return Rb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers117711")};return new Ei(a,je)}function Gi(a){try{var b=a[0];return b.a?b.a(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].rb(null),b;throw c;}}function Hi(a,b){b=zi(b,Fi(function(c){a[2]=c;a[1]=4;return Gi(a)}));return H(b)?(a[2]=Cb(b),a[1]=4,mh):null}
^
Error: /Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js: Unknown property: L
at matchProperty (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:15854:8)
at handleLoneUnicodePropertyNameOrValue (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32136:19)
at getUnicodePropertyEscapeSet (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32145:9)
at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32276:5)
at /Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32323:12
at Array.map (<anonymous>)
at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32322:26)
at /Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32323:12
at Array.map (<anonymous>)
at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32322:26) {
code: 'BABEL_TRANSFORM_ERROR'
}
[2021-07-30 16:51:35.396 - WARNING] :shadow.build.babel/babel-transform-ex - {:code "import{LicenseInfo as e,useLicenseVerifier as t}from\"@material-ui/x-license\";export{LicenseInfo}from\"@material-ui/x-license\";import*as r from\"react\";import n from\"react\";import{capitalize as l,ownerDocument as o,useEventCallback as a,createSvgIcon as i,unstable_useId as s,useForkRef as c,ownerWindow as u,debounce as d}from\"@material-ui/core/utils\";import p from\"clsx\";import m from\"@material-ui/core/InputBase\";import*as f from\"@material-ui/core/styles\";import{useTheme as g,lighten as b,darken as h}from\"@mater
RuntimeException EOF while reading
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.LispReader.read (LispReader.java:268)
clojure.lang.LispReader.read (LispReader.java:216)
clojure.lang.LispReader.read (LispReader.java:210)
clojure.core/read (core.clj:3754)
clojure.core/read (core.clj:3729)
clojure.core/read (core.clj:3729)
clojure.core/read (core.clj:3729)
shadow.build.babel/babel-transform! (babel.clj:107)
shadow.build.babel/babel-transform! (babel.clj:93)
shadow.build.babel/babel-loop (babel.clj:126)
shadow.build.babel/babel-loop (babel.clj:123)
[:mylo-app] Build failure:
babel failed?
{:file "/Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js"}
ExceptionInfo: babel failed?
shadow.build.babel/convert-source/fn--11641 (babel.clj:164)
shadow.build.babel/convert-source (babel.clj:156)
shadow.build.babel/convert-source (babel.clj:152)
shadow.build.resolve/make-babel-source-fn/fn--11715 (resolve.clj:202)
shadow.build.data/get-source-code (data.clj:319)
shadow.build.data/get-source-code (data.clj:306)
shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313/fn--11314 (closure.clj:1809)
shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313 (closure.clj:1808)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
clojure.core/chunk-next (core.clj:710)
clojure.core.protocols/fn--8176 (protocols.clj:137)
clojure.core.protocols/fn--8176 (protocols.clj:124)
clojure.core.protocols/fn--8136/G--8131--8145 (protocols.clj:19)
clojure.core.protocols/seq-reduce (protocols.clj:31)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
clojure.core/reduce (core.clj:6830)
clojure.core/into (core.clj:6897)
clojure.core/into (core.clj:6889)
shadow.build.closure/convert-sources-simple* (closure.clj:1837)
shadow.build.closure/convert-sources-simple* (closure.clj:1804)
shadow.build.closure/convert-sources-simple (closure.clj:2098)
shadow.build.closure/convert-sources-simple (closure.clj:2050)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
shadow.build.compiler/compile-all (compiler.clj:1440)
shadow.build.compiler/compile-all (compiler.clj:1307)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:442)
shadow.build/compile (build.clj:432)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:439)
shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:428)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068/fn--14076 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068 (util.clj:283)
shadow.cljs.devtools.server.util/server-thread/fn--14067 (util.clj:256)
java.lang.Thread.run (Thread.java:834)
also, i've seen this from that package once or twice when it did compile:
--- node_modules/@material-ui/data-grid/dist/index-cjs.js:17 Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.which led me to try adding:
:compiler-options {:output-feature-set :es2018}}}} to the options which led to the original error even on the older 2.12.7 version.@inovua/reactdatagrid-community instead of x-grid @U02LLEJMREGAn error occurred when loading reagent_material_ui.styles.jsand warnings like
shadow-cljs - failed to load module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple shadow.js.jsRequire @ js.js:74 shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$ButtonBase @ ButtonBase.js:35 shadow.js.jsRequire @ js.js:66
:js-options {:entry-keys ["browser" "main"]} in your build config:lein {:profile "+dev"} in my config, does that impact the release build? I’m guessing it does?:lein in the :dev map of the build? I’ve tried it and there are no complaints, but I don’t know if it is picked up.:lein {:profile "+dev"} in the config, Leiningen starts like so:
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch appWhich satisfies Calva’s needs, and works in development. But I am unsure how/if it impacts a release build of the client app.
:require does. what isn't required isn't included. see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html:output-dir OR :modules but not updating your HTML to actually load those files and thus loading the old fileswatch competing with each other:devtools-url not properly proxying requests?devtools-url. Let me check #1.output-dir than the other modules? I would like to use the modules feature to generate my service worker...message: "Error loading admin: Consecutive load failures", stack: "CustomError: Error loading admin: Consecutive load…2e67cadcbe6a0cbc0cd49287b5202a7cdedc.js:421:1090)" Any ideas?[lazy/lazy #:lazy{:loadable (slazy/loadable <someprojectname>.client.views.administration.core/administration)
:state :loading/administration}]
Here is the lazy implementation:
(ns <someprojectname>.client.views.widgets.lazy
(:require ["react" :as react]
[reagent.core :as r]
[shadow.lazy :as slazy]
[<someprojectname>.client.views.loading :as loading]))
(defn- component
"React Lazy component which waits till the code is loaded and then replaces it with the component itself."
[loadable]
(react/lazy
(fn []
(-> (slazy/load loadable)
(.then (fn [root-el]
#js {:default (r/reactify-component (fn [props] [@loadable props]))}))))))
(defn lazy
"Renders a component whose source code may have to be first loaded. While the source code is loaded, renders the
loading screen for the given state. The single parameter is a map having the following keys:
:lazy/loadable - Call (slazy/loadable ).
:lazy/state - The loading state while the component's source code is loaded."
[{:lazy/keys [loadable state]}]
[:> react/Suspense {:fallback (r/as-element (if state
[loading/loading {:loading/state state}]
[:div]))}
[:> (component loadable)]])
The error isn't very specific unfortunately - or at least I don't see any useful details.(rf/reg-event-fx
:administration/load-data
[clean/effects]
(fn [effects [_ refresh]]
(let [{:administration/keys [init mode]} (db-get/administration effects)]
(js/console.log "LOG LOG Loading administration data.")
(if (or init refresh)
(db-update/administration (case mode
:administration/index (metrics/switch-to-metrics effects)
:administration/metrics (metrics/switch-to-metrics effects)
:administration/charts (charts/switch-to-charts effects)
:administration/users (users/switch-to-users effects)
:administration/usergroups (usergroups/switch-to-usergroups effects)
:administration/devices (devices/switch-to-devices effects)
:administration/orgpages (orgpages/switch-to-orgpages effects)
:administration/campaigns (campaigns/switch-to-campaigns effects)
(metrics/switch-to-metrics effects))
dissoc :administration/init)
effects))))
reagent/reagent in my deps.edn file. where to look for clues?
[:app] Compiling ...
-> Resolving Module: :main
[:app] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".user clj like:
(defn shadow-cljs
[& args]
(server/start!)
(shadow/watch :app {:verbose true}))reagent to shadow-cljs.edn. Instead i'm using an alias within deps.edn. Does it matter?(ns ... (:require ["react" :as react]))[reagent.core :as r] Also in your package.json add the dependency:
"dependencies": {
...
"react": "^16.14.0",
<and optionally other dependencies with appropriate versions>
"react-dom": "^16.14.0",
"react-easy-crop": "^2.1.2",
"react-motion": "^0.5.2",
"react-transition-group": "^4.4.1",
...
},package.json is shadow different in this aspect?{:deps {...}}
:paths ["src" "resources" "target"]
:aliases
{:dev-deps {:extra-deps {;;nrepl/nrepl {:mvn/version "0.8.3"}
cider/cider-nrepl {:mvn/version "0.26.0"}
reagent/reagent {:mvn/version "1.1.0"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.3"}
cljsjs/react-bootstrap {:mvn/version "1.3.0-0"}
thheller/shadow-cljs {:mvn/version "2.14.6"}
ring/ring-devel {:mvn/version "1.9.3"}}}
:dev {:main-opts ["-m" "user"]
:extra-paths ["dev"]}
:build {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
:prod {:main-opts ["-m" "web.core"]}}}clj -M:dev-deps:devnpm to handle npm dependencies. it does not support CLJSJS (which you probably relied on with figwheel){:aliases
{:dev-deps {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.866"}
reagent/reagent {:mvn/version "1.1.0"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.3"}
cljsjs/react-bootstrap {:mvn/version "1.3.0-0"}}}}}
clj -M:dev-deps --main cljs.main -O advanced -c web.corereact however is not a CLJS library. it is a JS library. the default cljs implementation will resolve those using a mechanism called foreign-libs which are provided by CLJSJS packages. shadow-cljs does not support those and instead provides JS deps directly from npm.root-el? I mean I can't describe it any clearer than I did in that comment?{:lein true
:jvm-opts ["-Dfile.encoding=UTF8" "-Xmx2G"]
:nrepl {:port 9000}
:ssl {:keystore "keystore.jks"
:password "..."}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:module-loader true
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:admin {:entries [orgpad.client.views.administration.core]
:depends-on #{:main}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :eval}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}
:emails {:target :browser
:output-dir "emails/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.server.email.dev/init}}
:devtools {:http-root "emails"
:http-port 3600
:after-load orgpad.server.email.dev/mount-root
:watch-dir "emails"
:browser-inject :main}}
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}}}:module-hash-names so how do you get the proper filenames into the loader?(defn release []
(let [version (System/getenv "GIT_SHA")]
(when-not (= (shadow/release :client {:config-merge [{:release-version version}]}) :done)
(throw (RuntimeException. "Shadow-cljs compilation failed.")))))
shadow/release! that'll throw if compile failsmount-root) :
https://github.com/prestancedesign/pingcrm-clojure/blob/ssr/src/cljs/pingcrm/app.cljs#L11-L26createInertiaApp:
(defn ^:dev/after-load start []
(createInertiaApp
#js {:resolve (fn [name] (let [^js comp (r/reactify-component (get pages name))]
(when-not (= name "Auth/Login")
(set! (.-layout comp) (fn [page] (r/as-element [layout page]))))
comp))
:setup (j/fn [^:js {:keys [el App props]}]
(d/render (r/as-element [:f> App props]) el))}))
(defn init! []
(start))createInertiaApp: https://github.com/inertiajs/inertia/blob/master/packages/inertia-react/src/createInertiaApp.js#L4after-load-async in this case or nothing related?app.cljs for the SPA part
2. ssr.cljs for the SSR part'# to theses components. Here the commit:
https://github.com/prestancedesign/pingcrm-clojure/commit/175aee8fca26a281e7bc82680b5ac5e1e70fb997(ns my.namespace (:require ["@material-ui/core" :as mui]) (mui/P|<- *cursor is here* )
clj-suitable is a way to go (and whether it works correctly with shadow), but worth investigating:deps true or :deps {:aliases [:dev]} in my shadow-cljs.edn file, then I should not have a :dependencies key anywhere in the same file, correct? All my deps are managed by deps.edn as a result of those settings -- that's my understanding.internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/events/events.js"]
{:dep [:shadow.build.classpath/resource "goog/events/events.js"]}
ExceptionInfo: internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/events/events.js"]
I am using shadow 2.14.6. Am I missing something super obvious? I've tried adding goog events manually a few places but no dice so far{:target :browser-test
:test-dir "target/test/"
:autorun tr
which basically compiles to target/test/js/test.js, but when I run jest on test.js, it produces the following:
FAIL target/test/js/test.js
● Test suite failed to run
browser bootstrap used in incorrect target
1449 |
1450 | if (!doc) {
> 1451 | throw new Error("browser bootstrap used in incorrect target");
| ^
1452 | }
1453 |
1454 | var scriptBase = goog.global.window.location.origin;
at Object.call (target/test/js/test.js:1451:11)
at Object.<anonymous> (target/test/js/test.js:1582:3)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.43 s
How to fix this?
This is the singular test file that’s being compiled:
(ns humboi.sum-test)
(defn sum [a b] (+ a b))
(test "adds 1 + 2 to equal 3"
(fn []
(.toBe (expect (sum 1 2)) 3)))
:browser-test won't work[:test] Compiling ... [:test] Build failure: The required JS dependency "@testing-library/react" is not available, it was required by "humboi/core_test.cljs". Dependency Trace: humboi/core_test.cljs Searched for npm packages in: /Users/prikshetsharma/Desktop/humboi/node_modules See:
/Users/prikshetsharma/Desktop/humboi/node_modules/@testing-library/react directory?/Users/prikshetsharma/Desktop/humboi?/Users/prikshetsharma/Desktop/humboi/package.json?lein test runs only the clj tests. Is there a way to run only the cljs tests?shadow-cljs compile test && node the-file-generated-by-node-test-build.jsnpx shadow-cljs server or a running watch is needed. otherwise it won't be running{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:devtools {:watch-dir "resources/public"
:preloads [re-frisk.preload]}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:release {}}
:test {:target :browser-test
:test-dir "target/test/"
:autorun true
:devtools {:http-port 8081
:http-root "target/test/"}}}
:lein true}:dev-http https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http:autorun is not an option for :browser-testExecution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:30). Assert failed: (keyword? repl-env)
"@blueprintjs/core/dist/core.bundle.js", I tried to load that but no luck["@blueprintjs/core" :as bp-core], it doesn't give any error, but the bp-core comes blankrequire.js to load monaco and that was conflicting under window.require facepalm using interop, rather than importing it in shadowClosure compilation failed with 1 errors
--- node_modules/puppeteer/lib/cjs/puppeteer/common/AriaQueryHandler.js:33
Cannot convert ECMASCRIPT_2018 feature "RegExp named groups" to targeted output language
Is there a way to configure the goog compiler to swap out the targeted output language to a later ecmascript and use the feature anyway through the shadow.edn or something or is there more to this kind of compatibility problem?:compiler-options {:output-feature-set :es-next} in your build config:bootstrap build I’m getting a lot of Uncaught ReferenceError: goog is not defined when the compiler is loaded in the application, I don’t get it during development and I’m not sure why… :thinking_face:{:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:module-hash-names true
:modules {:app {:entries []}}
:compiler-options {:warnings {:infer false}}
:build-hooks
[(scripts.gen-routes/watch)]
:devtools
{:watch-dir "resources/public"
:preloads [re-frisk-remote.preload
shadow.remote.runtime.cljs.browser]}
:dev
{:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:js-options
{:resolve {"dom-helpers/class/addClass" {:target :npm
:require "dom-helpers/addClass"}
"dom-helpers/class/removeClass" {:target :npm
:require "dom-helpers/removeClass"}}}}
:bootstrap {:target :bootstrap
:output-dir "target/cljsbuild/public/js/bootstrap"
:asset-path "/js/bootstrap"
;; These are the namespaces we expose to the bootstrapped compiler
:entries [cljs.js
dlstats.telemetry.common
dlstats.telemetry.schema]
:compiler-options
{:warnings {:infer false}}
;; many macro namespaces can't be evaluated in ClojureScript -
;; so we exclude them here to avoid runtime errors. Note that
;; it's ok to include code that consumes Clojure (jvm) macros,
;; but only selfhost-compatible macros can be evaluated "live".
:exclude #{cljs.js}}shadow-cljs release app bootstrap:optimizations :simple in your app build :compiler-options:advanced does not work with self-hostednpx shadow-cljs compile app --config-merge '{:js-options {:js-provider :external :external-index "foo.js"}}' and then let the regular depcheck run over that foo.js file:js-options {:resolve {"react-dom" {:target :npm :require "react-dom/profiling"}}}, optionally wrapped in :release {:js-options ...} when it should only apply to release builds?--config-merge--config-merge would allow me to do this via CLI:release {,,,} wrapping if I'm doing shadow-cljs release --config-merge ",,,"?Uncaught TypeError: module$node_modules$cytoscape$dist$cytoscape_esm.cytoscape is not a function
at Object.topology$graph$cytoscape_clj [as cytoscape_clj] (graph.cljs:36):require is just wrong:refer (cytoscape) when either :as cytoscape or :default cytoscape would be correct.(:require ["/js/cytoscape.esm.min" :default cytoscape])(cytoscape (clj->js {}))/js/cytoscape.esm.min? why not use the npm package? or is that not an npm package?(cytoscape (clj->js {}))
#object[eo$$module$js$cytoscape_esm_min [object Object]]cd react-native appears twice.Cannot find module 'uuid'\\nRequire stack my `shadow-cljs.edn` is something like:{:deps {:aliases [:cljs]} :builds {:handler {:target :node-library :output-to "handler.js" :exports-var example-demo.core/exports :compiler-options {:infer-externs :auto}} :test {:target :node-test :output-to "test.js"} :autotest {:target :node-test :output-to "test.js" And this only happen when I am trying this via
clojure -M:cljs:shadow release handler My cljs file look like:(ns example-demo.core (:require ["uuid" :as uuid])) (println "sample uuid: " (uuid/v4)) ;; this work properly when running in in the dev mode via REPL and check the eval the code via editor (defn sample [] ;; ... some code that return js/Promise ) (def exports #js {:sample sample}) I am trying to read through the documentation still I am not sure if someone know if something that I may have missed? Thanks
Carmine is compatible with GraalVM for example.node_modules as wellnode_modules of your project are considered. it does not look at node_modules of libraries, unless you specifically configured that via :js-packages-dirsBuild failure:
Failed to inspect file
/home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js
it was required from
/home/david/Documents/transparency/frontend/src/cljs/transparency/reporting/user_input.cljs
files outside the project are not allowed: /home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js
{:file #object[java.io.File 0x6910e23c "/home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js"]}
ExceptionInfo: files outside the project are not allowed: /home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js/home/david/Documents/whatever/:require?(:require ["@date-io/date-fns" :as date-fns-utils]):js-options :resolve or so?node_modules (or anything in it) symlinked?npm i --savenode_modules from the dep library, it works./home/david/Documents/transparency/frontend this is your project folder?/home/david/Documents/whatever would be the project folder2.15.1, should be ok again(defn book_consultation [req, res]
;/book_consultation
(let [query (.. req -query)
email (.-email query)]
(.on
(.get
https
""
(fn [resp]
(let [data ""]
(.on
resp
"end"
(fn [] (.send res (.. (.parse js/JSON data) -results))))))
"error"
(fn [err] (.log js/console (str "Error: " (.-message err))))))))-------------------------------------------------------------------------------- 12 | "" 13 | (fn [resp] 14 | (let [data ""] 15 | (.on -----------------^-------------------------------------------------------------- Cannot infer target type in expression (. resp on "end" (fn [] (.send res (.. (.parse js/JSON data) -results)))) -------------------------------------------------------------------------------- 16 | resp 17 | "end" 18 | (fn [] (.send res (.. (.parse js/JSON data) -results)))))) 19 | "error" --------------------------------------------------------------------------------
cljs.core.async.macros :refer [go] macro? Or would that not work on node.js?> /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:177 > return new XMLHttpRequest(); > ^ > ReferenceError: XMLHttpRequest is not defined > at goog.net.DefaultXmlHttpFactory.createInstance (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:177:5) > at Object.goog.net.XmlHttp (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:37:36) > at goog.net.XhrIo.createXhr (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xhrio.js:682:42) > at goog.net.XhrIo.send (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xhrio.js:530:20) > at Object.cljs_http$core$xhr [as xhr] (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/core.cljs:107:5) > at cljs_http$core$request (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/core.cljs:150:5) > at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:125:7 > at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:207:7 > at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:223:7 > at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:104:7With this code:
(defn book_consultation [req, res]
;/book_consultation
(let [query (.. req -query)
email (.-email query)]
(go (let [response (<! (http/get ""
{:with-credentials? false}))
name (get-in response [:body :results :name :first])])
(.send res (str "name is: " name)))))(ns functions.index
(:require ["firebase-functions" :as fun]
["https" :default https]
[cljs.core.async :refer [<!]] [cljs-http.client :as http]
[cljs.nodejs :as nodejs]
["xhr2" :as xhr2])
(:require-macros [cljs.core.async.macros :refer [go]]))
(set! js/XMLHttpRequest xhr2)
(defn book_consultation [req, res]
;/book_consultation
(let [query (.. req -query)
email (.-email query)]
(go (let [response (<! (http/get ""
{:with-credentials? false}))
name (get-in response [:body :results 0 :name :first])]
(.send res (str "name is: " name))))))(set! js/XMLHttpRequest (nodejs/require "xhr2"))(set! js/XMLHttpRequest xhr2){:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:devtools {:watch-dir "resources/public"
:preloads [re-frisk.preload]}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:release {}}
:test {:target :node-test
:test-dir "target/node-tests.js"
:autorun true
}}
:lein true}
And I’m getting this error:
https://gist.github.com/zendevil/6f29c2ac64d8be067e5e5f525b2f059e
How can I fix this?target/node-tests.js is an actual file? when it should be a directory?{...
:builds
{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true}}}:output-to:test-dir is from :browser-test onlywatch mode for a :target :node-script? I want to see the expressjs tracebacks in terms of my cljs code. I tried putting this in my shadow-cljs.edn
:compiler-options {:source-map true
:source-map-inline true}
But the only way I can get source maps is if I do release mode with --debug. Any help is much appreciated! 🙏watch in :node-script? do you have shadow-cljs installed in the project? you need the source-map-support package, either intalled directly or indirectly via shadow-cljsdeps.cljs file listing the :npm-deps. not sure if it does. the leinigen files won't do anythingmake shadow:
$ clj -m shadow.cljs.devtools.cli watch dev
Error building classpath. Could not find artifact com.datomic:dev-local:jar:0.9.203 in central (https://repo1.maven.org/maven2/)
I an guessing shadow does not use Datomic. But…who is looking for that dev-local jar? Wish I knew mvn. (I’ll start researching that,)
Now once upon a recent time I had installed some Datomic tools, so I am guessing one of them is trying to reach that dev-local.jar, but I do not recall what that could be or how to track it down and get rid of it. Not doing Datomic these days.~/.clojure/deps.edn or so?user.clj to start shadow-cljs and clj repl is right there. One can jump from cjl repl into cljs repl.
Is there a way to start perhaps a separate cljs repl? Or what's the best way to allow emacs to connect to both clj and cljs repl?deps.edn instead."
Is there something we should know, @pez? Some deficit in shadow-cljs? Performance, build quality, app size? Thx! 🙏:local/root stuff then it makes sense to use deps.edn(shadow.cljs.devtools.api/compile :docs {:verbose true) with the shadow build :modules {:main {:entries [doc] and that entrie/ns being
(ns docs
(:require [ :as app]
;; must require dynadoc.core so dynadoc's frontend can be built
dynadoc.core
[rum.core :as rum])
(:require-macros [dynadoc.example :refer [defexample]]))
Return's the error The required namespace "cljsjs.rangy-core" is not available, it was required by "paren_soup/core.cljs".
If i look at the namespace paren_soup/core.cljs it does require it right here https://github.com/oakes/paren-soup/blob/15f55ebb40ee30f75ca960d381ddebd094a76f3d/src/paren_soup/core.cljs#L6
but i'm unsure why it would "not available". Any advice on how to troubleshoot this would be appreciated.
Things to i have noticed:
• the author's minimal example of how to use the overall functionality used figwheel here: https://github.com/oakes/dynadoc-examples/tree/master/basic-deps-cljs
uses fighwheel with compiler optimizations set to :simple, which i have also enabled.
• if i remove the require on the dynadoc.core library in the cljs ns (e.g https://github.com/oakes/dynadoc-examples/blob/b23ef1003365d238847d1f1ea3f6d73149ae0bac/basic-deps-cljs/src/basic_deps_cljs/docs.cljs#L4) then it will compile, but the examples don't properly eval (e.g (defexample conj (conj [] 1)) doest show the expression result [1]. So i assume the comment on the code for the dyadoc.core require is still relevent. "must require dynadoc.core so dynadocs frontend can be built".
My intuition is that maybe shadow is pruning out cljsjs.rangy-core because it's never directly used?
but overall, I'm really unsure where to look.[:app] Configuring build. [:app] Compiling ... [:app] Build failure: The required JS dependency "querystring" is not available, it was required by "node_modules/url/url.js".even after installing with npm
shadow-cljs installed in the project, so npm install shadow-cljsnode-libs-browser polyfills package which polyfills node built-in packages for the browserjs/NodeList as seqable by default?
(seq (.getElementsByClassName js/document "terminal"))It seems to just work in a project compiled with shadow, so I wondered about this.
NodeList#values - so it satisfies cljs.core/js-iterable?Closure compilation failed with 1 errors --- node_modules/jspdf/dist/jspdf.es.min.js:10636 Duplicate let / const / class / function declaration in the same scope is not allowed.I assume this is an issue with the library code itself (as the error states). I'm just wondering if there's a "quick and dirty" fix to solve this, or if my only option is to fork and fix the dependency? The dependency: https://github.com/MrRio/jsPDF
e iced repl :main --force-shadow-cljs --with-cljs -A:dev
OK: CLJS option is enabled.
OK: shadow-cljs project is detected
OK: For shadow-cljs project, start watching instead of starting REPL.
shadow-cljs - config: /project/shadow-cljs.edn cli version: 2.8.64 node: v12.18.0
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.11.23 running at
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
GUARDRAILS IS ENABLED. RUNTIME PERFORMANCE WILL BE AFFECTED.
Mode: :runtime Async? false Throw? false
Guardrails was enabled because the CLJS Compiler config enabled it
[:main] Build completed. (287 files, 0 compiled, 0 warnings, 9.00s)
[2021-07-20 11:27:28.995 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns sheluchin.user}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding defrecord at (rewrite_clj/node/comment.clj:6:1). #:clojure.error{:phase :macroexpansion, :line 6, :column 1, :source "rewrite_clj/node/comment.clj", :symbol defrecord}
clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
clojure.lang.Compiler.macroexpand (Compiler.java:7075)
clojure.lang.Compiler.eval (Compiler.java:7161)
clojure.lang.Compiler.load (Compiler.java:7636)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:459)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
Caused by:
NullPointerException
clojure.lang.Compiler.maybeResolveIn (Compiler.java:7424)
clojure.core/ns-resolve (core.clj:4370)
clojure.core/ns-resolve (core.clj:4359)
clojure.core/resolve (core.clj:4372)
clojure.core/resolve (core.clj:4372)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core/reduce1 (core.clj:930)
clojure.core/set (core.clj:4113)
There is some suggestion that the issue is coming up because I'm including CLJ function calls in CLJS and shadow doesn't know what to do with it: https://clojurians.slack.com/archives/C68M60S4F/p1626790359069100?thread_ts=1625841427.419200&cid=C68M60S4F
Any suggestions for a fix? I can't seem to get around this one.(require '[shadow.cljs.devtools.server :as server]) (require '[shadow.cljs.devtools.api :as shadow]) (server/start!) (shadow/watch :app) (shadow/nrepl-select :app)and everything but the last step works fine. The last step fails with
:missing-nrepl-middleware.
Where should I dig?:jvm-opts ["-Xmx600m"] to limit to 600mb. that is usually plenty unless you run like 5 watch in parallelCannot read property 'ByteBuffer' of undefined. why that is so I do not know, don't know what it is trying to access that on. as always can't say much more without a reproducible repo[2021-07-22 05:26:30.681 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
OutOfMemoryError Java heap space
java.util.Arrays.copyOfRange (Arrays.java:4061)
java.lang.StringUTF16.newString (StringUTF16.java:1025)
java.lang.StringBuilder.toString (StringBuilder.java:449)
clojure.core/str (core.clj:555)
clojure.core/str/fn--5483 (core.clj:559)
clojure.core/str (core.clj:557)
clojure.core/str (core.clj:546)
shadow.build.targets.browser/flush-unoptimized-module-eval (browser.clj:540)
shadow.build.targets.browser/flush-unoptimized-module-eval (browser.clj:501)
shadow.build.targets.browser/flush-unoptimized-module (browser.clj:669)
shadow.build.targets.browser/flush-unoptimized-module (browser.clj:664)
shadow.build.targets.browser/flush-unoptimized/fn--40713/fn--40715 (browser.clj:691)
738m seems to work OK.watch size generally is fairly large. although 22mb is quite a lot even for watchnpm install, even run npm install -g shadow-cljs, after running shadow-cljs watch client, I get the following error:
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch client SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See for further details. NPM dependency "react" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.14.6 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... [:client] Build failure: The required namespace "goog" is not available, it was required by "devtools/preload.cljs".
project.clj instead[thheller/shadow-cljs "2.14.6"]
[org.clojure/clojurescript "1.10.866"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]shadow-cljs clj-repl then ( "goog/base.js")shadow.user=> ( "goog/base.js") #object[java.net.URL 0x5787e5d4 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/org/clojure/google-closure-library/0.0-20201211-3e6c510d/google-closure-library-0.0-20201211-3e6c510d.jar!/goog/base.js"]
shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.15.2 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... [:client] Build failure: The required namespace "goog" is not available, it was required by "devtools/preload.cljs".
slurp, see if its empty or somethinggoog and it appears to be there? maybe try wiping .shadow-cljs although that self wipes on versions updates so unlikely to help:log {:level :debug} in shadow-cljs.edn. maybe that logs something useful( "cljs/core.cljs") and ( "com/google/javascript/jscomp/Compiler.class")shadow.user=> ( "cljs/core.cljs") #object[java.net.URL 0x391d2130 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/org/clojure/clojurescript/1.10.879/clojurescript-1.10.879.jar!/cljs/core.cljs"] shadow.user=> ( "com/google/javascript/jscomp/Compiler.class") #object[java.net.URL 0x390c8c58 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20210505/closure-compiler-unshaded-v20210505.jar!/com/google/javascript/jscomp/Compiler.class"]
C:\Shared\orgpad>shadow-cljs watch client
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch client
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
[2021-07-23 20:29:33.876 - FINE] :shadow.cljs.devtools.server/clj-check - {:cli-pid "4900"}
[2021-07-23 20:29:34.274 - FINE] :shadow.cljs.devtools.server.nrepl/config - {:port 9000}
[2021-07-23 20:29:34.597 - FINE] :shadow.remote.relay.local/client-hello - {:client-id 1, :client-info {:connection-info {}, :since #inst "2021-07-23T18:29:34.588-00:00", :type :runtime, :lang :clj, :desc "JVM Clojure Runtime"}}
shadow-cljs - HTTP server available at
[2021-07-23 20:29:34.617 - FINE] :shadow.cljs.devtools.server.dev-http/http-serve - {:handler-state {:mime-mappings #object[io.undertow.util.MimeMappings 0x2d7166ee "npx create-cljs-project dummy cd dummy npx shadow-cljs browser-replshadow-cljs - config: C:\Shared\dummy\shadow-cljs.edn shadow-cljs - updating dependencies Retrieving org/clojure/core.async/1.3.618/core.async-1.3.618.jar from Retrieving org/clojure/tools.reader/1.3.6/tools.reader-1.3.6.jar from Retrieving commons-io/commons-io/2.10.0/commons-io-2.10.0.jar from Retrieving expound/expound/0.8.9/expound-0.8.9.jar from Retrieving ring/ring-codec/1.1.3/ring-codec-1.1.3.jar from Retrieving crypto-random/crypto-random/1.2.1/crypto-random-1.2.1.jar from Retrieving thheller/shadow-cljs/2.15.2/shadow-cljs-2.15.2-aot.jar from Retrieving ring/ring-core/1.9.4/ring-core-1.9.4.jar from shadow-cljs - dependencies updated shadow-cljs - server version: 2.15.2 running at shadow-cljs - nREPL server started on port 62056 [:browser-repl] Configuring build. [:browser-repl] Compiling ... [:browser-repl] Build completed. (119 files, 118 compiled, 0 warnings, 11.46s) cljs.user=>
npx shadow-cljs browser-repl I mean?[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build failure:
The required namespace "goog" is not available, it was required by "devtools/preload.cljs".
[2021-07-23 20:37:08.192 - FINE] :shadow.remote.relay.local/client-hello - {:client-id 3, :client-info {:connection-info {}, :since #inst "2021-07-23T18:37:08.191-00:00", :type :repl-session, :build-id :browser-repl, :proc-id "de1528ef-bc61-4bb8-869d-c0e23ee42dff"}}
cljs.user=>{:lein true
:jvm-opts ["-Dfile.encoding=UTF8" "-Xmx2G"]
:nrepl {:port 9000}
:ssl {:keystore "keystore.jks"
:password "openpassword"}
:log {:level :debug}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:module-loader true
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:admin {:entries [orgpad.client.views.administration.core]
:depends-on #{:main}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :eval}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}
:emails {:target :browser
:output-dir "emails/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.server.email.dev/init}}
:devtools {:http-root "emails"
:http-port 3600
:after-load orgpad.server.email.dev/mount-root
:watch-dir "emails"
:browser-inject :main}}
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}}}browser-repl also fails(defproject orgpad "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/tools.cli "1.0.206"]
[com.taoensso/sente "1.16.2"]
[com.taoensso/timbre "5.1.2"]
[bidi "2.1.6"]
; Use epoll on Linux for a lot more efficient polling of incomming packets
;
;
;
[io.netty/netty-transport-native-epoll "4.1.25.Final" :classifier "linux-x86_64"]
[aleph "0.4.6"]
[mount "0.1.16"]
[nrepl "0.8.3"]
[cprop "0.1.16"]
[cheshire "5.10.0"]
[clojure.java-time "0.3.2"]
[dnsjava/dnsjava "3.3.1"]
[org.postgresql/postgresql "42.2.12.jre7"]
[luminus-migrations "0.6.7"]
[conman "0.8.4"]
[expound "0.8.4"]
[yogthos/config "1.1.7"]
[selmer "1.12.22"]
[ring/ring-anti-forgery "1.3.0"]
[ring/ring-defaults "0.3.2"]
[ring/ring-devel "1.8.0"]
[ring/ring-codec "1.1.2"]
[ring/ring-json "0.5.0"]
[metosin/ring-http-response "0.9.1"]
[buddy/buddy-hashers "1.4.0"]
[co.deps/ring-etag-middleware "0.2.1"]
[bk/ring-gzip "0.3.0"]
[com.cognitect/transit-clj "1.0.324"]
[ring-basic-authentication "1.0.5"]
[ring-oauth2 "0.1.4"]
[clj-http "3.11.0"]
[hiccup "2.0.0-alpha2"]
[com.draines/postal "2.0.4"]
[cljc.java-time "0.1.8"]
[com.amazonaws/aws-java-sdk-s3 "1.11.1034"]
[byte-streams "0.2.5-alpha2"]
[camel-snake-kebab "0.4.1"]
[bouncer "1.0.1"]
[garden "1.3.10"]
[orgpad/volcano "0.1.2"]
[tea-time "1.0.1"]
[com.twelvemonkeys.imageio/imageio-jpeg "3.6.2"]
[com.twelvemonkeys.imageio/imageio-tiff "3.6.2"]
[com.twelvemonkeys.imageio/imageio-batik "3.6.2"]
[net.coobird/thumbnailator "0.4.13"]
[org.apache.xmlgraphics/batik-transcoder "1.14"]
[thheller/shadow-cljs "2.15.2"]
[org.clojure/clojurescript "1.10.879"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[reagent "0.10.0"]
[re-frame "0.12.0"]
[day8.re-frame/http-fx "v0.2.0"]
[hickory "0.7.1"]
[venantius/accountant "0.2.5"]
[pathetic "0.5.1"]
; Node.js dependencies, should duplicate dependencies from shadow-cljs.edn for Cursive.
[macchiato/core "0.2.17"]
[macchiato/env "0.0.6"]]
:plugins [[lein-garden "0.3.0"]
[lein-ns-dep-graph "0.2.0-SNAPSHOT"]]
:main orgpad.server.core
:min-lein-version "2.5.3"
:source-paths ["src"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"test/js"]
:resource-paths ["resources"]
:garden {:builds [{:id "orgpad"
:source-paths ["src"]
:stylesheet orgpad.css.core/orgpad
:compiler {:output-to "resources/public/css/orgpad.css"
:pretty-print? false}}
{:id "landing"
:source-paths ["src"]
:stylesheet orgpad.landing.css.core/landing
:compiler {:output-to "landing/resources/l/css/landing.css"
:pretty-print? false}}]}
:profiles
{:dev {:jvm-opts ["-Dconf=dev-config.edn" "-Xmx2G"]
:dependencies [[binaryage/devtools "0.9.10"]]
:plugins [[lein-doo "0.1.8"]]
:source-paths ["env/dev/clj"]
:resource-paths ["env/dev/resources" "landing/target"]}
:uberjar {:source-paths ["env/prod/clj"]
:omit-source true
:main orgpad.server.core
:aot [orgpad.server.core]
:uberjar-name "orgpad.jar"
:prep-tasks ["clean"
["garden" "once"]
["run" "-m" "shadow.cljs.devtools.cli" "release" "screenshot"]
["run" "-m" "orgpad.landing.build/build!"]
["run" "-m" "orgpad.server.email.build/build!"]
["run" "-m" "orgpad.build/release"]
"compile"]
:resource-paths ["env/prod/resources"]}})[binaryage/devtools "0.9.10"]. don't know why it fails on goog since everything depends on it[:client] Build failure: The required namespace "goog" is not available, it was required by "shadow/cljs/devtools/client/console.cljs".
:preloads. that one is added by watch, the other is added automatically when devtools are on the classpathlein version? although I don't really know why that would affect anythingC:\Shared\orgpad>shadow-cljs watch client shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? shadow-cljs - updating dependencies shadow-cljs - dependencies updated NPM dependency "react" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs [2021-07-23 20:48:16.503 - WARNING] TCP Port 9630 in use. shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.15.2 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - watching build :client [:client] Configuring build. [:client] Compiling ... Browserslist: caniuse-lite is outdated. Please run next command `npm update` [:client] Build completed. (1134 files, 1128 compiled, 0 warnings, 57.48s)
:dependencies [[binaryage/devtools "0.9.10"]]
[lein-ns-dep-graph "0.2.0-SNAPSHOT"] is? maybe that does something weird?/js/ from our server to Shadow-cljs. It seems to fix the issue.[:span {:className (str "absolute top-0 right-0 block h-3 w-3 transform -translate-y-1/2 translate-x-1/2 rounded-full ring-2 ring-white" color)}]
Ofc I can a case around of span, but is here easier/nicer solution? (sorry if that is beginner question)color is just a regular string it should be detected as a tailwind classUncaught Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefaultIs this functionality just not supported in react native or do I need to do something different?
shadow.js.shim.module are the npm requires that are addedthheller18:01:52 but you are using react-native anyways so you should figure out a way to let react-native compile the js files and not shadow-cljsso thought maybe there was a way to skip the babel step
shadow$provide object entry to each npm dependency. under normal circumstances that is populated before the depdencny is actually accessedjs/require but not via nsnode_modules package for those, which might be fine. don't know what kind of files you are trying to load:output-dir "app" you can (js/require "../js/some.jsx") to access the js file directly. again same limitations though, only on initial loadns like ["../gen/TaskList.js" :refer (TaskList)] , I’ve tried to replicate the same setup in my react native project but actually the generated file is different, even with exactly the same babel command and source filenode_modules package and load via ["your-package/TaskList" :refer (TaskList)]"?ns )var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TaskList = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _this = this,
_jsxFileName = "/src/stories/TaskList.tsx";
var TaskList = function TaskList() {
return _react.default.createElement(_reactNative.View, {
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 6,
columnNumber: 5
}
}, _react.default.createElement(_reactNative.Text, {
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 12,
columnNumber: 7
}
}, "Hello, world!"));
};
exports.TaskList = TaskList;@babel/runtime/helpers/interopRequireDefault in node_modules(def TaskList (.-TaskList (js/require "../src/gen/TaskList.js"))) with the babel approach, still going to try the npm package way but that at least confirms theres nothing wrong with shadow[react-modern-calendar-datepicker *:as* DatePicker] in requireimport 'react-modern-calendar-datepicker/lib/DatePicker.css'; like ["react-modern-calendar-datepicker/lib/DatePicker.css"] I get:
Failed to inspect file
/Users/prikshetsharma/Desktop/humboi/node_modules/react-modern-calendar-datepicker/lib/DatePicker.css
it was required from
/Users/prikshetsharma/Desktop/humboi/src/cljs/humboi/core.cljs
Errors encountered while trying to parse file
/Users/prikshetsharma/Desktop/humboi/node_modules/react-modern-calendar-datepicker/lib/DatePicker.css
{:line 1, :column 1, :message "primary expression expected"}:node-library target suitable for code that will be executed in the browser, rather than by node? Are there particular circumstances or edge cases to be aware of?watch and compile won't run in the browser. release only when processed by webpack or sonpm install without need a node runtime or npm installed.
It's a pure-clojure implementation of an interpreter" of package-lock.json that downloads packages from npm registry and untar it into node_modules.
Easy as run (npm/install {:path "."}), or with new -T, clj -T:npm install :path '"."'
For me, the advantage of this project is allow me to create advanced compiled cljs without need a nodejs runtime inside my docker image.
I would like to know from other cljs developers if this is an interesting lib before continue to work on this project.
https://github.com/souenzzo/tools.npmpackage.json or some other kind of config (eg. deps.edn). how would you get a package-lock.json without having npm or node installed in the first place? 😛node_modules. it'll run through babel:node-script then no that cannot do :modules. there is no currently available target for node that would support this:node-library already though? I assume it's not that hard to offer a library (which I want to do anyway) that exposes on CLI main namespaces as well:target :npm-module, but no matter what I do, I always get the error:
module.exports = goog.debug.Error;
^
TypeError: Cannot read property 'Error' of undefined
Am I doing something wrong here?:npm-module is pretty much dead. some recent updates to the closure-compiler,closure-library makes it pretty much a no-go:target :esm does but that not yet fully working for node since the focus was the browser. also still not sure what the current state of ESM in node is. I think it works but interop with CommonJS is kinda weird:esm is currently sort of hard coded to bundle all dependencies. which typically isn't what you want for node builds:npm-module? oh I see:esm a go.:modules from scittle:exports a required thing:entries from :exports so its definitely needed:entries but currently isn't:init-fn would work though. so no :exports just :init-fn, at least judging by the code 😛assoc :entries but later merges the :init-fn:exports anyways, don't know exactly what you are planning for nodejs/require<script type="application/x-scittle"> or did I miss something?tbd foo.cljs it will run foo.cljsjs/require again:npm-module, and now I'm migrating to :esm. It's giving me the following error:
file:///home/mauricio/projects/tbd/out/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
^
ReferenceError: WebSocket is not defined
at shadow$cljs$devtools$client$websocket$start (file:///home/mauricio/projects/tbd/out/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14):runtime :node in the build config, otherwise it assumes browser:esm needs some work for node targets. I only tested browser and deno as described in the clojureverse postrelease don't work (it fails with Error processing externs: JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10).shadow-cljs/builds/<build-id>/release?╰─>$ ls .shadow-cljs/builds/modules/ dev/
╰─>$ npx shadow-cljs release modules --verbose
shadow-cljs - config: /home/mauricio/projects/tbd/shadow-cljs.edn
[:modules] Compiling ...
-> build target: :esm stage: :configure
<- build target: :esm stage: :configure (3 ms)
-> Resolving Module: :tbd.core
<- Resolving Module: :tbd.core (226 ms)
-> Resolving Module: :tbd.main
<- Resolving Module: :tbd.main (0 ms)
-> Resolving Module: :tbd.reagent
<- Resolving Module: :tbd.reagent (0 ms)
{:type :empty-module, :mod-id :tbd.main, :shadow.build.log/level :info}
{:type :empty-module, :mod-id :tbd.reagent, :shadow.build.log/level :info}
-> build target: :esm stage: :compile-prepare
<- build target: :esm stage: :compile-prepare (2 ms)
Error processing externs:
JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10
Don't know if it helps:exports can't be empty. so you must either add :exports or :init-fn for each module. the clue is the :empty-module warning which should really be an error I guessContent-Type header or you can in your HTML directly via <meta charset="UTF-8">shadow-cljs.edn you can set :jvm-opts ["-Dfile.encoding=utf8"] to force it. delete .shadow-cljs and restart it after setting set:externs and :externs-file on their setup?
how do you use it? any good docs I can refer to?$ clojure -M -m shadow.cljs.devtools.cli release modules [:modules] Compiling ... "var ex_tbd.core_eval_code;\nvar shadow_esm_import;" Error processing externs: JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10
(str "ex_" (cljs-comp/munge (name module-id)) "_" (name export-name))
:exports and/or :init-fn for everything...:modules
{
:tbd.core {:exports {:eval_code tbd.core/eval!}}}
As a debugging step - same error happens$ node out/tbd.main.js test.cljs
file:///private/tmp/tbd/out/tbd.core.js:1817
export { tbd$core as init-fn };
^
SyntaxError: Unexpected token '-'
$APP.EB=this||self;ReferenceError: self is not defined
:init-fn tbd.core/eval_code{:tbd.core {:exports {:eval_code tbd.core/eval-code}}
:tbd.main {:init-fn tbd.main/init
:depends-on #{:tbd.core}}
:tbd.reagent {:init-fn tbd.reagent/init
:depends-on #{:tbd.core}}}:main {:init-fn ...} that didn't belong there$ clojure -M -m shadow.cljs.devtools.cli release modules [:modules] Compiling ... :module-id "tbd.core" "var tbd.core;\nvar shadow_esm_import;" Error processing externs: JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 7Note that
"var tbd.core;\nvar shadow_esm_import;" is the result of me printing bridge-name in esm.clj:tbd_core or so?ReferenceError: self is not defined
at file:///private/tmp/tbd/out/tbd.core.js:591:428tbd prefix. this isn't the browser so if a user is gonna import stuff they are going to import tbd/thing. tbd/tbd.thing doesn't do anythingtbd.core.js$ node out/tbd_main.js
file:///private/tmp/tbd/out/tbd_core.js:591
$APP.CB=function(a,b){return dh(Kq.i(a,xs.h(Yk,$APP.Bk.g(kp)),b))};$APP.N2=function(a){for(var b=Kc($APP.Pj(a,new $APP.H(null,1,5,$APP.I,[$APP.wq],null))),c=a;;){var d=$APP.w(c);if($APP.p(d)){var e=d;d=$APP.z.i(e,0,null);e=$APP.z.i(e,1,null);b=Si.i(b,d,$APP.xe(e)?e:new $APP.m(null,1,[$APP.oq,e],null));c=zd(c)}else return new $APP.m(null,2,[$APP.xq,$APP.xq.g(a),$APP.$p,Mc(b)],null)}};DB=function(){return null};$APP.EB=this||self;ba="closure_uid_"+(1E9*Math.random()>>>0);da=0;var Wm=String.prototype.trim?function(a){return a.trim()}:function(a){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]};$APP.g=pa.prototype;$APP.g.dc="";$APP.g.set=function(a){this.dc=""+a};$APP.g.append=function(a,b,c){this.dc+=String(a);if(null!=b)for(let d=1;d<arguments.length;d++)this.dc+=arguments[d];return this};$APP.g.clear=function(){this.dc=""};$APP.g.getLength=function(){return this.dc.length};$APP.g.toString=function(){return this.dc};var eh,fh,gh,Ba,Aa,ua,Mk,ya,sk,vd,Em,FB,Zh,dy,ok,xk,iD;eh={};fh={};$APP.md={};Ba=null;Aa=!0;ua=!1;Mk=!1;ya=null;sk=null;vd="undefined"!==typeof Symbol&&"function"===$APP.aa(Symbol)?Symbol.iterator:"@@iterator";
^
ReferenceError: self is not defined
at file:///private/tmp/tbd/out/tbd_core.js:591:428
self is from the newer closure library. try replacing it manually with globalThisself with globalThis got rid of the error. The next one is:
> ReferenceError: require is not defined in ES module scope, you can use import instead
I'm not sure where this comes from.js/require somewhere?shadow-cljs release modules --debug makes debugging much much easierjs/require to the script user["fs" :as fs] in the ns require:js-options {:keep-as-import #{"fs"}} in the build config:esm will attempt to bundle it I think(ns tbd.main
(:require [tbd.core :as tbd]
["fs" :as fs]))
> The required JS dependency "fs" is not available, it was required by "tbd/main.cljs".:js-options?self -> globalThis:
$ cat test.cljs (prn :foo) $ node out/tbd_main.js test.cljs :foo
node out/tbd_main.js test.cljswith the
:esm target.
But when I install the project with npm install -g and call it from some other directory, then I get:
$ tbd test.cljs
/usr/local/bin/tbd: line 2: import: command not found
/usr/local/bin/tbd: line 3: syntax error near unexpected token `('
/usr/local/bin/tbd: line 3: `const shadow_esm_import = function(x) { return import(x) };'
Should I configure npm to make it work well with the ecmascript module stuff somehow?$ node /usr/local/bin/tbd test.cljs
:npm-module approach might be betterimport. so maybe you need to pass an extra command line argument in the shebangimportbash /usr/local/bin/tbd gives exactly the same errors, that's why I think it's a shebang problem:npm-module is broken and pretty much unfixable in its current state. so don't build anything on top of that#!/usr/bin/env node fixed it, but I expect npm to do this for me so it becomes a cross-platform viable way of installing the tool:epm and :npm-module, I'm all ears.:node-library and then deal with the code splitting stuff later:node-library and will see what needs to be done for code splitting.:node-library here as well, not :node-script:advancedbin. that should be the runner. as seen here https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/package.json#L21npx shadow-cljs it'll call the runner.js and that will either locate the local node_modules/shadow-cljs install and run that or if not found use a global installrequire. So when someone writes js/require, we look up require from the global object and call it. This is why we need to put an override for require on the global object.node_modules when calling a globally installed CLI scriptrunner.js in shadow-cljs takes care of running either the LOCAL install OR the global install if that is missingjs/require calls within the scripts that are interpreted(js/require "./node_modules/my_lib") or sonode_modules which already has special rules so the user should NEVER type out node_modules in anything and instead they should be tying (js/require "my_lib")runner.js logic. it maintains which version of YOUR tool is loaded. either the local or the global. YOUR tool, so tbd. why would you want that for the code the USER is loading?js/require. since that is not actually global but belong to the module you are currently inmodule.createRequire based on the file it is currently eval'ingnode --input-type=module in the hashbang stuff:node-library approachshadow.esm/dynamic-import exposed to SCI so you can write:
(-> (js/import "csv-parse/lib/sync.js")
(.then (fn [csv]
(let [csv-parse (.-default csv)]
(-> (csv-parse "foo,bar,baz\n1,2,3" #js {:columns true})
(js->clj :keywordize-keys true)
prn)))))
I think the (require '["csv-parse/lib/sync.js" :default csv-parse]) can be supported instead, but I wonder why I needed to write .js... any idea here?
Should I wrap this function and automatically add this? That might be a bad idea. As (js/import "fs") works and (js/import "fs.js") for example doesn't.ns or require form and just let the user figure it out?(js/import "csv-parse")? specifying the extension when referencing a file is node stuff. I think thats a new requirement to esm, should have been that way always tbh(esm/dynamic-import "cvs-parse") ?(ns foo
(:require ["fs" :as fs]
["csv-parse/lib/sync.js" :default csv-parse]
[reagent.core :as r]
#_[reagent.dom.server :as rds]))
(println (str (.readFileSync fs "test.cljs")))
(prn :hello-the-end)
(prn (csv-parse "foo,bar"))
#_(prn (rds/render-to-string [:div [:p "hello"]]))
foo.js and you try to load it with:
(ns script (:require ["./foo"]))This doesn't work
module.createRequire if you must have a custom require (pretty sure there is a import equivalent)import { createRequire } from 'module';
I'm writing:
(:require ["module" :refer [createRequire]]])
but then I get:
The required JS dependency "module" is not available, it was required by "nodashka/core.cljs". Dependency Trace: nodashka/core.cljsNot sure if this is a correct message, since
module is built into nodeJS, I believe?(def createRequire (.-createRequire js/module)) (def require* (createRequire js/module.meta.url))I get:
ReferenceError: module is not defined in ES module scope
nodashka (current working name) globally using npm install -g nodashka and then have a local node_modules with e.g. the ink dependency, it can't find it. That is the problem I'm trying to solve.npm install -g ink then it does work. Perhaps this should just be how it works...?"module" to the :keep-as-import set in your build confignbb (yes, changed the name) as a global tool from npm and using it with node_modules in a local script dir. Do you think this is possible, or should a global tool always use the global npm deps?:default. use the official ["thing$default" :as x] instead of ["thing" :default x]import.meta.url in CLJS/shadow?(.. js/import -meta -url), and even js* but both failrelease you mean?js/shadow_esm_import.meta.url should workTypeError: Cannot read property 'url' of undefinedjs/shadow_esm_import is actually set(js/eval "import.meta.url")meta would have been null alreadyjs/eval:
import.meta.url
^^^^
SyntaxError: Cannot use 'import.meta' outside a modulecreateRequire(def require* (createRequire (js/eval "import.meta.url") #_(.. js/shadow_esm_import.meta.url -meta -url)))
tbd some-script.cljssome-script.cljspath/resolve"path" to :keep-as-import when you import it 😉node_modules(ns script (:require ["csv-parse/lib/sync" :as csv-parse] ["fs" :as fs] ["shelljs" :as sh]))Instead of (which was implemented via js/import):
(ns script (:require ["csv-parse/lib/sync.js" :default csv-parse] ["fs" :as fs] ["shelljs" :default sh]))
["csv-parse/lib/sync.js$default" :as csv-parse]csv-parse/foo working since its an alias:default at this point since it was rejected from CLJS properjs/require again like they are used to$ back to SCI proper so it can work for all CLJS applications using itimport stuff. I did manage to create require which resolves according to the file but you cannot require an ES Module with require, so I'll have to keep doing that using dynamic import.createImport instead of createRequireimport.meta.resolve also accepts a second argument which is the parent module from which to resolve from:
await import.meta.resolve('./dep', import.meta.url);"globalThis.shadow_esm_resolve = function(x,y) { return import.meta.resolve(x,y); }"
TypeError: (intermediate value).resolve is not a function
import.meta.resolve should be used, or, I should try something else than these ESM modules, or I should write my own resolver...:node-library and then making the code splitting worknode-library here: https://github.com/borkdude/nbb/tree/node-library
The compilation works nicely. It's just that I want code splitting so I can load "splits" dynamically, as needed.createRequire stuff while also loading my own ESM modules async. So now the programs look "node-ish" , while still leveraring your ESM target with module support.foo/deps.edn + foo/script.clj + clojure foo/script.clj will not use foo/deps.edn but only the local deps.edn/webapp/cljs/admin/shadow-cljs.edn
/tools/src/money.cljs
/test/money_test.cljs
/output/
/customer ; Separate cljs project also using tools, but not build by this shadow-cljs process
Here the relevant parts of the shadow-cljs.edn
{:source-paths ["src"
"../tools/src"
"../tools/test"]
:builds {:test {:target :node-test
:output-to "../output/node-tests.js"}}}
When I compile & run the tests (`pwd -> /webapp/cljs/admin`, I run node_modules/.bin/shadow-cljs compile test && node ../output/node-tests.js), I get this output:
shadow-cljs - config: /webapp/cljs/admin/shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
[:test] Compiling ...
[:test] Build completed. (51 files, 1 compiled, 0 warnings, 1.92s)
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
fs.js:114
throw err;
^
Error: ENOENT: no such file or directory, open '/webapp/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at global.SHADOW_IMPORT (/webapp/cljs/output/node-tests.js:52:15)
at /webapp/cljs/output/node-tests.js:1524:1
at Object.<anonymous> (/webapp/cljs/output/node-tests.js:1575:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
The file exists, but in the wrong location:
ls /webapp/{,cljs/admin/}.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js
ls: cannot access '/webapp/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js': No such file or directory
/webapp/cljs/admin/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js
My node version is v10.24.0 from the Debian Docker image I use and shadow-cljs is 2.15.2.../ in :output-to. that is supposed to be a directory in the project.:output-dir "../output" in addition to :output-to might work[cljsjs/mqtt "2.13.0-0"] as a dependency. In the code, we require [cljs.mqtt].
Problem: error from the shadow build app: "The required namespace "cljs.mqtt" is not available, it was required by "example/app.cljs"."
This all works fine in a web app we have, so I am guessing this is something to do with RN. Will shifting to interop with an RN MQTT NPM package help? We are trying: https://www.npmjs.com/package/react-native-paho-mqtt in the meantime./shadow-cljs.edn:
{:source-paths ["src" "test"]
:builds {:credit-assessment {:target :browser ;; Works!
:modules {:credit-assessment {:entries [credit-assessment.core]}}
:output-dir "../output/"
:asset-path "/cljs/output"}
:test {:target :node-test ;; Doesn't work :'(
:output-to "../output/node-tests.js"
:output-dir "../output"}}}
/src/credit_assessment/core.cljs (requires credit_assessment.criteria)
/src/credit_assessment/criteria.cljs:
(ns credit-assessment.criteria)
/test/credit_assessment/criteria_test.cljs:
(ns credit-assessment.criteria-test (:require [clojure.test :refer [deftest testing is are]] [credit-assessment.criteria :as creteria]))This works for the
credit-assessment build, but for the test build, I get this:
[:test] Compiling ... ------ ERROR ------------------------------------------------------------------- File: /test/credit_assessment/criteria_test.cljs:1:2 -------------------------------------------------------------------------------- 1 | (ns credit-assessment.criteria-test --------^----------------------------------------------------------------------- An error occurred while generating code for the form. ExceptionInfo: no source by provide: credit-assessment.criteria
:output-dir for multiple buildslein--- SHADOW-CLJS FAILED TO LOAD! ---------------------- This is most commonly caused by a dependency conflict. When using deps.edn or project.clj you must ensure that all required dependencies are provided with the correct version. You are using shadow-cljs version: 2.11.8 The important dependencies are: org.clojure/clojure "1.10.1" org.clojure/clojurescript "1.10.773" com.google.javascript/closure-compiler-unshaded "v20200830"
closure-compiler-unshaded in exclusions, not specifying clojure or clojurescript. Even including closure-compiler-unshaded in deps.edn. Is that a wrong version of closure-compiler-unshaded that is somehow being picked up? Any way to really start from scratch, as there's nothing actually wrong with this particular deps.edn/Fulcro project.The error encountered was:
Syntax error macroexpanding at (closure.clj:70:5).
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:619)
at shadow.build.js_support$eval12458$loading__6721__auto____12459.invoke(js_support.clj:1)
at shadow.build.js_support$eval12458.invokeStatic(js_support.clj:1)
at shadow.build.js_support$eval12458.invoke(js_support.clj:1)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:703)
at shadow.build.resolve$eval10708$loading__6721__auto____10709.invoke(resolve.clj:1)
at shadow.build.resolve$eval10708.invokeStatic(resolve.clj:1)
at shadow.build.resolve$eval10708.invoke(resolve.clj:1)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:2793)
at shadow.build.api$eval10700$loading__6721__auto____10701.invoke(api.clj:1)
at shadow.build.api$eval10700.invokeStatic(api.clj:1)
at shadow.build.api$eval10700.invoke(api.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7177)
at clojure.lang.Compiler.eval(Compiler.java:7166)
at clojure.lang.Compiler.load(Compiler.java:7636)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:3204)
at shadow.build$eval10694$loading__6721__auto____10695.invoke(build.clj:1)
at shadow.build$eval10694.invokeStatic(build.clj:1)
at shadow.build$eval10694.invoke(build.clj:1)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:3204)
at shadow.cljs.devtools.api$eval2236$loading__6721__auto____2237.invoke(api.clj:1)
at shadow.cljs.devtools.api$eval2236.invokeStatic(api.clj:1)
at shadow.cljs.devtools.api$eval2236.invoke(api.clj:1)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:1289)
at shadow.cljs.devtools.cli_actual$eval173$loading__6721__auto____174.invoke(cli_actual.clj:1)
at shadow.cljs.devtools.cli_actual$eval173.invokeStatic(cli_actual.clj:1)
at shadow.cljs.devtools.cli_actual$eval173.invoke(cli_actual.clj:1)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.load(RT.java:459)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6839.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.core$serialized_require.invokeStatic(core.clj:6079)
at clojure.core$requiring_resolve.invokeStatic(core.clj:6088)
at clojure.core$requiring_resolve.invoke(core.clj:6082)
at shadow.cljs.devtools.cli$_main$fn__166.invoke(cli.clj:70)
at shadow.cljs.devtools.cli$_main.invokeStatic(cli.clj:69)
at shadow.cljs.devtools.cli$_main.doInvoke(cli.clj:67)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.main$main_opt.invokeStatic(main.clj:514)
at clojure.main$main_opt.invoke(main.clj:510)
at clojure.main$main.invokeStatic(main.clj:664)
at clojure.main$main.doInvoke(main.clj:616)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:40)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.javascript.rhino.IR.name(IR.java:407)
at com.google.javascript.jscomp.VarCheck.<clinit>(VarCheck.java:97)
at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:243)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1733)guava dependency. frequently happens with datomic on the classpathyarn shadow-cljs server . At least we have a solution.deps.edn moving the com.datomic/datomic-pro map-entry from :deps to all the aliases that need datomic. So datomic should not be on the classpath that shadow-cljs.edn uses, as shadow-cljs.edn has :deps true , and thus doesn't use any of the aliases, just the default :deps. Did not help unfortunately 😞clj -Stree or so what your dependencies look likegoogle-apps-clj was the remaining culprit. So problem fixed. Now I've got the much more minor problem of dependencies duplicated in 5 aliases. I'm not sure there's a way to tidy this up (merge maps) in deps.edn. But overall 😄.shadow-cljs.edn. works perfectly fine unless you need git deps{:deps false} in shadow-cljs.edn ?:dependencies and :source-paths listed there. don't even set :deps:deps {:aliases [:cljs]}. That could be another alternative better setup than what I've got now. I'll try not using deps.edn at all first though.shadow-cljs.edn :dependencies a good solution. I've removed cljs-only libs from deps.edn and the few that now exist in both config files are both clj and cljs anyway. So overall the whole thing makes sense. Works for development but I may have broken things for production - maybe an uberjar is created only from deps.edn artifacts and thus now won't include cljs-only libs.:builds of the shadow-cljs.edn there is a :prod key. So I suppose it is used as part of creating the uberjar. So the uberjar will contain compiled javascript and no need for any cljs-only libs in the deps.edn.release version of a build. if you have a :prod build you are likely using shadow-cljs wrong since you should have the same build for development watch and production releasenpx shadow-cljs help rungives no helpful information
> (def a 3) Execution error (TypeError) at (<cljs repl>:1). undefined is not an object (evaluating 'cljs.user.a = (3)') nil cljs.user=>What could be the potential cause?
in-ns does not create a namespace that doesn't exist. so if you have a custom :repl-init-ns then cljs.user does not exist(ns cljs.user)(defn navigate! [match _] (prn "match is " match) (e/common-navigate match))Error:
app.js:1552 TypeError: Cannot read property 'common_navigate' of undefined
at humboi$core$navigate_BANG_ (core.cljs:257)
at reitit$frontend$easy$start_BANG__$_rfe_on_navigate (easy.cljs:39)
at Object.eval [as reitit$frontend$history$History$_on_navigate$arity$2] (history.cljs:128)
at Object.reitit$frontend$history$_on_navigate [as _on_navigate] (history.cljs:12)
at Object.eval [as reitit$frontend$history$History$_init$arity$1] (history.cljs:125)
at Object.reitit$frontend$history$_init [as _init] (history.cljs:10)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (history.cljs:170)
at Object.reitit$frontend$easy$start_BANG_ [as start_BANG_] (easy.cljs:36)
at Object.humboi$core$start_router_BANG_ [as start_router_BANG_] (core.cljs:487)
at Object.humboi$core$init_BANG_ [as init_BANG_] (core.cljs:504)
the e/ namespace definitely exists.1 (:require
2 [day8.re-frame.http-fx]
3 [reagent.dom :as rdom]
4 [reagent.core :as r]
5 [re-frame.core :as rf]
-- 6 [goog.events :as events]
-- 7 [goog.history.EventType :as HistoryEventType]
8 [markdown.core :refer [md->html]]
9 [humboi.ajax :as ajax]
10 [reitit.core :as reitit]
11 [reitit.frontend.easy :as rfe]
12 [clojure.string :as string]
-- 13 ["@typeform/embed-react" :refer [PopupButton]]
-- 14 [cljs.core.async :refer [go]]
-- 15 [cljs.core.async.interop :refer-macros [<p!]]
16 #_["use-magic-link" :as useMagicLink]
17 #_[accountant.core :as accountant]
18 [humboi.events :as e]
19 [humboi.subs :as s]
-- 20 [react :refer [useEffect]]
21 [react-calendar :default Calendar])
And this is the e/ namespace’s ns declaration:1 (ns humboi.events
-- 1 (:require-macros [humboi.macros :refer [db-event fx-event sub]]
2 [humboi.env :refer [endpoint blockchain-provider]])
3 (:require
-- 4 [re-frame.core :refer [reg-event-fx reg-fx] :as rf]
5 [ajax.core :as ajax]
6 [reitit.frontend.easy :as rfe]
7 [reitit.frontend.controllers :as rfc]
8 [cljs.core.async :refer [go]]
9 [cljs.core.async.interop :refer-macros [<p!]]
10 ["magic-sdk" :refer [Magic]]
11 ["@magic-ext/oauth" :refer [OAuthExtension]]
-- 12 [humboi.macros :refer [deep-merge]]
-- 13 [humboi.subs :as s]
-- 14 [web3 :as Web3]
-- 15 ["@metamask/detect-provider" :as detectEthereumProvider]
16 ["@alch/alchemy-web3" :refer [createAlchemyWeb3]]))(find-ns 'humboi.events) gives nil in the first fileshadow-cljs - remote-error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}bubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}defaultPrevented: falseeventPhase: 0isTrusted: truepath: []returnValue: truesrcElement: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}target: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}timeStamp: 166289.09999990463type: "error"[[Prototype]]: Event
eval @ shared.cljs:305
shadow$cljs$devtools$client$shared$remote_error @ shared.cljs:18
eval @ websocket.cljs:29
error (async)
shadow$cljs$devtools$client$websocket$start @ websocket.cljs:26
eval @ shared.cljs:324
eval @ shared.cljs:345
setTimeout (async)
eval @ shared.cljs:341
eval @ shared.cljs:297
shadow$cljs$devtools$client$shared$remote_close @ shared.cljs:17
eval @ websocket.cljs:24
1 (go
2 (let [web3 (createAlchemyWeb3 (blockchain-provider))]
3 (js/console.log "deploying contract "
4 (.-issuer (-> db :user))
5 "."
6 "web3" web3
7 (.then
8 (.send
9 (.buy
10 (.-methods
11 (new (.. web3 -eth -Contract)
12 (:contract-json db)
13 (-> db :creation :creation/contract-address)))
14 ;; magic id
15 (.-issuer (-> db :user)))
16 (clj->js {:value (* (:creation-input-value db)
17 1000000000000000000)
18
19 :from (->
20 (<p!
21 (.request
22 (:ethereum db) (clj->js {:method "eth_ requestAccounts"})))
23 (get 0))})
24 (fn [err transaction-hash]
25 (prn "err is;; " err)
26 (prn "transaction has is " transaction-hash)))
27 (fn [contract-instance]
28 (js/console.log "new contract instance is " contract-instanc e))))))Cannot infer target type in expression (. inst_62878 (buy inst_62880))
^js tags don't work properly in go.then and <p!, pick one and stay with itgo. you can (set! *warn-on-infer* false) directly after the ns to turn warnings off for that filebrowser.cljs:39 Failed to load humboi/events.cljs SyntaxError: Unexpected token '.'
at eval (<anonymous>)
at Object.goog.globalEval (app.js:486)
at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:24)
at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:36)
at eval (browser.cljs:57)
at eval (env.cljs:236)
at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:208)
at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:244)
at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:43)
at eval (browser.cljs:93)
But it doesn’t say what line the . is on{:method "eth_ requestAccounts"} or (js/console.log "new contract instance is " contract-instanc e)(* (:creation-input-value db) 1000000000000000000):dev-http {9500 {:root "public"
:push-state/headers {"content-type" "text/html"
"Cross-Origin-Opener-Policy" "same-origin"
"Cross-Origin-Embedder-Policy" "require-corp"}}}:dev-http property. Suppose I have two http handlers configured in shadow-cljs.edn. If I launch clj and then call (start-server!), everything works as expected — I get two http servers:
$ cat shadow-cljs.edn
$ head -n 5 shadow-cljs.edn
{:deps true
:nrepl {:port 7888}
:socket-repl {:port 9002}
:dev-http {9666 {:handler dev.handler/handler}
9667 {:handler dev.handler2/handler}}
$ clj
Clojure 1.10.3
user=> (do (require '[shadow.cljs.devtools.server :as shadow.server])
(def config (shadow.server/load-config))
(shadow.server/start! config))
...
shadow-cljs - HTTP server available at # 1️⃣ First server
...
shadow-cljs - HTTP server available at # 2️⃣ Second server
...
:shadow.cljs.devtools.server/started
user=>
Now I would like to turn on the second http server using a CLI argument. I remove the second http server from shadow-cljs.edn and configure it during runtime. For the simplicity of the example, I don't do any CLI arguments parsing here, but instead just prepare the config on the fly:
$ head -n 5 shadow-cljs.edn
{:deps true
:nrepl {:port 7888}
:socket-repl {:port 9002}
:dev-http {9666 {:handler dev.handler/handler}
#_#_9667 {:handler dev.handler2/handler}}
$ clj
Clojure 1.10.3
user=> (do (require '[shadow.cljs.devtools.server :as shadow.server])
(def config (shadow.server/load-config))
(def config* (assoc-in config [:dev-http 9667] {:handler 'dev.handler2/handler}))
(shadow.server/start! config*))
...
shadow-cljs - HTTP server available at # 1️⃣ Only the first server
...
:shadow.cljs.devtools.server/started
user=>
Though the configs are seemingly the same during runtime, second server doesn't start anymore.
I'd appreciate any pointers to the solution!:node-library using https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_exports:node-library?:node-library . Should have copy/pasted 😅:npm-module is pretty much dead anyways so prefer to use :node-library if you can:npm-module already only exports things marked with ^:exportshadow-cljs.edn again and does not respect server/start! arguments. it loads the config itself since it automatically adjusts the servers if you change them while running:handler you should be using your own server. I even regret adding support for handler in the first place.npm i:Compilation failed! The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js". Dependency Trace: humboi/app.cljs humboi/core.cljs humboi/events.cljs node_modules/@alch/alchemy-web3/dist/cjs/index.js node_modules/web3/lib/index.js node_modules/web3-eth/lib/index.js node_modules/web3-eth-accounts/lib/index.js node_modules/crypto-browserify/index.js node_modules/create-hash/browser.js node_modules/cipher-base/index.js node_modules/stream-browserify/index.js
node_modules/readable-stream folder, can you find the writable.js in there? There may be a version mismatch between what stream-browserify expects and what you have installed.The required JS dependency "stream" is not available, it was required by "node_modules/cipher-base/index.js". Dependency Trace: humboi/app.cljs humboi/core.cljs humboi/events.cljs node_modules/@alch/alchemy-web3/dist/cjs/index.js node_modules/web3/lib/index.js node_modules/web3-eth/lib/index.js node_modules/web3-eth-accounts/lib/index.js node_modules/crypto-browserify/index.js node_modules/create-hash/browser.js node_modules/cipher-base/index.js
npm i -s stream makes no difference<project>/node_modules/shadow-cljs. this should also ensure that <project>/node_modules/node-libs-browser exists?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0575776c6e766d6071766d647768644555776c6e766d60717628486466476a6a6e2855776a"}, :content ("[email protected]")}stream-browserify package. did you sort of the version conflict? or which version of shadow-cljs do you use?:esm module, so that the npm installed one will be used instead of using a built-in version of React. I thought I could do this with:
{:deps true
:builds {:modules {:js-options {:keep-as-import #{"fs" "module" "path"}
:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}}}
:compiler-options {:infer-externs :auto}
:target :esm
:runtime :nodeshadow-cljs - failed to load 0 ReferenceError: React is not defined
React:keep-as-import:keep-as-import just tells the compiler to not bundle a thing and instead let the runtime import sort it out (so node in your case)["react" :as react] might not work, might need to be ["react$default" :as react]^
TypeError: d.Sf is not a function
at x8.$APP.g.flush_render (file:///private/tmp/tbd/out/nbb_reagent.js:44:344)
at x8.$APP.g.flush_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:313)
at x8.$APP.g.run_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:414)
at Timeout.a [as _onTimeout] (file:///private/tmp/tbd/out/nbb_reagent.js:43:50)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)shadow-cljs release thing --pseudo-names or --debug--debug it started working ...--pseudo-names as well:pseudo-names true and :source-map true? that shouldn't affect externs related thingsnbb/externs.txt with:
componentQueueand now it works...
keep-as-import-ed "react", it won't use a local react.
$ nbb ink-demo.cljs
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react' imported from /usr/local/lib/node_modules/nbb/out/nbb_reagent.jsPerhaps I should just split out the reagent module into a separate npm package and just depend directly on react there, without keep-as-import.
npm install -g nbb --no-optional now doesn't install reactwatch without live reloading? I'm trying out Pulumi for infrastructure as code and have been successful using compile but that's a longer feedback cycle. When using watch shadow is waiting to make a connection I think via a websocket when I run pulumi up. Looking for a way for watch to only compile the code, not reload.:devtools {:enabled false} on your build does this I think;; Here is some dev-specific config
:dev {:compiler-options {:devcards true}}sci which is quite cool. Obviously misses lots of things but I think its promising https://martinklepsch.org/100/interactive-design-system-docs.html is the where the compiler env is checked and then is an example usage. there are 24 such checks in that filereact to be optional you'd need to use the same createRequire path you used for the intepreterNODE_PATH or NODE_INLUDE_PATH or something like thatnbb-runner and expose an additional nbb script which is bash on linux/macOS and .cmd or so on Windows with:
#!/usr/bin/env bash NODE_PATH=$NODE_PATH:$PWD/node_modules nbb-runner
node_modulesmodule.constructor._initPaths which, if this isn't _too_ hacky, is my preferred solution as this makes deploying stuff much easiernbb.main but it complained about module not being available in ESM module scope"module" require?(js/module.constructor._initPaths) etcrequire('module').Module._initPaths()import.meta.url to pass it to the createRequire(js/require ...), that is not allowed(:require ["module" :as m]) (m/_initPaths).Module seems to be a circular reference back to itself so you can skip that$ node out/nbb_main.js script.cljs file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3 import$module._initPaths(); ^ ReferenceError: import$module is not defined
nbb.mainscript.cljs or in nbb code?import$module is the correct name. dunno why its not defined(when require
(set! (.-require goog/global) require))(js/require "foo") work in the interpreted code$ node out/nbb_main.js script.cljs file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3 module["constructor"]._initPaths(); ^ ReferenceError: module is not defined in ES module scope
:require require is passed to the namespace evaluation logic, but users can also do interop on the global object directlyconstructor thats pointlessmodule without a require or import doesn't exist. that is expected.$ node out/nbb_main.js script.cljs file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3 module._initPaths(); ^ ReferenceError: module is not defined in ES module scope
module you are talking aboutmodule you get in commonjs code is different from the one you get via the "module" modulemodule you'd go via .constructor or .Module the others do not$ node out/nbb_main.js script.cljs
file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3
cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([module], 0));
^
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/borkdude/git/nbb/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3:102
at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)
(I just realized I left out the interesting bit perhaps)(prn js/module))m obviouslyjs/module is not supposed to exist(prn m) (prn (._initPaths m))
#object[Object] nil
nil shows that _initPaths is not therenpm remove -g nbb doesn't clear thatNODE_PATH stuff$ npx shadow-cljs --force-spawn test modules shadow-cljs - config: /Users/borkdude/git/nbb/shadow-cljs.edn shadow-cljs - starting via "clojure" TBDI was wondering how to test my
;target :esm build.:target :node-test?:target :esm somehow? I don't know really where to start$ npx shadow-cljs compile test
shadow-cljs - config: /Users/borkdude/git/nbb/shadow-cljs.edn
shadow-cljs - starting via "clojure"
[:test] Compiling ...
========= Running Tests =======================
file:///Users/borkdude/git/nbb/target/test/test.js:5
var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/test/dev/out/cljs-runtime';
^
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/borkdude/git/nbb/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/borkdude/git/nbb/target/test/test.js:5:26
at file:///Users/borkdude/git/nbb/target/test/test.js:1571:3
at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)packages/nbb with its own package.json in that dirtest-out with its own package.json. really up to you.cjs file like the error suggests. many possible solutionstest only for the test build?:deps true:aliases [:test] on the level of the build for example which would pull in :extra-paths ["test"]:deps true but I'll use :deps {:aliases [:test]} then:esmclassProperties
static ERROR = ERRORIs there a way to configure Shadow to work with that?
(ns app.client.hyper (:require ["hyperspace" :refer [Client Server]]))and this is the error
Failed to inspect file
/media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/arpeecee/index.js
it was required from
/media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/hrpc-runtime/rpc.js
Errors encountered while trying to parse file
/media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/arpeecee/index.js
{:line 60, :column 15, :message "'(' expected"}
But I know from trying the same thing with a create-react-app project that the problem is the experimental classProperties, it suggested using a https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties and pointed out this https://github.com/mafintosh/arpeecee/blob/master/index.js#L60 as the reason of the error.2.15.2["fs" :as fs] from two different namespaces, say nbb.main and nbb.core, I get
ReferenceError: import$fs is not defined
at C8 (file:///Users/borkdude/git/nbb/out/nbb_main.js:8:313)
after advanced compilation.
After this workaround, I got it working again:
https://github.com/borkdude/nbb/commit/df0edd3c2a560ea3954dc6943a228c3d49668e75:compiler-options {:js-provider :import} so you don't have to list every single package in :keep-as-import, it'll just import everythingThe required JS dependency "fs" is not available, it was required by "nbb/core.cljs".
:js-options {:js-provider :import} directly on the toplevel of the build, then I get a different error msg:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
:js-options {:js-provider :import}.touch the clj file, then it does get updated. This is understandable. But I'm observing what looks like cached macro output when running release. What's the easiest way to force re-running all macros?:cache-blockers so I don't know if it's the same thing, but as a quick and dirty solution, it appears that rm -rf .shadow-cljs does cause a refresh. Since this works reliably in a toy example based off of shadow-cljs/quickstart-browser.git ~most likely~ my pipeline was messed up:node-test target, which means that all JS requires are resolved by node. so your (:require ["react-native-swipe-list-view" :as swipe-list-view]) is just directly converted to a require("react-native-swipe-list-view") with no further processing by shadow-cljs for thisimport:node-test. I was missing mock for package for testing and that's why it was crashing.index.js with ^export s for JavaScript consumers.
• Ship cljs source up to npm also.
• cljs consumers can add node_modules/mylibrary/src to their :source-paths and add the library to package.json instead of using other deps mechanisms (as they do now with js deps).
I wonder if it would be interesting/good if shadow-cljs automatically pickedup cljs sources from inside node_modules subdirs and added them to the cljs classpath so that this could become a standard practice for shipping cljs libs on npm? :thinking_face:deps.cljs file in the library containing {:npm-deps {"some-dep" "version"}}Uncaught ReferenceError: $map__115133 is not defined
at Object.shadow$cljs$devtools$client$env$src_is_loaded_QMARK_ [as src_is_loaded_QMARK_] (env.cljs:257)
at eval (env.cljs:279)
at eval (core.cljs:5203)
at eval (core.cljs:5203)
at Object.eval [as sval] (core.cljs:3452)
at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3509)
at Object.cljs$core$seq [as seq] (core.cljs:1236)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2493)
at Object.eval [as cljs$core$IReduce$_reduce$arity$3] (core.cljs:3519)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2565)
Looks like something related to path? but the build succeed without errors, and page load with errors.:js-options {:keep-as-import #{"fs" "module" "path"
"react" "react-dom"}}
in your build. Wild guess.2.15.3 is already out2.15.3, re-frame 1.2.0 etc.) that happens only in the CI environment:
... shadow-cljs - dependencies updated [:webapp] Compiling ... The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs".
remote: The required namespace "react" is not available, it was required by "reagent/core.cljs".npm installpackage.json look like?npm install is not getting run as part of what is going to heroku["shell" "npm" "install"]<project>/shadow-cljs.edn and <project>/rn and <project>/rn-web or whateverpackage.json:js-package-dirs accordingly https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules:js-options {:js-package-dirs ["rn/node_modules"]}:advanced compiled :bootstrap host? I’m trying to figure out a work around but it’s not clear why it breaks down after advanced compilation.:advanced renames everything, deletes stuff that is unused, inlines stuff, etc:simple though:advanced:simplevars namespace but not sure I’m using it correctly.-A:aliases when I build from the command line, but I’m compiling from the repl and not sure how to pass the aliases optionns :require it won't be includedfoo/*.cljs to an output-dir of bar/*.js? From reading the guide it looks like I have to explicitly specify every file/namespace symbol?:modules / code splitting? E.g. for nbb I have:
{:deps {:aliases [:test]}
:builds {:modules {:js-options {:keep-as-import #{"fs" "module" "path"
"react" "react-dom"}}
:compiler-options {:infer-externs :auto}
:target :esm
:runtime :node
:output-dir "out"
:modules
{:nbb_core {:init-fn nbb.core/init}
:nbb_main {:init-fn nbb.main/main
:depends-on #{:nbb_core}}
:nbb_reagent {:init-fn nbb.reagent/init
:depends-on #{:nbb_core}}
:nbb_promesa {:init-fn nbb.promesa/init
:depends-on #{:nbb_core}}}
:build-hooks [(shadow.cljs.build-report/hook
{:output-to "report.html"})]}
:test {:target :node-test
:ns-regexp "-test$"
:output-to "target/test/test.cjs"
:autorun true}}}nbb_reagent.js file and a nbb_promesa.js filecljs/*.cljs files, and shadow will generate pages/api/*.js files for me, perhaps its not worth it and I should just learn javascript properly though...node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js:13
constructor is missing a call to super()
Has anyone run into this ? Or know of a fix?:target? jsdom typically runs in node but the error you get is from the closure-compiler processing the code, which is only done for browser builds?16.4.0 of js-dom. What's the version there?^15.2.1 then you should be able to npm i at the top level and it will use the updated version instead.(shadow.cljs.devtools.api/repl :the-build-id {:runtime-id 123})shadow-cljs: #4 ready!(shadow.cljs.devtools.api/repl-runtimes :the-build-id) to get the data from the REPL without the UI[{:since #inst"2021-08-14T06:20:06.623-00:00",
:proc-id "3133b4c9-82b9-4144-a0dc-68e8daddfdae",
:connection-info {:remote true, :websocket true},
:client-id 4,
:user-agent "Chrome 537.36 [Win32]",
:type :runtime,
:lang :cljs,
:build-id :browser,
:host :browser,
:dom true}
{:since #inst"2021-08-14T06:20:07.205-00:00",
:proc-id "3133b4c9-82b9-4144-a0dc-68e8daddfdae",
:connection-info {:remote true, :websocket true},
:client-id 5,
:user-agent "Chrome 537.36 [Win32]",
:type :runtime,
:lang :cljs,
:build-id :browser,
:host :browser-worker,
:dom false}]:client-id from that list#X ready! messages, with increasing id numbers. (And the id:s are bumped accordingly.) I’m using the :react-native target and have started a web and an iOS client. Looks like so after a while:
= web #5 ready! #7 ready! #8 ready! #10 ready! #12 ready! #14 ready! #16 ready! #17 ready! #20 ready! = iOS Simulator #4 ready! #6 ready! #9 ready! #11 ready! #13 ready! #15 ready!What could be part of this is that I started the apps, then closed the lid on my laptop and made some breakfast to the family. Now opening the laptop again there is this. I think I just managed to reproduce the behaviour when closing and re-opening, but only in the web app. The runtime info looks like so:
[{:connection-info
{:remote true,
:websocket
true},
:since
#inst "2021-08-14T08:45:55.502-00:00",
:host
:react-native,
:type :runtime,
:lang :cljs,
:build-id :app,
:proc-id
"165ac90e-ac63-4516-9453-3c49e4f85815",
:client-id 15}
{:connection-info
{:remote true,
:websocket
true},
:since
#inst "2021-08-14T08:53:30.446-00:00",
:host
:react-native,
:type :runtime,
:lang :cljs,
:build-id :app,
:proc-id
"165ac90e-ac63-4516-9453-3c49e4f85815",
:client-id 20}]
I can select the repl as per above, and evaluations happen in the right app.The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
:since doesn’t change. Can I rely on that, as long as the app is not reloaded?tap> and the inspect UI runs over shadow.remote, so anything the UI displays you have access to as well"op" "shadow.remote" or so. haven't really looked into it too much yet(:require ["react-bootstrap" :as bs])But when I console.log
bs roughly half the keys (component names) have no values
Image: {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, render: ƒ}
InputGroup: {$$typeof: Symbol(react.forward_ref), Text: {…}, render: ƒ, Radio: ƒ, Checkbox: ƒ, …}
ListGroup: {$$typeof: Symbol(react.forward_ref), Item: {…}, render: ƒ}
ListGroupItem: {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, render: ƒ}
Modal: undefined
ModalBody: undefined
ModalDialog: undefined
ModalFooter: undefined
Any idea why Modal and friends would not get imported?__esModule: true(js/require "react-bootstrap/Tabs") does load the correct function component(js/require "react-bootstrap"):target is this?:browser but it’s an electron app with node integration in the renderer:js-options {:entry-keys ["browser" "main"]} in your build config"module" fixed it, that’s strange"module"?build/index.js to the root level and then doing a find/replace to fix the paths in the file, so is there a reason why shadow wouldn’t allow you to do this automatically?:output-dir "." might also work but not recommended, no guarantee that shadow-cljs won't overwrite a file that you might need for something. preferable to have its own directory that you can delete at any point"." but it doesn’t generate the correct paths for the js/require calls, then I pretty much did what you’ve suggested there:target :esm might also be an option. been a while since I looked at react-native stuff, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116(js/alert "foo") I don't see anything in the browser and doing @(rf/subscribe [:bar]) returns nil when I would expect it to contain values from the app-db. Any help would be appreciated!:dev build. the REPL picks the one that connects first and evals there:dev builds are an anti pattern in shadow-cljs. builds always represent the dev and release parts in one config:dev to :appnamespace.a that includes a component from namespace.b. However, namespace.b/component is returning nil , which is very strange. namespace.b is requiring D3 with (:require ["d3" :as d3]) . D3 has been added to my package.jsonnamespace.b/component no longer evals to nil, and everything works ok------ ERROR -------------------------------------------------------------------
File: /home/void/wp/crispeta/src/acme/web/ui/components.cljs
failed to require macro-ns "acme.web.utils.macros", it was required by "acme.web.ui.components"
Syntax error macroexpanding clojure.core/ns.
Call to clojure.core/ns did not conform to spec.
-- Syntax error -------------------
(... (:require
[camel-snake-kebab.core :as csk]
["semantic-ui-react" :as semantic-ui]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:clojure.core.specs.alpha/ns-form:
(clojure.spec.alpha/cat
:ns-name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:attr-map
(clojure.spec.alpha/? clojure.core/map?)
:ns-clauses
:clojure.core.specs.alpha/ns-clauses)
-------------------------
Detected 1 errorpom action
$ clj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.15.4"}}}' -M -m shadow.cljs.devtools.cli pom
Unknown action.
compile watch work fine, but pom doesn't. Any idea what is wrong with this call?$ clj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.15.4"}}}' -M -m shadow.cljs.devtools.cli -h
Usage:
shadow-cljs <action> <zero or more build ids>
Supported actions are:
compile - ...
watch - ...
check - ...
release - ...
classpath - ...
node-repl - ...
browser-repl - ...
cljs-repl - ...
clj-repl - ...
clj-eval - ...
clj-run - ...
run - ...
info - ...
pom - ...
npm-deps - ...
test - ...
aot - ...
init - ...
help - ...
server - ...
start - ...
stop - ...
restart - ...
Options:
-----
--npm internal, used by the shadow-cljs npm package
-d, --dependency DEP adds an additional dependency (eg. -d foo/bar:1.2.3 -d another/thing:4.0.0)
--config-merge DATA merges additional EDN data into the build config
-A, --aliases ALIASES adds aliases for use with clj, only effective when using deps.edn
--source-maps temporarily enable source-maps for release debugging
--pseudo-names temporarily enable pseudo-names for release debugging. DO NOT SHIP THIS CODE!
--debug enable source-maps + pseudo-names. DO NOT SHIP THIS CODE!
--stdin clj-eval from stdin
-v, --verbose verbose build log
--force-spawn spawn new process, do not connect to running server
--cli-info prints a bunch of information
--via VIA internal option, used by node script
-h, --help
-----
So theoretically the pom is supported. but for some reason it doesn't work.pom is done by the npm shadow-cljs script and only works when using shadow-cljs.edn. Otherwise there is no point and so the JVM code doesn't support it.shadow-cljs pom worked fine for me. I've just thought there is a parity between js and jvm versionshadow.cljs.devtools.api? (I want to run npx shadow-cljs classpath to clj-kondo. If shadow-cljs isn't installed locally, shadow-cljs prints a warning saying WARNING: shadow-cljs not installed in project. It prints it into stdout, which means it trickles all the way down to clj-kondo, which then proceeds to croak with an inscrutable error.
Would it be possible to change the println calls here such that the warning is printed into stderr instead? https://github.com/thheller/shadow-cljs/blob/de52880090c7840ee30eb5369173c1bd7dd3055c/src/main/shadow/cljs/npm/cli.cljs#L783-L791
Looks like println -> log might do it?npx shadow-cljs classpath never contains anything else than the classpath. 🙂:devtools {:enabled false} in the build configautoload false for some reasonshadow-cljs pom , it doesn't populate paths based on deps.edn. Is something wrong with this config?
deps.edn:
{:paths
["src/main"]
:aliases
{:dev
{:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.10.879"}
thheller/shadow-cljs {:mvn/version "2.15.4"}}}
:test
{:extra-paths ["src/test"]}}}
shadow-cljs.edn:
{:deps
{:aliases [:dev :test]}
:builds
{:script {:target :node-script
:main example.core/-main
:output-to "lib/script.js"}}}
The pom command populates paths to pom.xml only if I add :source-paths to shadow-cljs.edn. Funny thing, because when I run watch command, there is a warning that these src paths are ignored, but for the generation of pom.xml it looks there is no other way but to duplicate these.pom is a command that only works when :source-paths and :dependencies are managed by shadow-cljs.edn ONLY. if you are using deps.edn use clj -Spom (with aliases if you need)proxy - could this be problematic in someway with shadow shims?SHADOW import error looks suspicious too!2.15.4 or 2.15.5 but not earlier versions:
[:app] Configuring build. [:app] Compiling ... SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See for further details. [:app] Build completed. (2733 files, 404 compiled, 0 warnings, 44.38s)I have no idea how to figure out why. The code is using
com.lambdaisland/glogi We were using version 1.0.116 and 1.0.128 (latest) Not sure what else would be interacting with shadow for log stuff like that. Any suggestions or known issues around this? Thanks2.15.3shadow-cljs browser-repl(require 'lambdaisland.glogc) to see if the warnings show upshadow-cljs server and then separately shadow-cljs browser-replglogi itself seems to be fine, just the glogc requires pedestal:target :esm. would help to have a plain JS example of an extension. then I could tell you exactly how it would look in shadow-cljs{:target :esm
:output-dir "my-extension"
:modules {:main {:exports {default my.extension/default}}}}
(ns my.extension)
(def default
;; a JS object similar to
#js {}){:target :esm
:output-dir "my-extension"
:modules {:main {:exports {default my.extension/default}}}
:js-options {:js-provider :import}}:js-provider tells shadow not to bundle anything and instead let the runtime provide it all (you need a very recent shadow-cljs version for all of this):output-dir you need a package.json with "main":"./main.js"release builds will likely just work. compile and watch will likely require adjustments since I don't know what jupyter does to the code and how possible it is to get a REPL into whatever it producescompile may just work too though, really depends on what it does:target :esm build using :target :node-test but it seems that compiles my tests not as an ecmascript module (which is not surprising) but how do I make that work together if I'm using esm features in the code which aren't available otherwise?:target :esm build and configure it manually without the conveniences you get from :node-test:nbb_tests within the same build. And then just run that file with node manually which executes the tests via the init fn:compiler-options {:load-tests true}. otherwise release won't contain tests. might be what you want but I always recommend running tests in release mode to rule out :advanced causing issues 😛:advanced. the tests likely will keep code alive that would otherwise be removed. it'll also make the nbb package larger by however large your tests make everything. I doubt an end user will ever run them.:output-dir would be best (IMHO)--aliases :test --config-merge shadow-tests.edn
:build-defaults {...} or :target-defaults {:esm {...}} too{:target :node-library
:output-to "out/lib.js"
:compiler-options {:infer-externs :auto}
:exports {:hello react-cljs-poc.core/app}
I can run everything in dev fine, but when I go to do this build, closure is taking some of that already minified code and changing some keys in some objects. Those keys can't change sadly. The keys look something like this:
var Me = {
day: {},
week: {},
month: {},
year: {}
}
And after the closure compiler is done doing its magic it looks like this:
var Ij = {
day: {},
pd: {},
month: {},
year: {}
}
Short of turning off advanced compilation, is there anything I can do to make closure not do these sorts of transforms?(js-obj "day" 123 "week" 123) it should be safe from renaming:compiler-options {:infer-externs :auto} is the default, you don't need to configure thatNo Taps yet. (tap> something) to see it here. Guess I'll try updating shadow-cljs and see if that helps (I'm on 2.12.4).shadow-cljs browser-repl does that?cljs-eval see https://clojureverse.org/t/status-update-inspect-cljs-eval/6074watch is running though. but besides that you can build all UI you want yourselfcljs-eval, thanks:preloads to aid local development that is totally fine:simple then it is possible:advanced does so much more. removing dead code, inlining, collapsing namespaces, etc(defn ^:export debug-me [] (pr-str @re-frame.db/the-thing)) or so.domain/$current_path) to make the whole process completely transparent:dev/after-load hooks not take effect when set in a library?examples , outside of the lib classpathCaused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
Invalid node in lhs: STRINGLIT / 15252:4 [length: 15] [source_file: node_modules/pdfmake/build/pdfmake.js]
Node(GETPROP default): node_modules/pdfmake/build/pdfmake.js:15259:8
exports.default = void 0;
Parent(ASSIGN): node_modules/pdfmake/build/pdfmake.js:15259:0
exports.default = void 0;
I know this isn’t much information but I’m not a javascript guy any thoughts on this - I’ve googled without any luckUncaught Error: Assert failed: Invalid Hiccup form: [nil] but the component is just this simple one
(defn heyson [] [:div "heyson"])i import it like this:
[app.components.cashflows :refer [graph-fn heyson]]
and it is used like this
[:<> [input-bar app-state] [heyson] [json-city-list @app-state (activate-modal app-state)]]
[:<> [input-bar app-state] ;[heyson] [json-city-list @app-state (activate-modal app-state)]]
[app.components.cities.city-list :refer [json-city-list heyson]]["@ant-design/charts" :refer (Line)] inside the same file as the heyson component.["@ant-design/charts/es/plots/line" :default Line]Uncaught Error: Assert failed: Invalid Hiccup form: [nil] error.
2. Go into the file where you imported this component from. Meaning the file in which you have defined the component that is causing the error.
3. Isolate which import/require is causing the trouble.
4. Try to replace it with a default import ["npmpackage/lib/component" :default Component]
5. Give this a thumbs up or down if it helped you. So that other people can now if it was useful, before they start reading 🙂 (ns foo (:require ["goog$global.console" :refer [log]]))That doesn't seem to work
goog$global.console does work$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.866"}}}' -M -m cljs.main
ClojureScript 1.10.866
cljs.user=> (ns foo (:require [goog$global.console :refer [log]]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Unexpected error (ExceptionInfo) compiling at (REPL:1).
Invalid :refer, var goog$global.console/log does not exist in file <cljs repl>
foo=> (ns foo (:require [goog$global.console ]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:203).
goog$global.console does not exist(:require ["clojure.string" :as str]) is valid in CLJS but not shadow-cljsgoog.provide and goog.require etcnode_modules folder(:require [whateverjslib]) in nbb but perhaps I should not?(:require [react]) is valid only if node_modules/react exists but not otherwise(:require ["react" :as react]) you at least tell the compiler that you intent to use JS code (and the :js-provider will know how to provide it)goog$global.Thing doesn't work in regular CLJS. it should but there is an open ticket specifically about "globals" so maybe thats why it doesn't work.shadow-cljs to my .gitignore?Expo with shadow-cljs I'm connecting to my iPhone device through the QR code. It was working ok until recently. Now I'm getting errors:
Error
21:09
shadow-cljs - remote-error, Event {
"isTrusted": false,
"message": "The operation couldn't be completed. Connection refused",
}
Stack trace:
in registerError
in errorImpl
in console.error
in error
in shadow.cljs.devtools.client.shared.Runtime.prototype.shadow$cljs$devtools$client$shared$IRemote$remote_error$arity$2
in shadow$cljs$devtools$client$shared$remote_error
in shadow$cljs$devtools$client$websocket$start/socket.onerror
in dispatchEvent
in _registerEvents/this._subscriptions<
in emit
in __callFunction
in callFunctionReturnFlushedQueue/<
in __guard
in callFunctionReturnFlushedQueue
in parcelRequire<.sYUN</onmessage</<
...
Any ideas what be going on here? It was working and then, for no apparent reason, it stopped working.get-ws-relay-url should return url with the ip address not a "localhost" in case it's running in iOS?:target :react-native in your build configshadow-cljs clj-repl and then (shadow/get-server-addr):local-ip in shadow-cljs.edn or ~/.shadow-cljs/config.edn controls thatlocalhost is an invalid value here 😛:local-ip "192.168.8.104"shadow-cljs: #11 ready!
index.esm2017.js:985 Uncaught ReferenceError: regeneratorRuntime is not defined
at PersistentConnection.value (index.esm2017.js:985)
at eval (index.esm2017.js:979)
any ideas what could be missing(:require ["regenerator-runtime/runtime"]) somewhere in your project. ideally before JS deps are loaded:compiler-options {:output-feature-set :es8}The required JS dependency "regenerator-runtime/runtime" is not available, it was required
npm install regenerator-runtime. for reasons I don't understand babel rewrites some code to use that package without ever adding a proper require for it:maven {:repositories ...} in shadow-cljs.edn^:export is forfoo.bar with a function (defn ^:export foo []) then you can refer to it from the HTML like foo.bar.footouch node_modules/your-lib/package.json~/.clojure/deps.edn this alias:
:dev/fulcro-rad {:override-deps {com.fulcrologic/fulcro-rad {:local/root "/Users/me/Projects/external/fulcro-all/fulcro-rad"}}}
and then I simply added it to shadow-cljs.edn :
{:deps {:aliases [:dev :test :sql :dev/fulcro-rad]}
I restarted npx shadow-cljs watch main but it seems that the modified code from the local override is not used there. So what else do I need to do? Remove some caches, ...? (The browser has dev tools open and "no cache if dev tools" enabled.) 🙏
Do I perhaps need to run frontend build in the dependency?:target :node-library and shadow-cljs compile and it works perfectly for node.
What am I supposed to do in order to bundle the lib as a single JavaScript file for the browser?<script> tag<script>? likely you want a secondary :browser build file. or you can put that file on a cdn/server somewhere and have people use that directly?script tag. This file should expose a couple of global functions.npm release on the browser target and add {:export true} to the functions I'd like to expose?global and for the the browser, it should be window!goog.global is forgoog.global. the build targets assign that to whatever is correct for the platformgoog.global is cool!.expo.js that Shadow (I think) produces and it will be no longer compatible with future expo versions.node_modules and any other output folder
• npm i
• Start shadow and then start expo
I have noticed that not necessarily ultimate versions are the best, in fact, I found that using the lastest expo version didn't compile my project, so I used the PEZ' version.
Also, deleting every output folder have solved me problems when I was updating my libs.
Hope you can solve your problem :){:builds
{:app {:asset-path "/js"
:modules {:main {:init-fn app.core/main}}
:output-dir "public/js"
:target :browser
:closure-defines {app.helpers.analytics/Greeting #shadow/env "HEY Simon"}
:js-options {:ignore-asset-requires true}}
But then how do i get it so that i can do this:
(prn Greeting)
(goog-define variable-name "default value") But it only provides the default value and doesn't get overwrittenshadow-cljs release app -config-merge '{:closure-defines {app.envvars.core/APP_ENV :dev}}'app.helpers.analytics/Greeting would be (goog-define Greeting ...) in (ns app.helpers.analytics) somewhere. should be fine.::http/file-root or so ::http/resource-root or socom.google.javascript/closure-compiler-unshaded v20210505{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1e7f6e7767715e7f6e776771334a767770754e7f7a"}, :content ("[email protected]")}:target :bundle from regular CLJSdeps.cljs file with {:npm-deps {"lib-b" "version"}}:npm-deps work only with shadow ?:npm-deps is a regular CLJS option, it is information only. acting on it may require calling a function. eg. cljs.main with --install-deps or so(:require ["react" :as react])react. shadow-cljs will just do so via npm. regular CLJS and figwheel will not:target :bundle with webpack or so:npm-deps are entirely irrelevant since the cljs compiler will not handle npm at all)About to one of those @U05224H0W:repl {:runtime-select :latest} (top-level shadow-cljs.edn) to always pick the last connected runtime for the REPL instead of the first(shadow.cljs.devtools.api/repl :the-build-id {:runtime-id 4}):CljEval ...the above... to signal to the Clojure side of the REPL rather than the JS side.:closure-defines value in shadow-cljs.edn able to be dynamic? By that I mean if I change it and force compile (or not) should the runtime pick up the change? I know these goog-define vars are compile time, but as there's continuous compilation with shadow-cljs I hoped I could change a value on the fly while developing (leaving it strictly at its default when not). I've got one that doesn't seem to be dynamic at the moment, but I'll try harder if I know they can be...r/atom is used in many places, but only this one occurrence is marked and I cannot get the warning to go away. Is this a bug or am I just not able to see the error?(:require [reagent.core :as r]) in your ns?a not an actual a or sonpx shadow-cljs -A:build:test compile test --config-merge '{:autorun false}'
Error building classpath. Specified aliases are undeclared: [:-A]It doesn’t quite make sense to me since it looks like the aliases aren’t passed at all. Was there any change in shadow that could cause this?
clojure tools.deps recently?clojure invocationclojure -A:build:test -M -m shadow.cljs.devtools.cli watch app (for shadow-cljs watch app)import LogRocket from 'logrocket'; would translate to (:require ["logrocket" :default LogRocket]) correct?["logrocket$default" :as logrocket]Must use import to load ES Module: /Users/toor/mutesync/shells/electron/node_modules/node-fetch/src/index.js require() of ES modules is not supported.
nbb:
npm install -g nbb npm install node-fetchfetch.cljs:
(ns fetch
(:require ["node-fetch$default" :as fetch]))
(-> (fetch "")
(.then #(.text %))
(.then prn))
nbb fetch.cljsAnd this should be similar when using
shadow-cljs with :esm targetnbb?:esm target is currently undocumented. This is how you can use it:
https://gist.github.com/borkdude/7e548f06fbefeb210f3fcf14eef019e0react_devtools_backend.js:2850 Warning: Invalid attribute name: `cljs$lang$protocol_mask$partition0$`
at div
at eval ()
at exports.CustomGallery ()
at f ()
at div
at div
at cmp ()
at div
at div
at div
at div
at cmp ()(ns quagga.components.dataview.photos.view
(:require
[reagent.core :as reagent]
["react-photoswipe-gallery" :refer (Gallery Item)]))
(defn photos-component
[]
[:div.tab-page.photos-page {:style {:display "block", :overflow-x "scroll"}}
[:div#tab-contentphotos.tab-content
[:f> Gallery
;; {:id "simple-gallery"}
[:div
{:style
{:display "grid"
:gridTemplateColumns "240px 171px 171px"
:gridTemplateRows "114px 114px"
:gridGap 12}}
[:f> Item
{:id "so-first"
:title "Author: Folkert Gorter"
:height "1600"
:width "1600"
:thumbnail
""
:original
""}
(fn [ref open]
(reagent/as-element
[:img
{:src ""
:ref ref
:on-click open
:style {:cursor "pointer"
:objectFit "cover"
:width "100%"
:maxHeight "100%"}}]))]]]]])clojure -A:build:test -M -m shadow.cljs.devtools.cli watch app@thheller this call seems to work but the issue also seems like potentially a different version issue in the CI env where it’s failing
-M might be a problem if your CI has an older tools.deps install?node-repl without restarting everything? There’s a way to restart the worker process for that but I can’t remember 😅(shadow.cljs.devtools.api/stop-worker :node-repl) from the CLJ repl--debug flag.:advanced since those parts only ever use :simple$emotion$core$create_styled$$ = function($display_name$jscomp$2_result$jscomp$144$$, $component$jscomp$30$$, $options$jscomp$119$$, $styles$$) {
var $wrap$jscomp$2$$ = $APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$2$($options$jscomp$119$$, "wrap")
, $camel_casing_props_QMARK_$$ = $APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($options$jscomp$119$$, "camelCasingProps?", !0)
, $class_name_prop$jscomp$1$$ = $APP.$cljs$core$name$$($APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($options$jscomp$119$$, "classNameProp", "class-name"))
, $wrapper_component$$ = $APP.$cljs$core$not$$($camel_casing_props_QMARK_$$) ? $component$jscomp$30$$ : null != $component$jscomp$30$$.__emotion_base ? $component$jscomp$30$$ : $APP.$cljs$core$_EQ_$$.$cljs$core$IFn$_invoke$arity$2$($APP.$cljs$core$type$$($component$jscomp$30$$), String) ? $emotion$core$create_forwarded_element$cljs$0core$0IFn$0_invoke$0arity$02$$($component$jscomp$30$$, $emotion$core$object__GT_camel_props$$) : $APP.$cljs$core$_EQ_$$.$cljs$core$IFn$_invoke$arity$2$($class_name_prop$jscomp$1$$, "className") ? $component$jscomp$30$$ : $emotion$core$create_forwarded_element$cljs$0core$0IFn$0_invoke$0arity$02$$($component$jscomp$30$$, function($p1__141952_SHARP_$$) {
return $emotion$core$convert_class_name$$.$cljs$core$IFn$_invoke$arity$2$($p1__141952_SHARP_$$, $class_name_prop$jscomp$1$$);
});
$wrapper_component$$.displayName = $display_name$jscomp$2_result$jscomp$144$$;
$display_name$jscomp$2_result$jscomp$144$$ = function() {
function $G__141956$$($props$jscomp$26$$) {
return $APP.$cljs_bean$core$__GT_js$$($styles$$).concat($props$jscomp$26$$.css);
}
var $fexpr__141955$$ = function() {
var $G__141958$$ = $APP.$cljs_bean$core$__GT_js$$($options$jscomp$119$$);
return $emotion$core$styled_component$$.$cljs$core$IFn$_invoke$arity$2$ ? $emotion$core$styled_component$$.$cljs$core$IFn$_invoke$arity$2$($wrapper_component$$, $G__141958$$) : $emotion$core$styled_component$$.call(null, $wrapper_component$$, $G__141958$$);
}();
return $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$ ? $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$($G__141956$$) : $fexpr__141955$$.call(null, $G__141956$$);
}();
return $APP.$cljs$core$truth_$$($wrap$jscomp$2$$) ? $wrap$jscomp$2$$.$cljs$core$IFn$_invoke$arity$1$ ? $wrap$jscomp$2$$.$cljs$core$IFn$_invoke$arity$1$($display_name$jscomp$2_result$jscomp$144$$) : $wrap$jscomp$2$$.call(null, $display_name$jscomp$2_result$jscomp$144$$) : $display_name$jscomp$2_result$jscomp$144$$;
}return $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$ ? $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$($G__141956$$) : $fexpr__141955$$.call(null, $G__141956$$);
$fexpr__141955$$.callIs undefined
--debug output? should be the assignment of $emotion$core$styled_component$$$emotion$core$styled_component$$ = $module$node_modules$$emotion$styled$dist$emotion_styled_browser_cjs$$.default
npm install and creating a dependency conflict that wasn't there beforedefrecords and I need these types to be redefined on code reload. So I added the marker to always reload this NS
(ns ^:dev/always mutesync.background.transit-types (:require ...))But this namespace is still not be reloaded when I update one of it’s children. Does
:dev/always mean always reload this NS or something else?(instance? TheRecord ...).protocols ns or so:refer-clojure :exclude?
(ns user (:refer-clojure :exclude [compile]) ) (defn compile [] 42)
$ npx shadow-cljs watch :main shadow-cljs - config: .../shadow-cljs.edn shadow-cljs - starting via "clojure" WARNING: compile already refers to: #'clojure.core/compile in namespace: user, being replaced by: #'user/compile
=== Version jar: 2.15.5 cli: 2.15.5 deps: 1.3.2 config-version: 2.15.5
clj -M --main cljs.main --compile user gives the same error, so it's not shadow-cljsbabashka.process is a library which you can probably add to deps.edn?postcss.clj which is a Clojure (JVM) filedeps.edn like this:
{:deps {babashka/process {:mvn/version "0.0.2"}}}
and in your shadow-cljs.edn write :deps true so it picks up on the deps.ednproject.clj then just add the dep there:inherit true option in processprintlns for debugging if those build functions are executed at all. ok goodnight!npm-run-all to run multiple things but in separate processes[BABEL] Note: The code generator has deoptimised the styling of mydev/node_modules/somelib.js as it exceeds the max of 500KB. in my builds recently. It is not always printed, but sometimes. Does not seem to affect my build times. Normally appears along with Browserslist: caniuse-lite is outdated. Please run next command npm update . Switching between shadow 2.12.x and 2.15.x seems to not make a difference. Is this something that needs configuration, or is it not a problem?shadow.edn support for this:local/rootimport React from "react";
import ReactDOM from "react-dom";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { resources } from "./translations";
export function init({onMissingKey}) {
i18n
// passes i18n down to react-i18next
.use(LanguageDetector)
.use(initReactI18next)
.on('missingKey', onMissingKey)
.init({
// order and from where user language should be detected
order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'path', 'subdomain'],
defaultNS: ['General'],
// keys or params to lookup language from
lookupQuerystring: 'lng',
lookupCookie: 'i18next',
lookupLocalStorage: 'i18nextLng',
lookupSessionStorage: 'i18nextLng',
lookupFromPathIndex: 0,
lookupFromSubdomainIndex: 0,
// cache user language on
caches: ['localStorage', 'cookie'],
excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)
// optional expire and domain for set cookie
cookieMinutes: 10,
// optional htmlTag with lang attribute, the default is:
htmlTag: document.documentElement,
// optional set cookie options, reference:[MDN Set-Cookie docs]()
cookieOptions: { path: '/', sameSite: 'strict' },
// the translations
// (tip move them in a JSON file and import them,
// or even better, manage them via a UI: )
saveMissing: true,
resources,
fallbackLng: "pl",
interpolation: {
// react already safes from xss =>
escapeValue: false
}
});
}
export function refresh({ onSuccess, onFailure }) {
return i18n.reloadResources().then(onSuccess).catch(onFailure);
}
export function language() {
return i18n.language;
}
export function changeLanguage(lang, {onSuccess, onFailure} ) {
return i18n.changeLanguage(lang).then(onSuccess).catch(onFailure);
}
export function t(key, opts) {
return i18n.t(key, opts);
}
This works perfectly for optimizations: none. However with shadow-cljs release changeLanguage and reloadResources are removed from the prototype 😮
Any hints what potentially I'm doing wrong?const pl = {
};
const en = {
};
export const resources = {pl, en};
After advanced en becomes M1# ----------------------------------------------- # [start] i18n externs [start] i18n.resources.en i18n.resources.pl i18n.changeLanguage i18n.reloadResources i18n.appendNamespaceToCIMode i18n.appendNamespaceToMissingKey i18n.htmlTag i18n.excludeCacheFor i18n.cookieOptions i18n.cookieMinutes i18n.lookupFromPathIndex i18n.lookupFromSubdomainIndex i18n.t # [end] i18n externs [end] # -----------------------------------------------
js/ReactDOMServer variable? I'm trying to do
(:require ["react-dom/server" :as ReactDOMServer]) (set! js/ReactDOMServer ReactDOMServer)I'm using
esm target with Deno and above code throw this error:
error: Uncaught (in promise) ReferenceError: ReactDOMServer is not defined (ReactDOMServer = module$node_modules$react_dom$server_browser);the reason why I had to do this is because
uix tries to use js/ReactDOMServer here: https://github.com/roman01la/uix/blob/0da33eef38a7122be226b9b9a8ae0b5431b6b5d3/dom/src/uix/dom/alpha.cljc#L69(set! js/goog.global.ReactDOMServer ReactDOMServer) will make it global(js/goog.exportSymbol "ReactDOMServer" ReactDOMServer) also works. might be safer if you are going for :advancedshadow-cljs release app and it builds fine but how do I actually run the release build? Everything I am trying is failing. shadow-cljs watch app still works for the dev build. But anything like shadow-cljs run app or shadow-cljs run core give me classpath errorspython -m http.server 8000 for example. Then point the browser to localhost:8000 and your app will load.release should override all the relevant files unless you have configured it not toshadow-cljs server. as a bonus while that is running shadow-cljs release app is also much faster:advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?cljs/core.cljs which I guess is to be expected. I assume as I continue building out the app, the size will grow at a slower rate (if that makes any sense)The required JS dependency "json-rpc-engine/src/createAsyncMiddleware" is not available, it was required by "node_modules/eth-json-rpc-middleware/block-cache.js". node_modules/moralis/index.js node_modules/moralis/lib/browser/Parse.js node_modules/moralis/lib/browser/decode.js node_modules/moralis/lib/browser/ParseACL.js node_modules/moralis/lib/browser/ParseUser.js node_modules/moralis/lib/browser/MoralisWeb3.js node_modules/moralis/lib/browser/MoralisWalletConnectProvider.js node_modules/@walletconnect/web3-provider/dist/esm/index.js node_modules/web3-provider-engine/subproviders/cache.js node_modules/eth-json-rpc-middleware/block-cache.jsI tried removing node_modules and reinstalling using npm i. I also tried npm i --save json-rpc-engine but that still gives the error. I tried npm i --save json-rpc-engine/src/createAsyncMiddleware, but that npm package doesn’t exist. How to fix this?
eth-json-rpc-middleware package maybe expects a different version of json-rpc-engine than you have installeduix for render/hydrate a simple React app. Thanks @thheller for adding esm support! now I just wished watch mode would work for esm target too.
deploy url: https://deno-cljs.deno.dev
https://github.com/huygn/deno-cljs-templatedocument was referenced in :server build, but compile/release mode works fine :thinking_face:
> deno run -A --unstable --watch src/index.ts
Check file:///Users/macair/src/github.com/huygn/my-project/src/index.ts
error: Uncaught ReferenceError: document is not defined
return goog.dom.createElement_(document, name);
^
at Object.goog.dom.createElement (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.dom.dom.js:288:34)
at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.style.transition.js:39:21
at Object.isSupported (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.functions.functions.js:142:15)
at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/shadow.dom.js:3:99no source by provide: module
{:provide module}
ExceptionInfo: no source by provide: module
shadow.build.data/get-source-id-by-provide (data.clj:186)
shadow.build.data/get-source-id-by-provide (data.clj:183)
shadow.build.data/get-source-by-provide (data.clj:189)
shadow.build.data/get-source-by-provide (data.clj:188)
shadow.build.js-support/shim-require-sugar-resource/fn--34338 (js_support.clj:107)
shadow.build.data/get-source-code (data.clj:319)
shadow.build.data/get-source-code (data.clj:306)
shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189/fn--34190 (closure.clj:2187)
shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189 (closure.clj:2186)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
clojure.core/chunk-next (core.clj:710)
clojure.core.protocols/fn--8176 (protocols.clj:137)
clojure.core.protocols/fn--8176 (protocols.clj:124)
clojure.core.protocols/fn--8136/G--8131--8145 (protocols.clj:19)
clojure.core.protocols/seq-reduce (protocols.clj:31)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8168 (protocols.clj:75)
clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
clojure.core/reduce (core.clj:6830)
clojure.core/into (core.clj:6897)
clojure.core/into (core.clj:6889)
shadow.build.closure/convert-goog* (closure.clj:2190)
shadow.build.closure/convert-goog* (closure.clj:2182)
shadow.build.closure/convert-goog (closure.clj:2361)
shadow.build.closure/convert-goog (closure.clj:2311)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
shadow.build.compiler/compile-all (compiler.clj:1426)
shadow.build.compiler/compile-all (compiler.clj:1307)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:442)
shadow.build/compile (build.clj:432)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:531)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:486)
shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230/fn--37238 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230 (util.clj:283)
shadow.cljs.devtools.server.util/server-thread/fn--37229 (util.clj:256)
java.lang.Thread.run (Thread.java:748):advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?error: Uncaught ReferenceError: document is not defined
return goog.dom.createElement_(document, name);
^
at Object.goog.dom.createElement
is there any ways to prevent this error during development with :esm target? I'm consuming the output in Deno.serveHttp so document isn't a thing there.
compile/release works fine, I guess it's due to dev mode always has :none optimization hence dom methods still there:runtime :custom in your build config. otherwise defaults to :browser which will attempt to use the dom. not related to :none in any waydeno which doesn't work with cljs very well?deno, but rather because I like it conceptually, however, I currently can't find a reason to want to use it.repl works normally?repl doesn't trigger a file change, so deno won't reloadJS 🙃:init-fn) to run stand-alone with shadow-cljs, then consume the exports in denodeno has no audience in our community:esm target works for deno, this is why thheller specifically created it, but I'm also using it for #nbb (scripting on Node using SCI) to be able to import ES modules and this target also supports code splitting which allows nbb to lazily load code for better startupdeno solves a lot of other problems that node has and esm isn't really one of them{:source-paths
["src/main"]
:dependencies
[[reagent "1.1.0"]
[cljs-ajax "0.8.4"]]
:dev-http {8080 "public"}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn app/start}}
:closure-defines {events.async/TWITCH_AUTHORIZATION_TOKEN #shadow/env "TWITCH_AUTHORIZATION_TOKEN"}}}}
also my .env:
TWITCH_AUTHORIZATION_TOKEN="blalbbllba"so my question is how to read a env variable then?
(get-in build-state [:shadow.build.modules/modules module-id :output-name])returns name w/o hash
:shadow.build.closure/modules should have the hashes in :output-nameshadow.build.modules is before optimizations and shadow.build.closure is after:target :node-library ?:prepend-js with a an empty module ns have the same effect?:modules {:js-only {:entries ["/that/file.js"]}}:devtools {:enabled false} that shouldn't happen:console-support false also (also in :devtools).shadow-cljs directory between release builds of clojurescript? we previously have been deleting that folder before we run a release build, in fear of stale cache or dependencies. retaining it makes our build at least 1 minute faster, so we want to see if its safe to no longer delete it between release builds:module-hash-names doens't work, the output is still client.js file without any hash :thinking_face:
:client {:target :esm
:runtime :browser
:output-dir "dist/client"
:modules {:client {:entries [app.client]
:exports {hydrate app.client/hydrate-app}}}
:devtools {:before-load app.client/stop
:after-load app.client/start}
:module-hash-names 8
:build-options {:manifest-name "manifest.json"}}:module-hash-names currently is only supported for :browser buildsjs/goog.exportSymbol described in the shadow docs and add that stub to the library source code and call it a day? Specifically, I'm trying to address this issue in this project: https://github.com/funcool/decimal/issues/7decimal.js instead of decimal.extern.decimaljs(:require ["decimal.js" :as dec]) or so:npm-deps {"decimal.js" "version"} to the deps.cljs filejs/Decimal uses as well to use the alias. I'm not entirely sure what you need to add to deps.cljs for that to work thoughError: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:626:3)
at tryReadSync (node:fs:391:20)
at Object.readFileSync (node:fs:428:19)
at UnableToResolveError.buildCodeFrameMessage (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:304:17)
at new UnableToResolveError (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:290:35)
at ModuleResolver.resolveDependency (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:168:15)
at DependencyGraph.resolveDependency (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph.js:353:43)
at /Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/lib/transformHelpers.js:271:42
at Server.<anonymous> (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/Server.js:842:41)
at Generator.next (<anonymous>)
....etc etcDevTools failed to load source map: Could not load content for : Fetch through target failed: Target not supported; Fallback: HTTP error: status code 500, net::ERR_HTTP_RESPONSE_CODE_FAILUREsigh
@import "antd/dist/antd.css"; listed in their docs which pulls from node_modules/antd to work with a shadow project?head of my index.html
<link rel="stylesheet" href="" integrity="sha512-Gfp2ZD1ULgfgThJArElWdfu/bPK67HVrx+rKfLfclPyRUlf68R7uHIy5zaPnZpv6ZuIX/ykmJCv3Q1bnfZngEg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
cljs.user=> (require '[clojure.spec.alpha :as s]) nil cljs.user=> (require '[clojure.spec.gen.alpha :as gen]) nil cljs.user=> (gen/generate (s/gen int?)) Execution error (Error) at (<cljs repl>:1). Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required :repl/exception!
[org.clojure/test.check "1.1.0"] to the :dependencies vector. is there anything I'm missing?cljs function using karma... it seems trickier than I expected
I'm getting an error that looks like this
-------------------------------------------------------------------------------- 23 | 24 | (defn ^:export run 25 | [karma] 26 | (-> (stest/enumerate-namespace 'quagga.utils.components.share-modal.events) stest/check) ---------^---------------------------------------------------------------------- Encountered error when macroexpanding cljs.spec.test.alpha/check. Error in phase :compile-syntax-check RuntimeException: No such namespace: stestHere's how I'm running the test; not sure if its' the correct way to do it
(defn ^:export run
[karma]
(-> (stest/enumerate-namespace 'quagga.utils.components.share-modal.events) stest/check)
(karma/run-tests karma
'quagga.utils.components.account-select.events-test
'quagga.components.dataview.table.events-test
'quagga.utils.components.share-modal.events-test))[clojure.spec.test.alpha :as stest]
ns :require of that file(defn ^:export run
[karma]
(stest/abbrev-result (first (stest/check `ranged-rand)))
(karma/run-tests karma
'quagga.utils-test
'quagga.utils.components.account-select.events-test
'quagga.components.dataview.table.events-test
'quagga.utils.components.share-modal.events-test
'quagga.components.organization.profile.events-test
'quagga.components.organization.user-management.events-test
'quagga.components.dataview.table.views-test
'quagga.components.dataview.table.utils-test
'quagga.components.dataview.table.subs-test
'quagga.utils.views.wrap-header-and-footer-test
'quagga.components.dataview.subs-test
'quagga.components.dataview.utils-test
'quagga.utils.views.walkthrough-test
'quagga.utils.components.share-modal.views-test
'quagga.utils.views.confirm-modal-test
'quagga.utils.components.new-project-modal.views-test
'quagga.components.dataview.charts.views-test))ranged-rand))) is set up, on purpose to failkarma/run-tests is(stest/check ranged-rand)` in the run function and not some test?karma/run-tests comes from [jx.reporter.karma :as karma :include-macros true]> (stest/abbrev-result (first (stest/check `ranged-rand)))
{:spec (fspec :args (and (cat :start int? :end int?) (fn* [p1__34241#] (< (:start p1__34241#) (:end p1__34241#)))) :ret int? :fn (and (fn* [p1__34242#] (>= (:ret p1__34242#) (-> p1__34242# :args :start))) (fn* [p1__34243#] (< (:ret p1__34243#) (-> p1__34243# :args :end))))), :sym cljs.user/ranged-rand, :failure {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 4}, :ret -2}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 4}, :ret -2}, :cljs.spec.test.alpha/args (0 4), :cljs.spec.test.alpha/val {:args {:start 0, :end 4}, :ret -2}, :cljs.spec.alpha/failure :check-failed}}(deftest my-gen-test (stest/check `ranged-rand))
> (deftest my-gen-test (stest/check `ranged-rand)) #'cljs.user/my-gen-test cljs.user=> (require '[cljs.test :as test :refer-macros [run-tests] :refer [report]]) nil cljs.user=> (run-tests) Testing cljs.user Ran 1 tests containing 0 assertions. 0 failures, 0 errors. nil > (deftest my-gen-test2 (stest/check `ranged-rand)) #'cljs.user/my-gen-test2 > (run-tests) Testing cljs.user Ran 2 tests containing 0 assertions. 0 failures, 0 errors. nil cljs.user=>
FAIL in (my-gen-test2) (repl-input.cljs:1:27)
expected: (= [] (stest/check (quote cljs.user/ranged-rand)))
actual: (not (= [] [{:spec #object[cljs.spec.alpha.t_cljs$spec$alpha38994], :clojure.spec.test.check/ret {:shrunk {:total-nodes-visited 5, :depth 4, :pass? false, :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}, :result-data {:clojure.test.check.properties/error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}}, :time-shrinking-ms 3, :smallest [(0 2)]}, :failed-after-ms 6, :num-tests 3, :seed 1631261832504, :fail [(9 13)], :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 9, :end 13}, :ret 6}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.test.alpha/args (9 13), :cljs.spec.test.alpha/val {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.alpha/failure :check-failed}}, :result-data {:clojure.test.check.properties/error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 9, :end 13}, :ret 6}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.test.alpha/args (9 13), :cljs.spec.test.alpha/val {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.alpha/failure :check-failed}}}, :failing-size 2, :pass? false}, :sym cljs.user/ranged-rand, :failure #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}}]))
Ran 2 tests containing 1 assertions.
1 failclojure.test.check.results/pass? is supposed to do this(deftest my-gen-test2 (ctcr/pass? (stest/check `ranged-rand)))
(deftest my-gen-test2 (is (ctcr/pass? (stest/check `ranged-rand))))
WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced. remote: You should remove this library from non-dev builds completely because it impedes dead code elimination. remote: The best way is to use :preloads compiler option: .
project.clj file that luminus gave me is this:
:profiles
{:uberjar {:omit-source true
:prep-tasks ["compile" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
:aot :all
:uberjar-name "ai.jar"
:source-paths ["env/prod/clj" "env/prod/cljs"]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:jvm-opts ["-Dconf=dev-config.edn"]
:dependencies [[binaryage/devtools "1.0.3"]
[cider/piggieback "0.5.2"]
[org.clojure/tools.namespace "1.1.0"]
[pjstadig/humane-test-output "0.11.0"]
[prone "2021-04-23"]
[re-frisk "1.5.1"]
[ring/ring-devel "1.9.4"]
[ring/ring-mock "0.4.0"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.24.1"]
[jonase/eastwood "0.3.5"]
[cider/cider-nrepl "0.26.0"]]
:source-paths ["env/dev/clj" "env/dev/cljs" "test/cljs"]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user
:timeout 120000}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
and the shadow-cljs.edn file has this:
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:devtools {:watch-dir "resources/public"
:preloads [re-frisk.preload]}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:release {:compiler-options {:optimimizations :advanced}}}
:test {:target :node-test, :output-to "target/test/test.js"
:autorun true}}
:lein {:profile "+dev"}}
So my build process is running this: shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm release app which is the problem because calling on that lein +dev is including the stuff I don't want in release. The uberjar profile in the project.clj file is not telling it to add that +dev part in the :prep-tasks commands so how do I get that honored?/env/dev/app.cljs which is a source path only called for in the lein :project/dev profile which is why I thought it was shadow-cljs pulling in when calling that lein +dev command:preloads (or just including those things directly via preloads)shadow-cljs.edn contain Clojure code? The reason I'm asking is we have different developers with different :preloads requirements and it would be handy to have an(other) edn file that could be read to determine whose machine the shadow-cljs.edn file is on. Any other way to achieve this? I was also thinking of taking it out of version control. But a configurable option would be ideal.:local/root deps? And does that make sense?"@foo/bar"~/.shadow-cljs/config.ednshadow-cljs watch app --config-merge '{:devtools {:preloads [foo.bar]}}' or using the clojure API to start things:local/root works greatExecution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$unified.unified is not a functionHere’s a sample of the source.
(ns app.org-parser
(:require ["unified" :as unified]
["rehype-stringify" :as html]
["uniorg-parse" :as uniorg]
["uniorg-rehype" :as rehype]
["rehype-raw" :as raw]
["uniorg-extract-keywords" :refer [extractKeywords]]
shadow.resource))
(def ^:private processor
(.. (unified)
(use uniorg)
(use extractKeywords)
(use rehype)
(use raw)
(use html)))
Is there something wrong with unified such that I can’t import it?
I also tried using js/require but that didn’t work either.
require() of ES Module /Users/main/Code/clojure/mysite/node_modules/unified/index.js from /Users/main/Code/clojure/mysite/[stdin] not supported. Instead change the require of index.js in /Users/main/Code/clojure/mysite/[stdin] to a dynamic import() which is available in all CommonJS modules.
"unified$default" :as unified after switching:esm target, but you can read about it here:
https://clojureverse.org/t/generating-es-modules-browser-deno/6116script type="module"$ nbb -e 'js/process.version' "v12.22.6"
:target :esm as an option works in the browser just fine, I’m still getting the same errors when trying to use unified though.script type="module" as well?"unified$default" :as unified$default again, but after adding I get this now.
------ REPL Error while processing ---------------------------------------------
(cljs.core/load-file "/Users/main/Code/clojure/mysite/src/app/org_parser.cljs")
------ REPL Error while processing ---------------------------------------------
(ns app.org-parser
(:require ["unified$default" :as unified]
["rehype-stringify" :as html]
["uniorg-parse" :as uniorg]
["uniorg-rehype" :as rehype]
["rehype-raw" :as raw]
["uniorg-extract-keywords" :refer [extractKeywords]]
shadow.resource))
In :require [shadow.js.shim.module$unified$default :refer (unified)] already used by [shadow.js.shim.module$unified :refer (unified)]type="module" in the script tag..shadow-cljs$default to the other requires btw(ns app.org-parser
(:require ["unified$default" :as unified]
#_["uniorg-parse$default" :as uniorg]
#_["uniorg-rehype$default" :as rehype]
#_["rehype-stringify$default" :as html]
#_["rehype-raw$default" :as raw]
#_["uniorg-extract-keywords" :refer [extractKeywords]]
;;shadow.resource
))
Here’s the result.
Execution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$unified$default is not a functionLooking at the source for unified, it isn’t labeled as a default export, just an export.
export const unified = base().freeze()
"unified$unified" ?------ REPL Error while processing ---------------------------------------------
(cljs.core/load-file "/Users/main/Code/clojure/mysite/src/app/org_parser.cljs")
------ REPL Error while processing ---------------------------------------------
(ns app.org-parser
(:require ["unified$unified" :as unified]
#_["uniorg-parse$default" :as uniorg]
#_["uniorg-rehype$default" :as rehype]
#_["rehype-stringify$default" :as html]
#_["rehype-raw$default" :as raw]
#_["uniorg-extract-keywords" :refer [extractKeywords]]
#_shadow.resource
))
In :require [shadow.js.shim.module$unified$unified :refer (unified)] already used by [shadow.js.shim.module$unified$default :refer (unified)]cljs.user> (ns app.org-parser
(:require ["unified$unified" :as unified]
#_["uniorg-parse$default" :as uniorg]
#_["uniorg-rehype$default" :as rehype]
#_["rehype-stringify$default" :as html]
#_["rehype-raw$default" :as raw]
#_["uniorg-extract-keywords" :refer [extractKeywords]]
#_shadow.resource
))
nil
Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$unified$unified is not a function
again$ nbb -e '(ns foo (:require ["unified$unified" :as u])) (.log js/console u)'
[Function: processor] {
data: [Function: data],
Parser: undefined,
Compiler: undefined,
freeze: [Function: freeze],
attachers: [],
use: [Function: use],
parse: [Function: parse],
stringify: [Function: stringify],
run: [Function: run],
runSync: [Function: runSync],
process: [Function: process],
processSync: [Function: processSync]
}yarn add but I think that’s effectively the sameunified somewhere?:esmExecution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$unified$unified is not a functionOk, minimal project here: https://github.com/wildwestrom/minimal-unified-troubleshooting
cider-connect-cljs in emacs. I don’t know what the equivalent is in your editor.yarn start then cider-connect-cljs.npx shadow-cljs watch app(require 'foo :reload) workflowimport("./file.js")? Basically removing configuration step in build config. I was thinking about something like a macro that would inject modules configuration into shadow’s build state, not sure if it makes sense. cc @dazldimport(..) within script type="module" to lazy-load a shadow-cljs module. (context is to load new react page component then render after url change)
Currently hitting an issue where such import will download a shared module again, so if home & about module both depends on shared module then both imports will trigger shared module download. Which leads to duplicated cljs namespace error or even React error due to different React/ReactDOM instance kind of thing.reagent.core I lazily load the reagent module using js/import. I don't understand what you need from shadow since this is already supported?:advanced can do so much more with static informationjs/require to load modules./foo.js file is created by this chunk https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L492-L494shadow.loader only works in a browser environment, not react-nativejs/require is actually dynamic though. I don't use react-native and don't know what the situation there ispublic folder in a resources directory but whenever I make that switch my backend messes up. It says that foo is not defined in foo.core.main() portion of the js script in my index.html. What I changed in my shadow-cljs.edn file was the :output-dir to "resources/public/js" instead of "public/js" , the :asset-path to "/public/js" instead of "/js" and the :http-root to "resources/public" instead of "public" .shadow-cljs watch app still works as expected with those changes"/js" since that is the path to access the actual files over http[BABEL] Note: The code generator has deoptimised the styling of "node_modules/@firebase/firestore/dist/index.esm2017.js" as it exceeds the max of "500KB".
And I get error in chrome saying
shadow-cljs - failed to load module$node_modules$$firebase$app$dist$index_esm2017:client {:target :browser
:output-dir "dist/client/js"
:asset-path "js"
:modules {:main {:entries [percap.client.core]}}
:devtools {:before-load percap.client.core/stop
:after-load percap.client.core/start
:http-root "dist/client"
:http-port 8022}}js/required the chunk on a click in the app, and confirmed that the chunk .js file was indeed loaded dynamically:chunks for RN is the status-im stuff. always good to have some more data on hand for this stuff 🙂:chunks is sugar over :modules - and the js/require stuff in RN itself is all pretty vanilla - so altogether there doesn't seem to be anything scary or magical about the splitting or loading mechanisms, which definitely gave me some comfort:modules (or now called :chunks) so it was quite easy:chunks directly:chunks - i did wonder:modules, just a renamejs/requirejs/require is sync - doesn't matter to me though - tiny (mostly not noticeable, unless you've got one of those underpowered old 'droids, in which case you are used to them) pauses throughout a session vs big pause at the start of a session:advanced will affect the bundle sizesign-in and home module, and the home bundle would start downloading as soon as I click login. But it would make a lot more sense to say ‘after sign-in has mounted, start downloading the home module’. With webpack I could do this
function SignUp() {
useEffect(() => {
import('./home')
}, []);
...
}
Is there a way of doing this with shadow?:users
{:entries [demo.components.account-overview
demo.components.sign-in
demo.components.sign-up]
:depends-on #{:main}}
But I wanted to know if you can have individual bundles, but pre download future bundles after a page has loaded and the component has mounted(useEffect #(sl/load users-bundle) #js []) would be the preloading your mentioned:modules yourself. I believe that to a better way to do stuff but it requires more thoughtlazy-component workedlazy-component was just a util to make the blogpost code less verbose:js-provider :external js-options.external-index file to do some tree shaking with for eg. webpack, right?require are "global" in compare in my CLJS code.
ALL["@ant-design/icons"] = require("@ant-design/icons");
ALL["@ant-design/pro-layout"] = require("@ant-design/pro-layout");
ALL["react-dom"] = require("react-dom");["antd/es/button" :default Button]
["@ant-design/pro-layout" :default ProLayout :refer [PageContainer]]
["@ant-design/icons" :refer [AppstoreOutlined FileTextOutlined LikeOutlined SettingOutlined AlipayCircleFilled]]@ant-design/icons directly which itself imports thousands of other things you are unlikely to use(:require ["@ant-design/icons/FileTextOutlined" :as FileTextOutlined]):js-provider :external because Ant design lib relies heavily on importing less css file for all his componentsnode_modules/antd/es/tag/style/index.js:import '../../style/index.less'; node_modules/antd/es/tag/style/index.js:import './index.less'; node_modules/antd/es/time-picker/style/index.js:import '../../style/index.less'; node_modules/antd/es/time-picker/style/index.js:import './index.less'; // style dependencies
ignore-asset-requires true:js-provider :external is the only solution, right?external-index file size is 1.8M 😕import { Thing } from "thing" instead of require but that had all sorts of other issues(:require ["react" :as react]) that would map to import * as react from "react" but given that react is shipped as commonjs only it must be imported via import react from "react"external-index bundled by webpack weight more than 1,1Mb.["@ant-design/pro-layout" :default ProLayout :refer [PageContainer]] ["@ant-design/icons/AppstoreOutlined" :default AppstoreOutlined] ["@ant-design/icons/FileTextOutlined" :default FileTextOutlined] ["@ant-design/icons/LikeOutlined" :default LikeOutlined] ["@ant-design/icons/SettingOutlined" :default SettingOutlined] ["@ant-design/icons/AlipayCircleFilled" :default AlipayCircleFilled]
external-index file uses commonjs require then I can't do anything at webpack level, like eg tree shaking like with es import, right?require(ns foo.bar) (def dog "doug")and another namespace
(ns foo.bar.dog) ;; other stuffI end up with a namespace clash
Namespace foo.bar.dog clashes with var foo.bar/dogThat makes sense, I understand why that happens. Is there a way to work around this without renaming namespaces or vars? I was thinking there would be some configuration for my
:target :browser build where I could declare something the effect of
"namespace foo.bar should be compiled to the name 'something_completely_different' on the output javascript object"
It's not that big of a deal, I can always rename, but it would be nice to be able to keep the ones I have right now.:esm build target be helpful there as well, since it basically generates the same source for browser and node?:target :node-script basically. one :main one :main your.worker/main. no clue what you mean by "selective loading of deps". if that refers to loading CLJS namespaces on demand then your only option is going self hostedisMainThread checking all over the place bad practice (just like regular web-workers) so I always go with writing your own entry namespace for the worker that is only ever loaded in the worker and as such never has to check what it is supposed to be--config-merge to work:
clojure -m shadow.cljs.devtools.cli --config-merge '{:js-options {:js-package-dirs ["external/frontend_npm/node_modules"]}}' release frontend
returns:
Searched for npm packages in:
/Users/arohner/Programming/griffin/banksy/node_modules
i.e. without updating the actual list of package-dirs. Is there a way to debug what the config looks like post merge?:js-package-dirs is used:release {:js-options {:js-package-dirs ["external/frontend_npm/node_modules"]}} in your build config to make it only apply to release builds but not dev?2.15.10 should allow you to config-merge js-package-dirsnpm-module isn't very well maintained:node-library and it is working fine, thank you for you help 🙂 i was stuck like 4 hours or more , we didnt find why it didn't work, but now all seem fine:target :esm for both browser and node now btw, but it's somewhat undocumentedcljs is not defined is not one of them but I can't say more without seeing actual code and config and how you use it. Don't know what the MongoServerSelectionError is about?(defn f1 []
(go (let [mongodb (js/require "mongodb")
MongoClient (.-MongoClient mongodb)
_ (prn "Until here is ok")
_ (prn MongoClient)
client (<p! (.connect (MongoClient. "" (clj->js {"useUnifiedTopology" true}))))
_ (prn "Will never be printed if :npm-library")
])))
(f1)Uncaught:
cljs$core$ExceptionInfo [Error]: Promise error
at new cljs$core$ExceptionInfo (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.js:37699:10)
at Function.cljs$core$IFn$_invoke$arity$3 (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.js:37760:9)
at /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.async.interop.js:32:84 {
data: {
meta: null,
cnt: 1,
arr: [ [Object], [Object] ],
__hash: null,
'cljs$lang$protocol_mask$partition0$': 16647951,
'cljs$lang$protocol_mask$partition1$': 139268
},
cause: MongoServerSelectionError: cljs is not defined
at Timeout._onTimeout (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/mongodb/lib/sdam/topology.js:310:38)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: [Map],
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
}
},
description: undefined,
number: undefined,
fileName: undefined,
lineNumber: undefined,
columnNumber: undefined
}cljs is not defined:npm-library now only works with :node-library and :node-script~/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp$ node
Welcome to Node.js v12.22.6.
Type ".help" for more information.
> var c=require("./queries/clojurescriptapp.core");
undefined
> "Until here is ok"
#object[MongoClient]
Uncaught:.....the above error........mongodb (js/require "mongodb") in a go block? none of this should be a in a go blockgo in general makes everything 1000x harder to debug, so avoid it if you can:npm-module in the first place? why do you want to use it?:builds {:library {:target :npm-module
:output-dir "./queries"
:compiler-options {:infer-externs true}
:entries [clojurescriptapp.core]}
:library2 {:target :node-library
:output-to "dist/index.js"
:exports {:f1 clojurescriptapp.core/f1}}
:app {:target :node-script
:output-to "target/main.js"
:source-map true
:main clojurescriptapp.core/main
:compiler-options {:infer-externs true}
:devtools {:repl-init-ns clojurescriptapp.core
:repl-pprint true}
}}:node-library is recommended{
"name": "clojurescriptapp",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"watch": "shadow-cljs watch app",
"compile": "shadow-cljs compile app",
"build": "shadow-cljs release app"
},
"keywords": [],
"author": "takis",
"license": "MIT",
"devDependencies": {
"shadow-cljs": "^2.10.12",
"source-map-support": "^0.5.19",
"ws": "^7.3.0",
"mongodb": "4.0.0"
}
}2.10 is ancient history by now:deps or :lein in shadow-cljs.edn?shadow-cljs info will tell you the version{:source-paths ["src"]
:dependencies [[cmql "0.1.0-SNAPSHOT"]
[cmql-js "0.1.0-SNAPSHOT"]]
:builds {:library {:target :npm-module
:output-dir "./queries"
:compiler-options {:infer-externs true}
:entries [clojurescriptapp.core]}
:library2 {:target :node-library
:output-to "dist/index.js"
:exports {:f1 clojurescriptapp.core/f1}}
:app {:target :node-script
:output-to "target/main.js"
:source-map true
:main clojurescriptapp.core/main
:compiler-options {:infer-externs true}
:devtools {:repl-init-ns clojurescriptapp.core
:repl-pprint true}
}}}shadow-cljs info shadow-cljs - config: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/shadow-cljs.edn === Version jar: 2.15.9 cli: 2.15.9 deps: 1.3.2 config-version: 2.15.9 === Paths cli: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/shadow-cljs/cli/dist.js config: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/shadow-cljs.edn project: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp cache: .shadow-cljs
(ns whatever
(:require ["mongodb" :as mdb]))
(defn f1 []
(-> (mdb/MongoClient. "" #js {:useUnifiedTopology true})
(.connect)
(.then (fn []
(prn [:mongodb-connected])
))))~/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp$ node
Welcome to Node.js v12.22.6.
Type ".help" for more information.
> var c=require("./queries/clojurescriptapp.core");
undefined
> c.f1();
Promise { <pending> }
> (node:8986) UnhandledPromiseRejectionWarning: MongoServerSelectionError: cljs is not defined
at Timeout._onTimeout (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/mongodb/lib/sdam/topology.js:310:38)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(node:8986) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 1)
(node:8986) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.TypeError: _system.keyframes is not a function.
The relevant file has var _system = require("@mui/system"); but _system itself is... 0.
What would be the right way to fix it?:output-feature-set :es5 works.
But :output-feature-set :es6 doesn't.shadow-cljs watch server app but I think I want to turn off hot reloading because I'm setting local vars to aid debugging and they are lost when the namespace reloads.shadow-cljs compile server app but it wasn't happy.stop-autobuild.(shadow.cljs.devtools.api/watch-set-autobuild! :the-build-id false) to stop the automatic rebuild or you can set :devtools {:autoload false} in your build config to still run the automatic watch rebuild but not automatically load it(shadow.cljs.devtools.api/watch :the-build-id {:autobuild false})eternal-index js-options, I had this warning:
[:app] Compiling ... ------ WARNING #1 - ----------------------------------------------------------- Resource: shadow.js.shim.module$react_dom.js:3:34 variable shadow$bridge is undeclared
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli-actual/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:110)
...
Caused by:
Hook [0 shadow.cljs.build-report/hook] failed in stage :flush
NoSuchFileException: .shadow-cljs/release-snapshots/my-build/latest/main.js
I am not sure where main.js is coming from...:modulesbut if you use :output-to then it gets named something completely different.:browser target:node-library and it is missing :modules {:main {}} ?shadow-cljs watch app . I'm using WSL on windows via VS Code.
This project I'm trying to run works perfectly on my Ubuntu machine. But when I try to run watch app on WSL I'm getting the following error:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "502324253122242310287d3c31207d656662"}, :content ("[email protected]")}
Any ideas what I'm doing wrong.
My shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[binaryage/devtools "0.9.10"]
[reagent "1.0.0"]
[re-frame "1.2.0"]
[day8.re-frame/re-frame-10x "1.0.1"]
[day8.re-frame/http-fx "0.2.3"]
[bidi "2.1.6"]
[cljs-ajax "0.8.1"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.rpl/specter "1.1.3"]]
:nrepl {:port 3333}
:dev-http {8080 "public"}
:builds {:app {:target :browser
:output-dir "public/js"
:modules {:main {:init-fn }}
:compiler-options {:closure-defines {re-frame.trace/trace-enabled? true
day8.re-frame.tracing/trace-enabled? true}}
:devtools {:http-root "public"
:http-port 3000
:preloads [day8.re-frame-10x.preload]}}}}
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f88b8c8d998a8c8bb880d5949988d5cdceca"}, :content ("[email protected]")}[com.cognitect/transit-cljs "0.8.269"] [com.cognitect/transit-clj "1.0.324"]
:dependencies?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "daa9aeafbba8aea99aa2f7b6bbaaf7efece8"}, :content ("[email protected]")}npm install shadow-cljs and ./node_modules/bin/shadow-cljs to use latest version
• Does moving the project into the Linux FS instead of /mnt/c work?shadow-cljs classpath show anything wrong?npm-check-upgradesnpm init and put in whatever.
2. npm install --save-dev shadow-cljs
3. ./node_modules/.bin/shadow-cljs watch app/tmp/clojure-11163815081130707132.edn?:clojure.error/class java.lang.NoClassDefFoundError, :clojure.error/line -2, :clojure.error/cause "Could not initialize class cognitect.transit__init",
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "84f7f0f1e5f6f0f7c4fca9e8e5f4a9b1b2b6"}, :content ("[email protected]")}:aot false in your shadow-cljs.edn config? same level as :source-paths{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d0a3a4a5b1a2a4a390a8fdbcb1a0fde5e6e2"}, :content ("[email protected]")}
:resolve with :target :file in the :js-options, the changes to the specified file doesn’t trigger a re-compile. is this expected?~/.m2/repositories dir. maybe there is something weird going on there. It'll just download all the files again"(in-ns ':repl/exception!)" that doesn't look rightrm -rf public/js? no it does notcljs-runtime before deploying.
This dir size is over 60Mb for my project.public/js/cljs-runtimerm and then shadow-cljs release apprimraf from npm is also useful. shadow-cljs itself does not have anything to delete stuffwasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type 'text/plain' expected 'application/wasm' and falling back to ArrayBuffer instantiation .{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4a380a3a253a672539"}, :content ("[email protected]")}:source-paths needs to be adjusted:libs (aka Google closure style ns) to shadow-cljs?:libs option:libs? I don't really know what that does?shadow-cljs - failed to load – "module$node_modules$$mui$material$node$ButtonBase$TouchRipple":compiler-options {:output-feature-set :es5}["@mui/material/Button" :default Button] . Thanks again!:main-opts such that it both calls a clj function in my project and start Shadow watching?project.clj, started my apps web server, and shadow still started watching:
:main ^:skip-aot sandbox.flag-yard.coreI’m failing to replicate this behaviour using deps.edn.
:main-opts at the root level…deps.edn like so:
:deps {b/b {:local/root "<path-to-b>"}
Where B has an npm dependency on something-something. How can I make shadow-cljs in project A look in project B for the dependency? Right now shadow complaints:
The required JS dependency "something-something" is not available, it was required by "B/some_file.cljs".
:js-options {:js-package-dirs ["node_modules" "<path-to-b>/node_modules"]}deps.cljs declaring :npm-depspackage.json and :npm-deps?deps.cljs with :npm-deps. nothing else is relevant for thatb/b has a npm dependency that your main project does not haveb/b to your main project you need deps.cljs:js-package-dirs but that has other issuesdeps.cljs and should manage its dependencies directly via package.jsondeps.cljs:npm-deps there now.deps.cljs:js-package-dirs from project A, and having this in b/deps.edn:
{:paths ["src"]
:npm-deps {"something-something" "X.X.X"}}
Also removing package.json and node_modules from B. Then restart shadow, reload the app and try to evaluate a namespace that requires "something-something". I get that error back:
The required JS dependency "something-something" is not available, it was required by "B/some_file.cljs".Either i have misconfigured something, or misunderstood something (or both).
a/deps.edn
{:deps {...
b/b {:local/root "../projects/b"}
...}
b/deps.edn
{:paths ["src"]}
b/src/deps.cljs
{:npm-deps {"something-something" "X.X.X"}}
Still getting that error message when connecting to a’s REPL and loading a file that requires in the thing on b that needs the npm thing. Does shadow want something more? (There’s no shadow-cljs.edn in b, for example.):main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "foo"]When I started it using shadow-cljs the download of the npm thing happened. But a lot of other things do not happen, so I can’t really go this way. Is
:js-package-dir what I should turn to anyway, you think?:js-package-dirs is totally fine, just more prone to potential dependenciy version conflictsnpm install for those packages and that in turn modifies your package.json. shadow-cljs itself does not modify it directly{:deps true
:dev-http {8000 "public"}
:builds {:app {:target :browser
:output-dr "public/js"
:asset-path "js"
:modules {:main {:entries [re-frame-routing.core]}}}}}
and commented out clojurescrript in the deps (otherwise it through an error, but i'm not sure why).
2. added a public/index.html file
3. ran cider-jack-in-cljs shadow > :app (build) > start browser
this starts a repl, but it doesn't seem to send expressions to it.browser-repl or node-repl depending on what you needcider-jack-in-cljs runs so I can only say that you do need a running watch fore the REPL to work:test
{:target :node-test
:output-to "target/node-test"
:autorun true}
And then running shadow-cljs watch test , the build completes, but it doesn't seem to run the tests. Any tips?karma.conf.js
and the attached screenshotnode out/node-tests.js
node-test should do that, sorry on the karma brainfart haha:output-to is supposed to be a file not a directory. so its missing the .js at least. it might fail to run because of that maybe?clojure.core.async.interop/<p!` and (.foo bar) .
This will happen in code like this:
(defn run []
(go
(let [conn (Connection. host)
market (<p! (.load Market conn market-addr #js {} serum-program-addr))
bids (<p! (.loadBids market conn))
asks (<p! (.loadAsks market conn))])))go loses all typehint info so the cljs.compiler cannot infer anything. I'd suggest keeping interop code out go loops entirely. can be a little bit annoying but (defn load-bids [^js market conn] (.loaderBids market conn)) and then just (<p! (load-bids market conn)) will not have any typehint issuesgo in the first place 😛<p! returns is a javascript object by adding type hint.:compiler-options {:output-feature-set :es5} the only way to use MUI 5+? I need to use @mui/x-data-grid which when compiled to ES5, gives this error:
[:main] Build failure: Closure compilation failed with 1 errors --- node_modules/@mui/x-data-grid/index-cjs.js:3 Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.
:compiler-options {:output-feature-set :es2018} gives another error as @gingerwizard was talking about:
shadow-cljs - failed to load – "module$node_modules$$mui$material$node$ButtonBase$TouchRipple"
:output-feature-set :es5.:output-feature-set fix it?shadow.build.test-util/find-test-namespaces calls cp/find-cljs-namespaces-in-files. I’m trying to use shadow with bazel, which strongly prefers JVM code to be distributed as jars rather than files, so I would like that to search through the proper classpath, rather than directories. Would you accept a PR that switches that to use tools.namespace to search through files and jars?tools.namespace. you can always create a namespace that requires all your tests and use :entries [that.collect-ns] or just :entries [my.foo-test my.bar-test]that.collect-ns for you. just needs to be (ns that.collect-ns (:require my.foo-test my.bar-test)) etccheckouts from lein when using shadow-cljs? My use case is that I am developing a library on my local that I will eventually put into clojars and I have a few projects that are consuming the same library. At the moment I am using symlinks from the src directory but I wonder if there is a better way?shadow-cljs.edn currently no. deps.edn or lein work as normal:local/root setupshared.js:1552 TypeError: Super expression must either be null or a function, not undefined
at _inherits (control.js:26)
at eval (control.js:50)
at Object.shadow$provide.module$node_modules$react_leaflet_control$dist$control (control.js:49)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at eval (quagga.components.dataview.map.view.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:486)
at Object.env.evalLoad (shared.js:1549)
at tabbed-dataview.js:250["react-leaflet-control" :default Control]
[:<>
[:> TileLayer {:url "https://{s}.}]
[:> ZoomControl {:position "bottomleft"}]
[:> Control [:button "click me"]]
[:> FeatureGroup
(map
(fn [position] [:> Marker
{:position position,
:key position,
:eventHandlers {:click (fn [e]
(js/console.log
(-> e
.-target
.-_latlng)))}}])
geopoint-positions)]](ns example.views
(:require
["react-leaflet-control" :default Control]
["react-leaflet" :refer [Map TileLayer ZoomControl]]
(defn main-panel [style]
[:div {:style style}
[:> Map {:center [51.3 0.7] :zoom 10}
[:> ZoomControl {:position "topright"}]
[:> TileLayer {:url "http://{s}."
:maxZoom 18}]
[:> Control {:position "topleft"}
[:button "click me"]
"Reset View"]]])
this is from https://www.npmjs.com/package/react-leaflet-control I ported the example to cljsrn-rf-shadow React Native project and facing issues with live reload
The project structure is as below
;; app.cljs
(ns
(:require [example.events]
[example.subs]
[expo.root :as expo-root]
["react-native" :refer [View]]
[example.screens.home :refer [home-screen]]))
(defn root []
[:> View
[home-screen]])
(defn start
{:dev/after-load true}
[]
(expo-root/render-root (r/as-element [root])))
...
;; screens/home.cljs
(ns example.screens.home
(:require ["react-native" :refer [SafeAreaView Text]]
[example.components.image :refer [image]]))
(def clojure-image (js/require "../assets/images/clojure.png"))
(defn home-screen []
[:> SafeAreaView
[:> Text "Hello World"]
[image clojure-image]
;; components/image.cljs
(ns example.components.image
(:require ["react-native" :refer [Image View]]))
(defn image [user-image]
[:> View {:style {:height 46
:width 46}
[:> Image {:source user-image
:style {:height 40
:width 40}}]])
Live reloading for any change I make in home.cljs or app.cljs is working perfectly fine. But isn’t working for changes in image.cljs I will have to do some dummy change in home.cljs everytime for the live reload to work.
I see that this was already asked here https://github.com/thheller/shadow-cljs/issues/544, but the specified solution only works for children (imported) in app.cljs
I tried ^:dev/always to app namespace like so (ns ^:dev/always ) and that doesn’t seem to work either.
Is there any solution for this. Am I missing something ?expo.root is so can't say[shadow.expo :as expo] from your reagent-expo example and the behaviour is same.
(ns
(:require [shadow.expo :as expo]
[re-frame.core :as rf]
["react-native" :refer [View]]
[reagent.core :as r]
[example.screens.home :refer [home-screen]]))
(defn root []
[:> View
[home-screen]])
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [root])))
(defn init []
(rf/dispatch-sync [:initialize-db])
(start)){:dev/after-load true} as suggested in the issue
;; app.cljs
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [root {:x (js/Date.now)}])))
Only works for changes in imports (children) of app.cljs
But don’t work for grandchildren.
Strange that this doesn’t happen for web development and only for react-native:devtools {:reload-strategy :full} in your build config to reload many more files than it usually would[root] didn't change. so reagent/react decide they can stop rendering completely and never get to the actual image which actually changed{:dev/after-load true} Yes I’ve tried this. Same behaviour.[root {:x (js/Date.now)}]:dev/after-load just tells shadow-cljs which function to call after its done reloading code. you need that regardless:x would be the "hack" to force reagent/react to actually render the component and not skip it➜ malli-ts git:(master) ✗ node
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> let malli_ts = require('malli_ts.ts')
Uncaught TypeError: Cannot read property 'Error' of undefined
at Object.<anonymous> (/home/tiago/Documents/side-projects/malli-ts/node_modules/goog.debug.error.js:38:29)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18){:target :npm-module
:output-dir "node_modules/"
:entries [malli-ts.ts]}:node-library over :npm-module when you can:node-library and it's working fine 🙂npm link is there any way to get shadow to hot reload them as the bundle for that linked package is updated?package.json files for changes, so if you touch package.json it should update.cljs file requires a .js file which requires an npm module. See below for a ~10-line example.Module not provided: shadow.js.shim.module$express, but I can confirm that that file is buried in my .shadow-cljs/... directory as I would expect.require(...) as opposed to import?require, nor node.js-specific features like filesystem access? Such that I can run the code in the d8 or jsc javascript consoles?:target configurations with :optimizations set to simple but couldn't get anything rolling.
I was able to find some benchmark code in the clojurescript repo that runs cljs stuff in d8 and jsc, so I know at some level this sort of thing is tenable:node-script release build should be ok in d8/jsc. either simple or advanced. watch or compile won't workgoog.global=global with goog.global=globalThis (not sure if that is correct though) then I get
> public/script.js:4203: ReferenceError: require is not defined
> ...
> shadow.js.shim.module$react=require("react");
> ...
I don't think d8 has require available 😕:js-options {:js-provider :shadow} in your build config. that'll make shadow-cljs bundle all dependencies so the result doesn't contain require anymore:alone
{:target :browser
:debug false
:output-to "public/script.js"
:main re-db.test/-main
:js-options {:js-provider :shadow}
:compiler-options {:optimizations :simple :pseudo-names true}
:output-dir "public/bench/js"
:modules {:bench {:entries [re-db.test]}}}
public/bench/js/bench.js:4428: TypeError: Cannot read properties of undefined (reading 'abs')
shadow.js.files[$i$jscomp$309_name$$],$moduleFn$$=shadow$provide[$i$jscomp$309_name$$];if(void 0===$module$$){if(void 0===$moduleFn$$)throw"Module not provided: "+$i$jscomp$309_name$$;$module$$={exports:{}};shadow.js.files[$i$jscomp$309_name$$]=$module$$}if($moduleFn$$){delete shadow$provide[$i$jscomp$309_name$$];try{$moduleFn$$.call($module$$,goog.global,shadow.js.jsRequire,$module$$,$module$$.exports)}catch($e$$){throw console.warn("shadow-cljs - failed to load",$i$jscomp$309_name$$),$e$$;}if($opts$$){var $globals$$=
^
TypeError: Cannot read properties of undefined (reading 'abs')
at Fa (public/bench/js/bench.js:208:349)
at Object.<anonymous> (public/bench/js/bench.js:225:174)
at Object.shadow$provide.<computed> (public/bench/js/bench.js:225:258)
at Object.shadow.js.jsRequire (public/bench/js/bench.js:4428:332)
at Object.shadow.js.require (public/bench/js/bench.js:4429:417)
at public/bench/js/bench.js:10843:137
at public/bench/js/bench.js:11772:4deps.edn file because I needed a dependency to be a local checkout (I followed https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn). But now, when I cider-jack-in-cljs, should I choose clojure-cli or shadow-cljs as the connection method? (before, I was choosing the latter).
Both give me problems:
• clojure-cli will give me:
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). shadow-cljs has not been started yet! In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it. If you have a shadow-cljs server or watch running then you are not connected to that process.•
shadow-cljs will give me:
[:app] Build failure: The required namespace "minimal.core" is not available.
shadow-cljs in the end (I was using a wrong path in paths):browser-test target combined with enabling :devtools :loader-mode :script, as well as loading the individually compiled files using an approach similar to the :node-test target, using vm. It more or less works, but is a little hacky.
Thinking about some improvements to this, one thing that looks interesting is Jest’s https://jestjs.io/docs/code-transformation capability, as it could theoretically allow us to “run” CLJS files directly rather than running Jest against the compiled target output. To do this we would need to be able to do two things: 1. Compile an arbitrary file, with goog.require statements that also handles node modules in a nice way, and 2. Generate the dependencies for that arbitrary file.
I’m curious how feasible this would be, or if there would need to be work done to enable this. Any thoughts?:npm-module is probably your best bet. I don't know how jest works internally though so no clue what it needs. the code transformation definitely won't work since that can't invoke JVM code:npm-module already handles the require calls correctly?):npm-module is just the most generic way to run CLJS code in JS based toolsdescribe and it to run tests. If it sees a require statement it does some additional stuff too. Would using :npm-module work well with :loader-mode :script ? Jest works best with individual files because it parallelizes the files it runs as well, so a single bundled file isn’t ideal:loader-mode :script is an entirely different thing and doesn't apply:npm-module. if jest really doesn't do anything special it'll just work:browser-test worked then it'll most definitely workns-regexp, will this also work with :npm-module?:ns-regexp worksns-regexp. When it’s present, I get a stack trace:
[:jest] Configuring build.
[:jest] Compiling ...
[:jest] Build failure:
NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
clojure.core/deref-future (core.clj:2304)
clojure.core/deref (core.clj:2324)
clojure.core/deref (core.clj:2310)
shadow.build.classpath/get-classpath-entries (classpath.clj:808)
shadow.build.classpath/get-classpath-entries (classpath.clj:807)
shadow.build.classpath/find-cljs-namespaces-in-files (classpath.clj:1250)
shadow.build.classpath/find-cljs-namespaces-in-files (classpath.clj:1247)
shadow.build.test-util/find-test-namespaces (test_util.clj:16)
shadow.build.test-util/find-test-namespaces (test_util.clj:7)
shadow.build.targets.npm-module/resolve* (npm_module.clj:78)
shadow.build.targets.npm-module/resolve* (npm_module.clj:67)
clojure.core/apply (core.clj:669)
clojure.core/update-in/up--6870 (core.clj:6174)
clojure.core/update-in/up--6870 (core.clj:6173)
clojure.core/update-in (core.clj:6175)
clojure.core/update-in (core.clj:6161)
shadow.build.targets.npm-module/resolve (npm_module.clj:102)
shadow.build.targets.npm-module/resolve (npm_module.clj:100)
shadow.build.targets.npm-module/process (npm_module.clj:112)
shadow.build.targets.npm-module/process (npm_module.clj:105)
clojure.lang.Var.invoke (Var.java:384)
shadow.build/process-stage/fn--16319 (build.clj:160)
shadow.build/process-stage (build.clj:157)
shadow.build/process-stage (build.clj:149)
shadow.build/resolve (build.clj:405)
shadow.build/resolve (build.clj:401)
shadow.build/compile (build.clj:439)
shadow.build/compile (build.clj:432)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/eval17936/fn--17938 (impl.clj:439)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--17698/fn--17699/fn--17707 (util.clj:284)
shadow.cljs.devtools.server.util/server-thread/fn--17698/fn--17699 (util.clj:283)
shadow.cljs.devtools.server.util/server-thread/fn--17698 (util.clj:256)
java.lang.Thread.run (Thread.java:831)
if I remove :ns-regexp it goes further and produces an expected error rather than the stack traceshadow-cljs.edn), so the only question remaining is if it’s possible to get a manifest.json file for the :npm-module build. I added :build-options :manifest-name "manifest.json" to my config but it didn’t seem to work:js-options
{:resolve {"react" {:target :global
:global "React"}}}}ReferenceError: self is not defined from the very early assignment goog.global=this||self. I have "type": "module" in my package.json file and am trying to create an ES module package. Anyone have any pointers as to what is going on there?:target :esm for node as well.:target :esm was an option:target :node-library published to npm? that by default doesn't bundle any dependencies so no further configuration is required. whether you declare your dependency on react as a regular dependency or node peerDependency is up to you and doesn't matter from the shadow-cljs perspective:target :node-script. It is consuming a library via :local/root which I am developing locally and it also has a deps.edn with a :npm-deps in it. Is there something I should do to make those :npm-deps from the library get installed into the top level project?:npm-deps don't belong and deps.edn and have no effect there for anything. they need to be declared in a deps.cljs file on the classpath. if your library does that then packages should be installed in the main project.^:dev/alwaysshadow.cljs.devtools.server.repl-impl/do-repl in the (experimental) shadow-cljs support for an editor plugin I'm working on. I realize that it's not part of the stable API, though. Would it be possible to have it be a part of the API (e.g. in shadow.cljs.devtools.api)? I'd be perfectly happy with something that basically just defers to shadow.cljs.devtools.server.repl-impl/do-repl without doing anything else.do-repl? I mean that is pretty REPL specific and most likely and editor should be talking directly to shadow.remote? That isn't documented much yet but the basic concept is explained here https://github.com/thheller/shadow-cljs/blob/master/doc/remote.mddo-repl uses it internallydo-repl will not become part of the public API but if you explain what exactly you need from it I can maybe adopt the shadow.cljs.devtools.api/cljs-repl?do-repl over shadow.remote. :thinking_face:do-repl?do-repl is running over shadow.remote already so anything it does you can replicatedo-repl over shadow.remote sounds like the way to go. Thanks! I might be back with possible questions regarding shadow.remote. 🙂:log {:level :debug} in your shadow-cljs.edn and it'll log a little more including the namespaces/files that triggered a compiledynCall is not a functionshadow-cljs.edn?TypeError: dynCall is not a function
at Function.eval [as bind_value] (eval at buildCallerFunction (nbind.js:1), <anonymous>:1:96)
at _nbind_value (nbind.js:1041)
at module.exports (entry-common.js:241)
at Object.shadow$provide.module$node_modules$$react_pdf$yoga$src$dist$entry_browser (entry-browser.js:41)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$react_pdf$renderer$dist$react_pdf_browser_cjs (react-pdf.browser.cjs.js:22)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at eval (rpdf.ex2.js:2)
at eval (<anonymous>)lein with-profiles +whatever run shadow.cljs.devtools.cli release your-build or so:lein {:profile "+cljs"}?out/background.js:null:null: n(null, 1, [js, new n(null, 7, [Xh
How can I disable code obfuscation?shadow-cljs release app --pseudo-names or shadow-cljs release app --debug:advanced optimizations to keep the code small:target for Chrome Extension? I see that mentioned in Basic Workflow but can't find a section for that:chrome-extension
:esm target?
[:server] Compiling ...
[2021-10-06 07:09:53.234 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/keyv/src/index.js", :requires [{:line 18, :column 14}]}
[2021-10-06 07:09:53.501 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/express/lib/view.js", :requires [{:line 81, :column 13}]}
My requires look like:
["keyv$default" :as Keyv] ["express$default" :as express]
require("some-string") but require(some_variable):target :esm intended for node you want to set :js-options {:js-provider :import}. otherwise shadow-cljs will attempt to bundle everything which won't work for many node thingsWarning: Failed prop type: The prop `open` is marked as required in `ForwardRef`, but its value is `null`.
in ForwardRef (created by WithStyles(ForwardRef))
in WithStyles(ForwardRef) (created by ui.views.reports.reports_dialog.render)
in ui.views.reports.reports_dialog.render (created by ui.views.reports.reports_dialog.init)
in ui.views.reports.reports_dialog.init (created by ui.views.meeting.home.render)
where ui.views.* is our code
since upgrading we get:
Warning: Failed prop type: The prop `open` is marked as required in `ForwardRef`, but its value is `null`.
at eval ()
at eval ()
at cmp ()
at cmp ()
at div
at eval ()
at cmp ()
so no pointer to our code at all which obviously makes it hard to work out what's up.:asset-path in your build config is misconfigured. if you get no warnings I would assume they loaded correctly and the problem is elsewherepnpm with shadow-cljs, and I appears that pnpm either does not install dependencies recursively, or that shadow-cljs does not work well with pnpm. Is there any shared experienced?:js-options {:allow-nested-packages false} in your build config. it might get confused by all the links otherwise?node_modules directory with all the packages. don't know what that looks like with pnpmCompilation failed!
------ ERROR -------------------------------------------------------------------
File: .../src/stories/components/Button.js:8:2
--------------------------------------------------------------------------------
5 | const Button = (props) => {
6 | const { variant, children, size, fontw, color, ...rest} = props;
7 | return (
8 | <button className={`button ${variant}`}
--------^-----------------------------------------------------------------------
primary expression expected
--------------------------------------------------------------------------------
9 | style={{width: `${size}`,
10 | color: `${color}`,
11 | fontWeight: `${fontw}`}}>
12 | {children.toUpperCase()}
--------------------------------------------------------------------------------
:as aliased is for the namespace so you can refer to all the stuff in the ns with the aliased/thing, you probably want to use :default for the default export. The error might be about something else though, it seems the JSX is confusing the compilation.(-> ""
(goog.string.Const/from)
(goog.html.TrustedResourceUrl/fromConstant)
(.jsloader/safeLoad)
(.addCallback some-callback-func))safeLoad)2.15.10 , getting an error in ie11 (I hate it too). I think this is because there is a single / for what looks like a regex. I have output set es5 … es6 is what should support the single / regex. This didn’t happen on the version I had previously, 2.11.23 . Is there another flag I need to set?shadow$provide[1694]=function(_c_,_a_,_e_,_b_){c=a(1556);b.UNSUPPORTED_Y=c(function(){var d=_RegExp_("a","y");d.lastIndex=2;return null!=d.exec("abcd")});b.BROKEN_CARET=c(function(){var d=_RegExp_("^r","gy");d.lastIndex=2;return null!=d.exec("str")})};NullPointerException for a release build whenever :source-map true and :source-map-include-sources-contentboth set to true. It compiles when either set to false. Is it a bug?{:infer-externs :all}. There are lots of them, so I wonder there are a list of functions from popular libraries that are known to break :advance compilation.:all. none of them are relevant__dirname is set to / so shadow's attempts to import things from __dirname + '/../.shadow-cljs/...' fail. Anyone know of a workaround there?release code in a production environment which will never use __dirname?:output-dir "functions" in addition to :output-to "functions/api.js". then it won't use __dirname eithercljs-runtime dir in the functions dir and then it errors out with no such file or directory, open '/cljs-runtime/goog.debug.error.js'functions-build and then it does some kind of build and copy of api.js over to that dirrelease can run wherever it wantsnpx shadow-cljs release lambdacljs-runtime too then it should be fine:output-to won't work:output-dir needs to be readable and should ideally not be further modified. otherwise it might mess with hot-reload and stuffcljs-runtime but that didn't work b/c it's still trying __dirname + /cljs-runtime so ends up w/ /cljs-runtime__dirname though? is this no longer following node rules?:target :npm-module or :target :node-library instead of :target :browser?:npm-module was made for that particular use case:node-library makes a few too many assumptions about being for node so I wouldn't recommend that:jvm-opts ["-Xmx512m"] are there any settings to limit the RAM and CPU consumption of shadow-cljs? Like reducing the number of files watched, disabling some services? I use a low end device to learn the basics of reagent.ReferenceError: goog is not defined
at call (../.shadow-cljs/builds/test/dev/out/cljs-runtime/goog/debug/error.js:15:1)
at SHADOW_IMPORT (out.js:62:44)
at Object.<anonymous> (out.js:1522:1):target :node-test because the tests are intended to run in node and jsdom (with Testing Library).:target :npm-module instead. :node-test is pretty specific to run cljs.test in node. you can use :ns-regexp "-test$" to get similar behavior as :node-test with regards to which files are includedFAIL dist-test/todomvc.app_spec.js
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (../node_modules/@jest/core/build/TestScheduler.js:175:18)
at Array.map (<anonymous>)jest.config.js
testMatch: [
"**/*_spec.js"
],{:target :npm-module
:ns-regexp "-spec$"
:output-dir "dist-test"}:browser-test target but that felt hacky and I thought there must be a better way:npm-module seems to work as far as I can tellFAIL dist-test/todomvc.app_spec.js
✕ arithmetic (5 ms)
● arithmetic
expect(received).toBe(expected) // equality
Expected: 5
Received: 4
at Object.<anonymous> (todomvc/app_spec.cljs:9:27)release seems to work so seems all good:target :jest if needed but AFAICT :npm-module seems to do everything you'd needPASS dist-test/todomvc.app_spec.js ✓ arithmetic (2 ms) Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 0.578 s, estimated 1 s Ran all test suites.
require() etc - the combination of node's require() and goog.provide etc is not something I can claim to understand:npm-module basically creates some glue code to pretend we still have everything in the same global scope but actually don't:target :commonjs but oh well naming is hard 😛cp src/test/todomvc/app_spec.cljs src/test/todomvc/another_spec.cljs
• in the shadow terminal Resource does not have expected namespace
• compilation stops
• ok fair enough, need to fix the ns decl
• open that file in emacs and rename to (ns todomvc.another-spec)
expected
• now that I've fixed the ns decl, compilation works again
actual
• it doesn't compile, I need to ^C and restart
• then it works(shadow.cljs.devtools.api/watch-compile! :the-build)(cider-eval-buffer) and that's itshadow-cljs clj-repl it is then 😉$ shadow-cljs clj-repl shadow-cljs - config: /Users/user/pitch/shadow-jest/shadow-cljs.edn shadow-cljs - connected to server shadow-cljs - REPL - see (help) To quit, type: :repl/quit shadow.user=>
shadow-cljs - connected to serverlein repl :client ....watch you have I guess(shadow.cljs.devtools.api/watch :app) [:app] Configuring build. [:app] Compiling ...
(shadow/watch :app) from shadow.user 🙂shadow-cljs server these days and do the rest over the UIuser.clj sitting on the classpath that contributes most of the slowness. Otherwise IMHO its fine.lein tries to do too may things, so it ends up not doing any of these well.
But of course I shouldn't have said "damage". We owe a lot to lein's original authors, and I'm in no position to complain, having written little in the way of OSStesting messages are not printed. Is that expected, is there any solution?
Unsure whether it is about shadow or CLJS itself.testing once 😛try-catch so it wouldn't work in an async setup.
Which is a tad weird since async examples do use testing: https://clojurescript.org/tools/testingcljs.test. :node-test can do selective test runs just fine:browser-test just never got around to itcljs.test isn't great overall I'd agree on that but the basics are fine. All the macros really are the problemshadow.test fixes that and beyond that there is just some UI that needs to be written to get the fancy stufftesting stuff can be made to work with async tests$ plk ClojureScript 1.10.597 cljs.user=> (require '[clojure.test :as t]) nil cljs.user=> (t/deftest foobar (t/async done (t/testing "dude" (js/setTimeout (fn [] (t/is (= 3 4)) (done)) 1000)))) #'cljs.user/foobar cljs.user=> (foobar) 1 FAIL in (foobar) (:) expected: (= 3 4) actual: (not (= 3 4)) cljs.user=> (t/deftest foobar (t/testing "dude" (t/is (= 3 4)))) #'cljs.user/foobar cljs.user=> (foobar) FAIL in (foobar) (file:44:173) dude expected: (= 3 4) actual: (not (= 3 4))
try/finally just isn't going to work with async, the finally block is of course executed too earlytesting into the callback, but then it won't nest properly2.15.11 from 2.15.10 and my project and tests started to throwing this https://github.com/rafaeldelboni/stasis/runs/3852914797?check_suite_focus=true:
Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$lib$react_markdown'
Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$index'
Chrome Headless 94.0.4606.0 (Linux x86_64) ERROR
Uncaught ReferenceError: babelHelpers is not defined
at ci.js:116796:9
ReferenceError: babelHelpers is not defined
at Object.shadow$provide.module$node_modules$react_markdown$lib$react_markdown (ci.js:188082:442)
at shadow.js.jsRequire (ci.js:116793:18)
at Object.shadow$provide.module$node_modules$react_markdown$index (ci.js:188088:300)
at Object.shadow.js.jsRequire (ci.js:116793:18)
at Object.shadow.js.require (ci.js:116818:20)
at ci.js:188249:56
Is there anything new I need to do in the new version? This only happens after I bump to the new version and delete the folder .shadow-cljsdeps.edn the only way to pull in a dependency from a git repository when using shadow-cljs at the moment? Or is there a way to specify git deps in shadow-cljs.edn?deps.edn only yes, shadow-cljs.edn doesn't support it currentlyresources directory + io/resource of clojure in cljs shadow world?resources is added to the classpath by lein conventions. It is equivalent to either just putting the files into on of the classpath dirs you already have or adding resources to said classpath. :source-paths ["src/main" "resources"] or just putting the files from resources into src/main if you have :source-paths ["src/main"]io/resource directly in CLJS. you can only do so in a macroExecution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3332).
:jvm-opts ["-Xmx512M"] or so to limit the memory or upgrade your JDK:npm-module
:npm-module because the tool I am trying to integrate with does not like the umd style exports which you get from :node-librarynode-repl is not enough? :npm-module works too but requires manual work. as in set :runtime :node in your build config and then from the JS that is consuming the compiled CLJS code somewhere you need to require("path-to-cljs/shadow.cljs.devtools.client.node")node-repl is generally simpler and usually enoughshadow-cljs.edn builds:
:preload {:target :node-script
:output-to "resources/preload.js"
:main electron-app.preload.core/main}
This is the error showing up in the devtools
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { #!/usr/bin/env node
^
SyntaxError: Invalid or unexpected token
at new Script (node:vm:100:7)
at createScript (node:vm:257:10)
at Object.runInThisContext (node:vm:305:10)
at wrapSafe (node:internal/modules/cjs/loader:1021:15)
at Module._compile (node:internal/modules/cjs/loader:1066:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1140:10)
at Module.load (node:internal/modules/cjs/loader:982:32)
at Module._load (node:internal/modules/cjs/loader:823:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Function.o._load (node:electron/js2c/renderer_init:29:379)contextBridge so there can potentially be a non trivial amount of code there:hashbang false in your build config to get rid of the #!/usr/bin/env node line.shadow-cljs directory on the build server? I think it could shave a couple minutes off our build time, but am worried about it making our builds unstable..shadow-cljs dir in CI envs yes function run via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run(shadow/release :build) there is identical to shadow release build from the CLIshadow-cljs release build test and then node wherever/your-test.js to run the testsclj-run part of the shadow docs. I'll experiment with that and combining the builds. Do some benchmarks. I suspect eliminating one jvm startup will have a big impact.shadow-cljs release build-a build-b is fine(defn release [] (shadow/release :app) (shadow/compile :test))Seems like an easy win so far. Shaved off another minute.
! variants to release! and compile!. otherwise errors are just printed without "failing" (ie. process exit code)! variants were for. Thanks again for the pro-tips^:dev/always
:watch-dir when using custom servers as described in the docs https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloadingrelease build will just load the shared file{:shared {:entries []}
:a {:entries [a.entry]
:depends-on #{:shared}}
:b {:entries [b.entry]
:depends-on #{:shared}}}
What could be the cause of this build error?
Module Entry "b.entry" was moved out of module ":b".
It was moved to ":shared" and used by #{:shared :b}.:shared or :a module directly requiring the b.entry ns. can't have that without either removing that require or making b depend on ab.entry apart from in modules configa -> c -> bapp.b.entry (that is not required anywhere) then requiring app.b in :shared will cause app.b.entry to be moved into the shared module? Does that mean that NS names hierarchy can impact how code splitting works?ns is not allowed, indirect and lazy is finea -> c -> b I meant a.entry requires something.c which requires b.entry thus forcing b.entry to be moved since its supposed to be in :b but can't:b would end up empty and pointlessshadow-cljs, and working with shadow-cljs through a custom build pipeline in our monorepo.
I'm getting an error when compiling, IOException: Cannot run program "node"
I am still doing some research to figure out exactly how the build is being called and help refine this question, but do you have any suggestions for how to interpret this error? It seems like shadow expects to find a node executable somewhere, but it isn't finding the executable. Does node need to be in the same directory?LISTEN 0 1000 *:9630 *:* LISTEN 0 50 [::ffff:127.0.0.1]:41491 *:* LISTEN 0 50 [::ffff:127.0.0.1]:46337 *:* LISTEN 0 50 [::ffff:127.0.0.1]:40289 *:* shadow-cljs - server version: 2.15.12 running at shadow-cljs - nREPL server started on port 46337
.shadow-cljs dir
$ ls -1 .shadow-cljs/ babel-worker builds cli-repl.port http.port jar-manifest nrepl.port server.pid server.token socket-repl.port
yarn remove shadow-cljs yarn add --devNotice should be at 24 now, not 4.
find / 2>/dev/null | grep shadowfind / -name shadow-cljs 2>/dev/null ends up being under /home/chris. I'm not even sure what a global install of shadow would look like. I'll do some research in the docs, that will hopefully include how to get rid of the global install. (As it seems like the concept exists!).yarn global remove shadow-cljs said it worked.$ ls -al /usr/bin/shadow-cljs lrwxrwxrwx 1 root root 45 Oct 15 22:43 /usr/bin/shadow-cljs -> ../lib/node_modules/shadow-cljs/cli/runner.js*
-name shadow-cljs is probably fine to go through the systemecho $PATH what do you have/home/chris/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/home/chris/.nvm/versions/node/v16.3.0/bin/
yarn shadow-cljs info returns the correct version:
=== Version jar: 2.11.24 cli: 2.11.24 deps: 1.3.2 config-version: 2.11.24
shadow-cljs.edn for all cljs only deps, to get rid of a dependency conflict (something Datomic needed, forget what). So I might convert to that way here too. Then perhaps I can get rid of the shadow-cljs mention in deps.edn? If so then that's another win for only using shadow-cljs.edn.shadow-cljs.edn can just be a text file for me.shadow-cljs.edn, that works fine but Cursive doesn't recognize dependencies in itshadow-cljs.edn till this gets answered: https://github.com/cursive-ide/cursive/issues/1804#issuecomment-314916994. Regardless the fix does seem a long way away.:js-options {:entry-keys ["module" "browser" "main"]} in your build config. otherwise the code doesn't seem to be rewritten properly due to a bug in GCCNo available JS runtime. SeeI also saw it working once though. What can go wrong? Cider also deosn't seem to connect my apps buffers with the repl
*nrepl-server xxx :localhost* buffer in emacs telling you the address of the development server to connect to in your browser for loading the js runtime.
You should see something like shadow-cljs - server version: 2.15.12 running at if you are running the browser-repl special build or shadow-cljs - HTTP server available at if you have declared a :dev-http server in shadow-cljs.edn.shadow-cljs - server version: 2.10.22 running atyea I opened this in the browser and now it works. Not sure if I also need to click compile there once? Either I was daft about it or the user guide could be more explicit about how to have the parts. (like with a warning > you should connect these 2 things or sth) shouldn't it say it here as well because I did the steps and then was stuck https://shadow-cljs.github.io/docs/UsersGuide.html#cider but yea thanks a lot 🙂 🎉
Visit in a browser? (y or n) message?:dev-http or the url when no :dev-http entry is configured in shadow-cljs.edn; If the user selects to run the browser-repl, then cider will also open, without prompting, in the default browser. Thus cider will make an effort to open the user code/browser-repl on the default browser hence loading the "js runtime".shadow-cljs - HTTP server available at shadow-cljs - server version: 2.15.8 running atBut the browsers won’t connect to ether saying
Safari can't open the page "" because Safari can't establish a secure connection to the server "discovery.local".And Chrome says:
This site can't provide a secure connectiondiscovery.local sent an invalid response. ERR_SSL_PROTOCOL_ERRORI suspect my problem may be how I’m setting up the certs and the keystore. I’ve tried a few different instructions and it all goes together without errors, but I don’t know how to confirm that the keystore or any of its inputs are actually correct. The link in the Shadow user guide for setting up the certs for the Mac is 404 https://certsimple.com/blog/localhost-ssl-fix My shadow-cljs.edn file:
{:deps true
:nrepl {:port 8777}
:ssl {:keystore "ssl/keystore.jks"
:password "super-secret}
:dev-http {8020 {:root "resources/public"
:host "discovery.local"}}
:http {:host "discovery.local"}
:builds {:app {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:app {:init-fn visx.dashboard.core/init}}
:js-options
{:resolve
{"@daily-co/daily-js"
{:target :npm
:require "@daily-co/daily-js/dist/daily-iframe-esm.js"}}}
:release {:output-dir "dist/js/compiled"
:compiler-options
{:infer-extern :auto
:closure-defines
{goog.debug.LOGGING_ENABLED true
re_frame.trace.trace_enabled? false
day8.re_frame.tracing.trace_enabled? false}}}}
:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}}}
I’m running shadow-cljs 2.15.8
Any suggestions on how to debug / make work, or some current known working guide to create certs and the keystore?:http {:host "discovery.local"} at all:dev-http {8020 "resources/public"} should be fine too?:host. so it might be binding to the wrong network adapter or so["firebase/compat/auth"] I’m getting the following error. According to https://firebase.google.com/docs/web/modular-upgrade#update_imports_to_v9_compat it should be a drop in replacement.{:source-paths ["src"]
:dependencies [[binaryage/devtools "0.9.10"]
[proto-repl "0.3.1"]
[reagent "0.8.0"]]
:nrepl {:port 3333}
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main
{:entries [giggin.core]}}
:js-options {:babel-preset-config {:targets {"chrome" "80"}}}
:devtools
{:after-load giggin.core/main
:http-root "public"
:http-port 3000}}}}
I had to figure this out as Firebase is part of the Learn Reagent coursebabel-preset-config documented anywhere? I can’t find it in the Shadow CLJS Guide:babel-preset-config is not documented since it is temporary and will be removed once I figure out how to remove babel completelyclojure.core.specs.alphabut am getting a runtime error ...Uncaught Error: Unable to resolve spec: :cljs.core.specs.alpha/defn-args
ls resources/public/js/cljs-runtime | grep core.specs cljs.core.specs.alpha.js cljs.core.specs.alpha.js.map
(:require-macros [cljs.core.specs.alpha]))
ClojureScript 1.10.879 cljs.user=> (require 'cljs.core.specs.alpha) nil
core.specs.alpha from the clojure side?.cljs file with these specs.cljs.core.specs.alpha=> (s/get-spec ::defn-args)
{:cljs.spec.alpha/op :cljs.spec.alpha/pcat,core.specs2.alpha :P:js-options {:entry-keys ["module" "browser" "main"]} in your build config. I haven't entirely figured out what causes this error(defn controlled-text-field []
(let [cursor-position (atom nil)]
(reagent/create-class
{:component-did-update (fn [this]
(let [dom-node (rdom/dom-node this)
input (aget (.getElementsByTagName dom-node "input") 0)]
(.setSelectionRange input @cursor-position @cursor-position)))
:reagent-render
(fn []
[:> TextField
{:label "controlled text field"
:type "text"
:fullWidth true
:size "small"
:value
(or
@(re-frame/subscribe [::subs/my-sub])
"")
:onChange
(fn [event]
(reset! cursor-position (-> event .-target .-selectionStart))
(re-frame/dispatch
[::events/update-value (-> event .-target .-value)])
)}])})))
-test prefix but the following configuration does not seem to work when running npx shadow-cljs compile test . The build completes without errors but zero tests are run. Do I need to setup a custom test runner for this?[cljs.test :refer :all] is not valid in CLJS so I suppose your compilation fails?[:test] Compiling ...
------ ERROR -------------------------------------------------------------------
File: /mnt/c/Users/thheller/code/tmp/cljs-test/test/cljs/cljs_test/some_test.cljs:1:1
--------------------------------------------------------------------------------
1 | (ns cljs-test.some-test
-------^------------------------------------------------------------------------
null
Invalid namespace declaration
-- Syntax error -------------------
(... ... (:require [cljs.test :refer :all]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:shadow.build.ns-form/ns-form:
(clojure.spec.alpha/cat
:ns
'#{clojure.core/ns}
:name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:meta
(clojure.spec.alpha/? clojure.core/map?)
:clauses
:shadow.build.ns-form/ns-clauses)
-------------------------
Detected 1 error
--------------------------------------------------------------------------------
2 | (:require [cljs.test :refer :all]))
3 |
4 | (deftest some-test
5 | (testing "that it is true"
--------------------------------------------------------------------------------
:error[cljs.test :refer-macros [deftest is testing]] but changing that to [cljs.test :refer [deftest is testing]] fixed the issue, thanks for the help!shadow-cljs watch also install new deps added to a deps.edn file?shadow-cljs touches deps.ednpackage.json did you mean? i would think so.watch, regardless of how the dependencies are managed. only on startupreact-select in a project of mine,and getting this error when trying to require "react-select/creatable"
FileNotFoundException: .shadow-cljs/builds/browser/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long)Any idea how to solve this?
:node-script option. I used it successfully, but in the mode that I had built things, the node script that was output still had some dependencies back into the build directory. Is that expected, or a characteristic somehow of the build that I specified? Do you know offhand?SHADOW-IMPORT-PATH sorts of things)compile vs release in this case.compile is only meant to run in the place where it is created. release you can move around. it'll still require access to the npm modules you used though:node-script output into it. copy that directory to wherever, run npm install then you can run your script just finepackage.json and npm install will install themExecution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.I have thheller/shadow-cljs in my deps.edn. The version in deps.edn and in yarn.lock is the same.
thheller/shadow-cljs {:mvn/version "2.15.12"}
Any ideas?{:deps {some/thing {:mvn/version "1.2.3
thheller/shadow-cljs {:mvn/version "4.5.6"}}}{:aliases
{
;; start a modern nREPL server on port 4000:
:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}}
:main-opts ["-m" "nrepl.cmdline"
"--bind" "0.0.0.0"
"--port" "4000"]
:jvm-opts ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5010"]}
:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.15.12"}
com.cognitect/transit-cljs {:mvn/version "0.8.256"}
reagent/reagent {:mvn/version "1.1.0"
:exclusions [cljsjs/react cljsjs/react-dom]}
secretary/secretary {:mvn/version "1.2.3"}
hiccups/hiccups {:mvn/version "0.3.0"
:exclusions [cljsjs/react cljsjs/react-dom]}
cljs-http/cljs-http {:mvn/version "0.1.45"}
bidi/bidi {:mvn/version "2.1.6"}
noencore/noencore {:mvn/version "0.3.4"}
medley/medley {:mvn/version "1.2.0"}
reagent-utils/reagent-utils {:mvn/version "0.3.4"
:exclusions [cljsjs/react cljsjs/react-dom]}
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
org.clojure/core.match {:mvn/version "0.3.0-alpha5"}
garden/garden {:mvn/version "1.3.6"}
alandipert/storage-atom {:mvn/version "2.0.1"}
frankiesardo/linked {:mvn/version "1.3.0"}
markdown-clj/markdown-clj {:mvn/version "1.0.7"}
;; [Devtools]()
;; adds custom formatters support for ClojureScript to
;; Chrome, so that ClojureScript data can be
;; comfortably inspected in the Chrome Dev Tools
;; Console. Shadow-CLJS automatically activates
;; cljs-devtools for every dev build, when it is on
;; the classpath, see:
binaryage/devtools {:mvn/version "0.9.10"}
cider/cider-nrepl {:mvn/version "0.26.0"}
}
:extra-paths ["src/cljs"]}
:pack {:extra-deps
{pack/pack.alpha
{:git/url ""
:sha "511c32d4238afb860ad0b16c4827322d80c7d615"
:exclusions [org.slf4j/slf4j-nop]}}
:main-opts
["-m"]}
}
:jvm-opts [
;; added to prevent exceptions with no stacktraces, see:
;;
"-XX:-OmitStackTraceInFastThrow"
]
:paths ["src/clj" "src/cljc" "src/cljs" "resources" "classes"]
:mvn/repos {"" {:url ""}
"central" {:url ""}
"clojars" {:url ""}}
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/core.cache {:mvn/version "1.0.217"}
org.clojure/core.memoize {:mvn/version "1.0.250"}
org.clojure/core.async {:mvn/version "1.3.622"}
org.clojure/core.match {:mvn/version "1.0.0"}
com.cognitect/transit-clj {:mvn/version "1.0.324"}
com.cognitect/anomalies {:mvn/version "0.1.12"}
nrepl/nrepl {:mvn/version "0.8.3"}
expound/expound {:mvn/version "0.8.10"}
ring/ring-core {:mvn/version "1.9.4"}
ring/ring-servlet {:mvn/version "1.9.4"}
ring/ring-ssl {:mvn/version "0.3.0"}
javax.servlet/servlet-api {:mvn/version "2.5"}
clj-time/clj-time {:mvn/version "0.15.2"}
org.clojure/tools.namespace {:mvn/version "1.1.0"}
medley/medley {:mvn/version "1.3.0"}
io.sentry/sentry-clj {:mvn/version "5.2.158"}
ring-middleware-format/ring-middleware-format {:mvn/version "0.7.4"}
ring-partial-content/ring-partial-content {:mvn/version "2.0.1"}
ring-cors/ring-cors {:mvn/version "0.1.13"}
bk/ring-gzip {:mvn/version "0.3.0"}
cheshire/cheshire {:mvn/version "5.10.1"}
org.shredzone.acme4j/acme4j-client {:mvn/version "2.12"}
org.shredzone.acme4j/acme4j-utils {:mvn/version "2.12"}
noencore/noencore {:mvn/version "0.3.6"}
environ/environ {:mvn/version "1.2.0"}
sv/blob-storage {:mvn/version "0.1.0"}
sv.blob-storage/file-blob-storage {:mvn/version "0.1.0"}
sv.blob-storage/gcloud-storage {:mvn/version "0.1.2"}
com.draines/postal {:mvn/version "2.0.4"}
hiccup/hiccup {:mvn/version "1.0.5"}
buddy/buddy-auth {:mvn/version "3.0.1"}
me.raynes/fs {:mvn/version "1.4.6"}
digest/digest {:mvn/version "1.4.10"}
markdown-clj/markdown-clj {:mvn/version "1.10.6"}
clj-http/clj-http {:mvn/version "3.12.3"}
sv/system.core {:mvn/version "0.1.1"}
sv/system.datomic {:mvn/version "0.1.0"
:exclusions [org.slf4j/log4j-over-slf4j
com.datomic/datomic-free]}
sv/system.main {:mvn/version "0.1.0"}
sv/system.httpkit {:mvn/version "0.1.0"}
;; it is important to use a recent version of
;; http-kit since the older version 2.1.18 caused a
;; downtime of the leader server due to this issue:
;;
http-kit/http-kit {:mvn/version "2.5.3"}
sv/system.ring {:mvn/version "0.1.0"}
;; logging:
com.taoensso/timbre {:mvn/version "5.1.2"}
sv/timbre.gcloud.logging {:mvn/version "0.1.4"}
com.fzakaria/slf4j-timbre {:mvn/version "0.3.21"}
org.slf4j/log4j-over-slf4j {:mvn/version "1.7.32"}
org.slf4j/jul-to-slf4j {:mvn/version "1.7.32"}
org.slf4j/jcl-over-slf4j {:mvn/version "1.7.32"}
;; using a newer version here, since it has a
;; better `DefaultCredentialProvider` that also
;; resolve the application-default-credentials inside
;; a docker container via Google Cloud's metadata
;; service ``
com.google.api-client/google-api-client {:mvn/version "1.32.2"}
sv/gcloud.client {:mvn/version "0.1.4"}
com.google.guava/guava {:mvn/version "27.0.1-jre"}
com.google.cloud/google-cloud-storage {:mvn/version "2.1.9"}
etaoin/etaoin {:mvn/version "0.4.6"}
clj-chrome-devtools/clj-chrome-devtools {:mvn/version "20200423"}
com.datomic/datomic-pro {:mvn/version "0.9.5561"
:exclusions [org.slf4j/log4j-over-slf4j
org.slf4j/slf4j-nop]}
;; Datomic production storage backend:
mysql/mysql-connector-java {:mvn/version "8.0.27"}
;; for the development environment:
org.postgresql/postgresql {:mvn/version "42.3.0"}
com.google.cloud.sql/mysql-socket-factory {:mvn/version "1.3.4"}
;; For to verify webhook requests:
com.xk72/paddle-webhook-verifier {:mvn/version "1.0"}
io.grpc/grpc-core {:mvn/version "1.41.0"}
org.clojure/data.csv {:mvn/version "1.0.0"}
com.datomic/client-pro {:mvn/version "1.0.72"}
com.datomic/client-cloud {:mvn/version "1.0.117"}
danlentz/clj-uuid {:mvn/version "0.1.9"}
fipp/fipp {:mvn/version "0.6.24"}
borkdude/sci {:mvn/version "0.2.7"}
diehard/diehard {:mvn/version "0.10.4"}
sv/basis {:local/root "basis"}
sv/message-emit {:git/url ""
:sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
:deps/root "message-emit"}
sv/message-logging {:git/url ""
:sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
:deps/root "message-logging"}
sv/memcached-auto-discovery {:git/url ""
:sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
:deps/root "memcached-auto-discovery"}
sv/registry {:git/url ""
:sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
:deps/root "registry"}
sv/peer-sci {:git/url ""
:sha "590932368d57d09fb475b946b5214996a9abb23f"
:exclusions [sv/slf4j-gke-logging]}
}
}
:cljs :extra-deps:cljs aliasyarn releaseyarn install --frozen-lockfile && yarn gulp && yarn shadow-cljs release client --source-maps && yarn build-tailwind
yarn shadow-cljs release client --source-mapsshadow-cljs.edn do you have :deps {:aliases [:cljs]}?:deps {:aliases [:cljs]}
yarn shadow-cljs release clientyarn shadow-cljs clj-replclj -A:cljs -M -m shadow.cljs.devtools.cli clj-repl?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b7d3d2c1f7d5c2dedbd39a87"}, :content ("[email protected]")}
clj -Sforce
This might happen if you remove $HOME/.m2shadow-cljs - failed to load module$node_modules$firebase$compat$auth$dist$index_esmThere is a file
node_modules/firebase/compat/auth/dist/index.esm.js and we’re not seeing any errors pointing in that direction in the server logs.TypeError: (0 , _app._registerComponent) is not a function
at eval (index-f41a0691.js:11897)
at Object.shadow$provide.module$node_modules$$firebase$auth$dist$esm2017$index_f41a0691 (index-f41a0691.js:12019)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$firebase$auth$dist$esm2017$internal (internal.js:556)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$$firebase$auth_compat$dist$index_esm2017 (index.esm2017.js:6)
at shadow.js.jsRequire (js.js:66)
at Object.shadow$provide.module$node_modules$firebase$compat$auth$dist$index_esm (index.esm.js:4)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
This is the error that follows the warning above:babel-preset-config {:targets {"chrome" "80"}})(0, whatever) trick:js-options {:entry-keys ["module" "browser" "main"]} in your build config can fix it"main" correspond to a module/entrypoint in our build or is this to be used as-is?package.json shadow-cljs uses when using npm packages(0, whatever). Why does typescript do that, what's the trick?this thing 😄watch in which case it shouldn't matter much since its incremental and only recompiles what changes?watch is only hot-reloads the files that changes anyways so that is entirely different thing that is also much fasteripcRenderer but, based on the electron docs themselves, I don’t understand why.,ipcRenderer through electron in the renderer process. You have to access it in a “preload script” which you can access when you start the browser window.
I just created a resources/preload.js file and added ipcRenderer to the window object.
https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts:target for this. too busy currently to figure it out thoughErrors encountered while trying to parse file
node_modules/react-native/index.js
{:line 14, :column 7, :message "cannot use keyword 'typeof' here."}
I do not quite understand what shadow-cljs target :react-native is doing, then what expo does to make it's working on the web, so it's hard for me to understand what I'm doing wrong. Did someone have a similar setup? Or maybe there are examples / blog posts about shadow-cljs/RN/web?
Thank you:browser build["vega-embed" :as vegaEmbed] as with here: https://github.com/djblue/portal/blob/master/src/portal/ui/viewer/vega.cljs#L3
I get this error after adding the require and building:
failed to resolve: ./iterator.js from prj/node_modules/vega-embed/build/vega-embed.js
{:require-from #object[java.io.File 0x28b055c "prj/node_modules/vega-embed/build/vega-embed.js"], :require "./iterator.js"}
ExceptionInfo: failed to resolve: ./iterator.js from prj/node_modules/vega-embed/build/vega-embed.js
shadow.build.npm/find-file (npm.clj:464)
shadow.build.npm/find-file (npm.clj:405)
shadow.build.npm/find-resource (npm.clj:737)
shadow.build.npm/find-resource (npm.clj:730)
shadow.build.resolve/find-npm-resource (resolve.clj:122)
shadow.build.resolve/find-npm-resource (resolve.clj:93)
shadow.build.resolve/eval18692/fn--18695 (resolve.clj:262)
clojure.lang.MultiFn.invoke (MultiFn.java:244)
shadow.build.resolve/find-resource-for-string (resolve.clj:80)
shadow.build.resolve/find-resource-for-string (resolve.clj:69)
shadow.build.resolve/resolve-string-require (resolve.clj:452)
shadow.build.resolve/resolve-string-require (resolve.clj:435)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-require (resolve.clj:665)
shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:477)
shadow.build.resolve/resolve-string-require (resolve.clj:435)
shadow.build.resolve/resolve-require (resolve.clj:672)
shadow.build.resolve/resolve-require (resolve.clj:665)
shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:659)
shadow.build.resolve/resolve-symbol-require (resolve.clj:618)
shadow.build.resolve/resolve-require (resolve.clj:669)
shadow.build.resolve/resolve-require (resolve.clj:665)
shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:659)
shadow.build.resolve/resolve-symbol-require (resolve.clj:618)
shadow.build.resolve/resolve-require (resolve.clj:669)
shadow.build.resolve/resolve-require (resolve.clj:665)
shadow.build.resolve/resolve-entry (resolve.clj:679)
shadow.build.resolve/resolve-entry (resolve.clj:678)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-entries (resolve.clj:693)
shadow.build.resolve/resolve-entries (resolve.clj:684)
shadow.build.modules/resolve-module/fn--19935 (modules.clj:252)
shadow.build.modules/resolve-module (modules.clj:248)
shadow.build.modules/resolve-module (modules.clj:238)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.build.modules/resolve-modules (modules.clj:258)
shadow.build.modules/resolve-modules (modules.clj:257)
shadow.build.modules/analyze (modules.clj:312)
shadow.build.modules/analyze (modules.clj:303)
shadow.build/resolve (build.clj:428)
shadow.build/resolve (build.clj:422)
shadow.build/compile (build.clj:460)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/eval21696/fn--21699 (impl.clj:457)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--21444/fn--21445/fn--21453 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--21444/fn--21445 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--21444 (util.clj:241)
Any idea what I'm doing wrong? I've deleted node_modules/ and reinstalled deps but it didn't help.module.exports = function() {}; should be enoughvar scripts$1 = {
prebuild: "yarn clean && yarn build:style",
build: "rollup -c",
"build:style": "./build-style.sh",
clean: "del-cli build build-es5 src/style.ts",
prepublishOnly: "yarn clean && yarn build",
preversion: "yarn lint && yarn test",
serve: "browser-sync start --directory -s -f build *.html",
start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
pretest: "yarn build:style",
test: "beemo jest --stdio stream",
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
prepare: "beemo create-config",
prettierbase: "beemo prettier '*.{css,scss,html}'",
eslintbase: "beemo eslint .",
format: "yarn eslintbase --fix && yarn prettierbase --write",
lint: "yarn eslintbase && yarn prettierbase --check",
release: "auto shipit"
};"vega-embed": "6.19.1", in your package.json if you don't really need anything in the newest release.
@U05224H0W and @U8ZQ1J1RR thanks for looking into this. Not the greatest start with vega, but it was recommended as a good starting point for charting, so I'm going to stick with it a while and see if issues like this are frequent.iterator.js file with the contents module.exports = function() {};. https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries might be helpful../iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js/home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/iterator.js but couldn't since it does not existnpm install just before everything should already be ready and shadow-cljs won't install anything:js-options {:entry-keys ["module" "browser" "main"]} in the build target.:browser and one :npm-module. For some reason automatic externs inferring isn’t working in :npm-module (and adding a line like :compiler-options :externs ["externs.js"] doesn’t help either) and so I get warnings for the :npm-module target that don’t show up in the :browser target. The warnings seem to be coming from using imported Node modules (so they necessarily must be JS functions)
Is there something that needs to be done additionally to get externs inferring to work for :npm-module?:browser shadow-cljs processes all JS and can infer a bunch of externs from that. for :npm-module that is not done since something else will provide the JS dependencies so you probably need a few more typehints^js?:npm-module target. I assume it’s because, as you mention, the :browser target processes the JS code while the :npm-module target doesn’t:browser compilation target) since the automatic externs inferring works in that case so it’s not a solution we would prefer to use if possible:target :npm-module target, if you use a JS function in a binding, and then later use that result in an anonymous function, it doesn’t seem to keep track of it even with a type hint and you’re forced to add a type hint in the anon function. https://github.com/jo-sm/shadow-externs-repro if you want to take a look, I tried to describe it as clearly as I can and am open to any ideas you haveobjects is a JS value as hinted (so probably an array) but you are map'ing over it and it does not automatically imply that each item in that array is also a JS value:target :browser mode (even with externs inferring fully disabled), and it doesn’t get fixed with type hints as I understand them from the official reference. So I feel like something isn’t working as expected :compiler-options {:warnings {:infer-warning false}} but I am also struggling to get that to work for :npm-module :advanced release builds. still might catch issues in your main build:advanced aside, is it possible to disable warnings for :npm-module?:js-options {:generate-externs false} in your :browser build config:npm-module:compiler-options {:infer-externs false} should turn off warnings(set! *warn-on-infer* false) in a file after the ns or so to turn off all warnings in that file only^js would take:infer-externs false does indeed fix it. Does it work differently than just disabling the warning (or does disabling the warning not work as I expect, which is that it won’t output it if it encounters it)?:warnings {:infer-warning false} ) wasn’tyarn shadow-cljs server is supposed to open a process that runs forever, until Cntl C out of it. But this morning, after an (attempted) OS upgrade, this is what I'm getting:
[The process terminates! Same with
yarn shadow-cljs watch. Actually yarn shadow-cljs server works fine for another project, with these two lines popping up after the config line:
shadow-cljs - HTTP server available at shadow-cljs - server version: 2.15.12 running at, and the process lasting forever as expected. There are no recently written log files to help diagnose, not in in the project root directory anyway.
.shadow-cljs directory that must have become corrupted. Doubt it had anything to do with the OS upgrade.shadow-cljs - connected to server is the hint. the server was already running.shadow-cljs you now likely have a zombie process thats no longer accessible. make sure to kill it manually.ps -aux | grep shadow-cljs | less . Thanks.user.cljs and hot reloading worked fine for me. Also, I tend to run shadow-cljs watch [buildname] then connect to the repl that it runs.user.cljs can't do (shadow/repl :app)?cljs/user.cljs on the classpath which the REPL include include automatically(shadow/repl :app) so your intention of what this should be doing is unclearOutOfMemoryError using shadow-cljs? I recently started encountering this, using shadow for our frontend build.[2021-11-04 11:03:49.953 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}} OutOfMemoryError unable to create new native thread:jvm-opts ["-Xmx512M"] in shadow-cljs.edn but that can still OOM if your system is not able to provide 512mb of ram when neededTypeError: (0 , _app._registerComponent) is not a function like errors please try shadow-cljs 2.15.132.16.3 just now and am still seeing TypeError: (0 , _app._registerComponent) is not a function
It does seem like the upgrade itself worked though as evident by some warnings related to use of unrequired namespacesgoog.object (or a macro that generates that) it'll break nowgoog.object must have a require for it, which in case of macros most likely won't be the caseTypeError: (0 , _app._registerComponent) is not a function type errors2.16.3 just now and am still seeing TypeError: (0 , _app._registerComponent) is not a function
It does seem like the upgrade itself worked though as evident by some warnings related to use of unrequired namespaces:release {:output-dir "foo"}index.js instead of src/foobar/main.cljs , can I configure shadow to use this and bypass CLJS completely?:entries [some.cljs.ns] just use :entries ["/some/files.js"]:target :esm sort of doesn't support it though since there is no way to express the exports without namespaced vars 😛:advanced should take care of removing cljs.core and such{:deps {:aliases [:dev :demo]}
:dev-http {8002 "public"
8001 "public/test"}
:nrepl {:port 9000}
:builds {:highlighter
{:compiler-options {:output-feature-set :es8}
:target :browser
:output-dir "public"
:modules {:clojure_highlighter {:init-fn clojure-highlighter.main/render}}
:build-hooks [(shadow.cljs.build-report/hook
{:output-to "report.html"})]}}}:init-fn and add :entries ["/that/file.js"]:entries ["clojure_highlighter/main.js"] :entries ["src/..."] :entries ["clojure-highlighter/main.js]but for all of them I get:
The required JS dependency "clojure_highlighter/main.js" is not available.
$ ls src/clojure_highlighter/main.js src/clojure_highlighter/main.js
:entries ["/clojure_highlighter/main.js][:highlighter] Compiling ... Wrote build report to: /Users/borkdude/Dropbox/dev/blog/report.html [:highlighter] Build completed. (16 files, 0 compiled, 0 warnings, 2,42s)0 compiled ;)
:advanced for npm packages?$ node_modules/.bin/rollup src/clojure_highlighter/main.js -f iife -o public/js/editor.bundle.js -p @rollup/plugin-node-resolve src/clojure_highlighter/main.js → public/js/editor.bundle.js... created public/js/editor.bundle.js in 1.1s $ ls -la public/js/editor.bundle.js -rw-r--r-- 1 borkdude staff 603547 Nov 6 11:06 public/js/editor.bundle.js
(+ 2 2) and get ((2) + (2));?clojure -A:cljs -M -m cljs.main -re node -r
ClojureScript 1.10.773
cljs.user=> (set! *print-fn-bodies* true)
true
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> foo
#object[cljs$user$foo "function cljs$user$foo(x){
return (x + (1));
}"]
cljs.user=>cljs.user=> (str (fn [] (+ 1 2 3)))
"function (){\nreturn (((1) + (2)) + (3));\n}"<script> element in HTML.set-cookie headers in a :dev-http server? not against adding that change just curious how you even get there?1.10.879 to match what I think shadow-cljs 2.15.12 wants but I'm still getting user-error: The shadow-cljs ClojureScript REPL is not available. When I look at *nrepl-messages* I see this:
(--> id "8" op "eval" session "844724f8-aa75-4953-bd4e-6ed230a647bf" time-stamp "2021-11-08 20:48:50.415368000" code "(require 'shadow.cljs.devtools.api)" ) ... (<-- id "8" session "844724f8-aa75-4953-bd4e-6ed230a647bf" time-stamp "2021-11-08 20:48:51.723743000" err "Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2). Could not initialize class com.google.javascript.jscomp.DiagnosticGroups " ) ...Does that error mean anything to anyone? Any idea where to look next?
yarn shadow-cljs cljs-repl :main to evaluate code once I had yarn shadow-cljs watch :main running somewhere else and my browser loaded. That sounds to me like the problem is firmly on the #cider side of things. Thanks for the thoughts here and for the excellent REPL troubleshooting documentation--that cleared some stuff up for me.:output-feature-set :es8 active. But in release mode, I get the error described in the issue. I’m assuming I shouldn’t use that compiler option in release mode. Does anyone have a solution/work-around?:release {:compiler-options {:output-feature-set :es5}}
This fixes the issue for us.shadow-cljs release just wipe the .shadow-cljs/builds/<your-build-id>/release dir and try again:output-feature-set will cause a cache wipe anyways.shadow-cljs folder unfortunately doesn’t fix it. And I do think it’s the same issue, because it’s also for me the Col element in react-bootstrap (now version 2.0.0, no longer rc). I just now updated shadow-cljs to 1.16.2. The steps that I’m doing:
• rm -rf .shadow-cljs node_modules
• npm i
• npx shadow-cljs -A:my-client server
• npx shadow-cljs -A:my-client release :my-client
I then request my HTML page through the dev server and I get TypeError: $jscomp.makeIterator is not a function in the JS console. Leaving out the Col element makes the error disappear. I can try to make a small reproduction project if that helps.$jscomp.makeIterator) to be available. normally when it does such replacements it also ensures that the polyfills will be injected itself. somehow something in the Col file however only causes the rewrite without ensuring its actually presentCol and that worked just finedeps.edn or only package.json?Col must be inside a Row and/or Container; just the Col may not trigger that code path.
https://github.com/svdo/shadow-cljs-9482.16.4 if you add :js-options {:force-library-injection #{"es6/util/makeiterator"}} to your build configshadow-cljs browser-repl since for that it has all the info. for the other stuff you might need to add a config option for it to work.shadow-cljs clj-repl,
Syntax error (UnsatisfiedLinkError) compiling at (/private/var/folders/xw/0lq56zhn4hb4lknppw_k086c0000gn/T/form-init9980842284905073960.clj:1:125).
:lein true is set…shadow-cljs info output too:lein true in your shadow-cljs.edn that your project.clj determines the shadow-cljs version, not the npm package.npx shadow-cljs -d cider/cider-nrepl:0.26.0 watch :app
This is the same for me.
In the video, JS dependencies are installed.
For me, they’re not installed.
Did he skip a step? I’m looking through the shadow-cljs docs and I can’t see a command that is meant to install dependencies.
I could install them myself but I guess I’m just curious why it didn’t work the same way for me. 🙂
npx shadow-cljs -d cider/cider-nrepl:0.26.0 watch :app npx: installed 97 in 6.588s shadow-cljs - config: /Users/nathankramer/Projects/nathanKramer/reframe-example/shadow-cljs.edn shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.16.2 running at shadow-cljs - nREPL server started on port 8777 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build failure: The required namespace "react" is not available, it was required by "day8/re_frame_10x/inlined_deps/reagent/v1v0v0/reagent/core.cljs".
npm install will install your JS dependencies assuming you have a package.jsonshadow-cljs? 🙂package.json being therepackage.json, and it has react etc in it. Curious!npm install to get it:reader-features the values of :target ?shadow.cljs.devtools.api/release from this build script as well. It does work fine for a browser build, the issue is when compiling the cljs tests (`:node-test` target) - because tools.build places the entire project directory on the classpath the test discovery finds a file in the test directory and then expects the namespace to start with test/ :
:cause "Resource does not have expected namespace",
:data
{:tag :shadow.build.resolve/unexpected-ns,
:resource
"test/my-app/components/events_test.cljs",
:expected-ns
test.my-app.components.events-test,
:actual-ns my-app.components.events-test}}}
I think the browser build works because the entry namespace is provided and discovered on the classpath in the correct spot. So I'm wondering if there are any creative solutions to this problem. The context is running a build in continuous integration where starting two JVM processes slows things down quite a bit.:ns-regexp to something like "^my-app\..*-test$", that should filter them out just by name?test 😛goog.object in any way its most likely this https://clojurescript.org/news/2021-11-04-release. can easily happen if the macro emits direct calls to anything goog.objectvar G__83387 = com.fulcrologic.rad.rendering.semantic_ui.report.goog$module$goog$object.get(props__55942__auto__,"fulcro$value");
var G__83387 = com.fulcrologic.rad.rendering.semantic_ui.report.goog$module$goog$object.get(props__55942__auto__,"fulcro$value");This is reproducible using this branch of the new fulcro-rad-template: https://github.com/fulcrologic/fulcro-rad-template/tree/latest-cljs Compile the
main target and look at the js file com.fulcrologic.rad.rendering.semantic_ui.form.js or com.fulcrologic.rad.rendering.semantic_ui.report.js. They both have the problem.
But I tried upgrading the compiler on Fulcro itself and running the simlple todomvc that exists in that project, and when used as cljs the macro seemed to work ok (in all cases the defsc macro from components is the one that is behaving strangely).:global-goog-object&array compiler options to work around the issue but I guess we have to make this transition at some point so best to get it over withunchecked-get and unchecked-set instead of goog.object/get&setmain.js:1 Uncaught SyntaxError: Identifier 'Ca' has already been declared--config-merge EDN:$ shadow-cljs --help
...
--config-merge DATA merges additional EDN data into the build configdiff --git a/package.json b/package.json
index c689932..3425558 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,6 @@
"uuid": "8.3.2"
},
"devDependencies": {
- "shadow-cljs": "2.15.12"
+ "shadow-cljs": "2.15.13"
}
}
diff --git a/project.clj b/project.clj
index 3bd6378..1877575 100644
--- a/project.clj
+++ b/project.clj
@@ -8,13 +8,13 @@
:username [:gpg :env/gitlab_token_type]
:password [:gpg :env/gitlab_token_value]}]]
:dependencies [[org.clojure/clojure "1.10.3"]
- [org.clojure/clojurescript "1.10.879"
+ [org.clojure/clojurescript "1.10.891"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[org.clojure/core.async "1.3.622"]
[org.clojure/test.check "1.1.0"]
- [thheller/shadow-cljs "2.15.12"]
+ [thheller/shadow-cljs "2.15.13"]
[reagent "1.1.0"]
[re-frame "1.2.0"]
[kee-frame "1.3.1"]goog.object also has a require for it. if some macro generates code accessing goog.object those need to be rewritten not to:compiler-options {:global-goog-object&array true})[:js-options :js-package-dirs to tell shadow about an npm module that a sub project (a :local/root deps.edn dependency) needs. Do I risk to be using the wrong version of some subdependency that my main project and the subproject both bring in?:npm-deps and manage them in the main project as wellnode_modules. it does not care how it got there:npm-deps now. I notice that it just works with yarn. Is this something shadow-cljs does or is it the clojurescript compiler that does it? I wonder if I need to somehow make sure it is my yarn.lock file that is updated…yarn add <npm-dep>@<version> for declared :npm-deps if they are not already in package.json if a yarn.lock file is foundnpm install/api/graph endpoint in shadow’s server code, but couldn’t figure out if it’s something that actually works/api/graph is for EQL graph queries but its not used much. what specifically are you looking for and at which point? you could easily extract it from the build state via a build hook for example:compile-start and everything after has all the info:build-sources vector. those are resource-ids sorted in dependency order:sources map:provides set or namespace symbols and a :deps vector:provides is a set since closure lib sources can provide multiple things per file#{that.ns}:build-hooks [(shadow.build/tap-hook)]in your build config
tap> the build state on :flush so you can inspect it via the UI(or (doto x tap>) y)(:require ["goog.object" :as goog.object]) ?edit: it appears to be simply
(:require [goog.object])
(:require [goog.object :as gobj]) as you should always be using aliases IMHO 😛TypeError: Cannot read properties of undefined (reading 'Level')
at eval (logging.cljc:12)
at eval (<anonymous>)
at Object.goog.globalEval (pnx-web.js:488)
at Object.env.evalLoad (pnx-web.js:1563)
goog.object one but an older onegoog.log.Level or soTypeError: (0 , _app._registerComponent) is not a function errors when trying to use Firebase SDK v9 with shadow-cljs 2.16.3 . I think the new cljs compiler was meant to fix some of these issues but we haven’t been able to get things working.(0, thing) related issues others had. this is not happening in code generated by CLJS, so it'll be guaranteed to be something badly rewritten by :simple in some npm codelein new reframe appname +10x. Then I installed mui5(CSS framework) https://mui.com/getting-started/installation/
2. Then I just modified views.cljs like below
(ns demo.views
(:require
["@mui/material/styles" :refer [ThemeProvider, StyledEngineProvider]]
["@sphere/component-library" :refer [themeV2]]
["@sphere/component-library/build/components/v3/Dummy/Dummy" :default Dummy]
["@mui/material/Button" :default Button]
["@mui/material/CssBaseline" :default CssBaseline]))
(defn test-component []
[:<>
[:> Button {:variant "contained"} "MUI Button"]
[:> Dummy]])
(defn main-panel []
[:> StyledEngineProvider {:injectFirst true}
[:> ThemeProvider {:theme themeV2}
[:> CssBaseline]
[test-component]]])
Note: Here ["@sphere/component-library/build/components/v3/Dummy/Dummy" :default Dummy] is a UI library written in JS react and https://mui.com/getting-started/installation/ only used there
I am getting below error in screenshots:create-react-app it works fine without any problem. Here is the code in screenshot::ns-regexp with :target :esm? :js-options :js-provider for the :npm-module target? I tried to but it didn’t seem to work and I’d like to be able to set it to :import so that it uses import("./some-file") rather than require(…):npm-module only outputs commonjs so it cannot use import(shadow.cljs.devtools.api/watch
{:build-id :test
:target :browser-test
:test-dir "target/public/js/test"
:devtools {:http-port 8021
:http-root "target/public/js/test"}}
{:verbose false})
the watch appears to start normally, but there is no browser-test server started. is there something else I need to do when using the api to make this work?get-server-configs var in that ns.
I think I can get by with just dev servers passed at top level, so if it used the server config passed in to start the shadow server, rather than reading from the file, that would work in that case at least:devtools config is deprecated. I just still allow it to not break old templates and suchwatch that I posted an example of.
this is because we have many builds across many projects and so benefit from sharing boilerplate via code.
we could write out shadow-cljs.edn files and then invoke api calls with build ids and so on but since I can pass in config directly to the functions that seems preferable.
the pr still means changes from shadow-cljs.edn are picked up as it is changed - everything still works. it just also means the config from the initial call to start the main server (whether passed as arg or got from shadow file) is used to start dev servers:dev-http is nothing but a simple static webserver. when you start your "main server" I assume that already has a webserver? why not use that?main server , I mean the shadow one, which has the dashboard ui. yes if I could get that to serve some resources of my choosing, that would work/ ofcshadow-cljs.edn) tend to use their own servers?shadow.cljs.devtools.server/start! to make it through to the dev-http stuff. that's what the pr achieves, while keeping the watch on shadow-cljs.edn workingshadow-cljs to automatically run tests when files are modified?
It looks possible when the target is node , but I couldn't find anything for when the target is karma or the browser.:browser-test you just open the browser and tests run automatically. for karma you run karma, no idea howshadow-cljs isn't working anymore to compile new the modified cljs files, right? (Following this https://shadow-cljs.github.io/docs/UsersGuide.html#_the_build)watch running?shadow-cljs compile ci # compile the tests from CLJS to JS npx karma start --single-runthis happens anytime a push to a branch occurs
shadow-cljs watch ci and then tell karma to watch for file changes.Resource: node_modules/<file> String continuations are not recommended. SeeThis SO answer seems to suggest I can disable warnings for this one file with
--hide_warnings_for=node_modules/somelibrary, but I’m not quite sure how to provide this argument in my shadow-cljs.edn ?
https://stackoverflow.com/questions/47668995/google-closure-suppress-warning-messages-for-a-particular-file@suppress annotation but they don’t seem to allow you to suppress the string continuation warning:log {:level :debug}?2.16.6 you can set :js-options {:hide-warnings-for #{"node_modules/ndarray/ndarray.js"}} in your build config to hide those warningserrors in file: .../node_modules/lower-case/dist/index.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/lower-case/dist/index.js", :js-requires [], :js-errors [{:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: .../node_modules/lower-case/dist/index.js
for the npm library lower-case. The offending line looks like
İ: "\u0069",anyone faced anything similar?
(TokenStream/isJSIdentifier "İ") returns truelein deps :why com.google.guava/guava Then, when doing a shadow build, the build fails as the closure compiler (i think!) tries to use the old version of guava (calling a method that doesn’t exist in guava 16.0.1):
Exception in thread "main" Syntax error macroexpanding at (closure.clj:77:5). at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1742) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705) at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457) at clojure.lang.Compiler.eval(Compiler.java:7186) at clojure.lang.Compiler.load(Compiler.java:7640) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6856.invoke(core.clj:6115) at clojure.core$load.invokeStatic(core.clj:6114) at clojure.core$load.doInvoke(core.clj:6098) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5897) at clojure.core$load_one.invoke(core.clj:5892) at clojure.core$load_lib$fn__6796.invoke(core.clj:5937) at clojure.core$load_lib.invokeStatic(core.clj:5936) at clojure.core$load_lib.doInvoke(core.clj:5917) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:5974) at clojure.core$load_libs.doInvoke(core.clj:5958) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:5996) at clojure.core$require.doInvoke(core.clj:5996) at clojure.lang.RestFn.invoke(RestFn.java:551) at shadow.build.js_support$eval10779$loading__6737__auto____10780.invoke(js_support.clj:1) at shadow.build.js_support$eval10779.invokeStatic(js_support.clj:1) at shadow.build.js_support$eval10779.invoke(js_support.clj:1) ... Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector; at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:257) at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:147) at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:48) at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:139) at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:408) at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:182) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167) at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1735)One confirmed way around this is to set a new version of guava as a top level dependency in our app so it’s picked up in the dependency tree. This works, however, we’d then need to keep manually ensuring that the guava version we specify is compatible with whatever version of the closure-compiler that shadow uses. It’s doable, but it seems like there may be a better solution. Any ideas?
lein deps :tree now shows zero dependencies under closure-compiler-unshaded. However, the closure compiler code can and will still conflict with other dependencies in your project. Just as we saw by pulling in guava 16.a > b > c, with a macro defined by b. So far hot reloading a seems to work though changing a does not seem to reload transitive dependency c (which seems odd, but maybe there's some optimized decisions or something). However, if I introduce an additional dependency between c and a , changing a reloads c before b, which is confusing to me: c relies on the macro in b, and results in an undefined var warning. Are my expectations about what gets reloaded and when, off? Let me know if it would help to post a simplified version the actual requires.(ns p.a) (defn f [])
(ns p.b) ; .clj (defmacro macro [] '(p.a/f))
(ns p.b ; .cljs (:require [p.a]) (:require-macros [p.b]))
(ns p.c
(:require [p.a] ; <-- this line causes p.c to be compiled before p.b
[p.b]))
(p.b/macro)p.c to be compiled at all when p.a is changed. without that it won'tp.c using p.b without requiring itp.a and p.b, and so p.b is not actually being reloaded in either case.p.c is indeed requiring p.b&env to determine if a particular symbol is a bound local1:49:52 PM cljs.1 | -> Compile CLJS: a.cljs 1:49:52 PM cljs.1 | -> Compile CLJS: c.cljs 1:49:52 PM cljs.1 | <- Compile CLJS: c.cljs ... 1:49:52 PM cljs.1 | <- Compile CLJS: a.cljsiWhere
c depends transitively on a. Does it mean these compilation steps are an asynchronous process? Are there any concurrency concerns here that might produce an undefined var error?:compiler-options {:parallel-build false} in your build configimport ... instead of require ... in the resulting JS?
The reason for that is that I have to interface with some libs that only use import in node.js, and I would like to not have to use an external bundler (to not loose the power of the REPL for development, for example):target :esm does that, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116deps.cljs files just need to be on the classpath, it doesn't matter whether thats in a jar or just a directory. combining them when building a jar is something you need to do as a jar can only contain onethe required dependency "process" is not available There is no declared dependency on process but I can see in the code there is if (typeof process !== 'undefined' so it's basically doing a polyfill. I can see why shadow has flagged it, but is there any opt to get shadow to let this kind of thing through?shadow-cljs npm package installed in the project. which means you are also missing the polyfills that provides. basically just npm install shadow-cljsshadow-cljs to your deps.cljs file?package.json as well as you MUST keep your package-lock.json in version control. not doing this is NOT an option in the JS world, unless you like pain of coursedeps.cljs then put node-libs-browser there, not shadow-cljsshadow-cljs.edn, which is what I’m going for.:source-paths ["src" "test"], but when I run the tests via npx shadow-cljs compile ci && npm run karma (using setup in https://shadow-cljs.github.io/docs/UsersGuide.html#_the_build) it says 0 tests are found. If I move my test file to the “src” folder and I run the command the tests are found. Is there a way to have a separate test folder from where tests are picked up?-testnpx shadow-cljs compile ci && npm run karma:infer-externs to :auto , which will trigger the compiler to warn about possible extern issues. However, in the compiler options section of the docs, it says that infer-externs defaults to true, which also seems to generate warning about possible extern issues. What’s the difference between :auto and true?:auto maybe does something extra to generate the appropriate externs (given a simple ^js typehint), and true does not. However, I can’t quite tell from the docs if this is a correct assumption.:auto is the default nowadays. The difference is that normally you need to (set! *warn-on-infer* true) in your files to enable the warnings. the externs inference is done regardless but you need to opt-in to get the warnings about it. :auto just sets that to true by default for your files (ie. not files from .jar files)deps.edn. (It’s a shadow cljs project).
This is my deps.edn (
{:paths ["src" "test"]
:deps
{...omitted dependencies...
thheller/shadow-cljs {:mvn/version "2.8.58"}
;; TODO: separate dev dependencies
tortue/spy {:mvn/version "2.9.0"}
;; Requires xmlhttprequest from NPM
cljs-ajax {:mvn/version "0.7.5"}}}
When I run yarn shadow-cljs watch :dev , I get the following error.
Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1). com.google.javascript.jscomp.AnonymousFunctionNamingPolicy Full report at: /var/folders/nd/8wtw0fvj50g96ch7b_tphgym0000gn/T/clojure-2795789891682912303.edn error Command failed with exit code 1. info Visit for documentation about this command.
spy library makes it clear it’s usable in CLJS too.
And the Full report file contains the following.
{:clojure.main/message
"Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).\ncom.google.javascript.jscomp.AnonymousFunctionNamingPolicy\n",
:clojure.main/triage
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "closure.clj",
:clojure.error/path "shadow/build/closure.clj",
:clojure.error/class java.lang.ClassNotFoundException,
:clojure.error/cause
"com.google.javascript.jscomp.AnonymousFunctionNamingPolicy"},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message
"Syntax error compiling at (shadow/build/closure.clj:1:1).",
:data
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 1,
:clojure.error/source "shadow/build/closure.clj"},
:at [clojure.lang.Compiler load "Compiler.java" 7652]}
{:type java.lang.ClassNotFoundException,
:message
"com.google.javascript.jscomp.AnonymousFunctionNamingPolicy",
:at
[java.net.URLClassLoader findClass "URLClassLoader.java" 382]}],
:trace
[[java.net.URLClassLoader findClass "URLClassLoader.java" 382]
[clojure.lang.DynamicClassLoader
findClass
"DynamicClassLoader.java"
69]
[java.lang.ClassLoader loadClass "ClassLoader.java" 418]
[clojure.lang.DynamicClassLoader
loadClass
"DynamicClassLoader.java"
77]
[java.lang.ClassLoader loadClass "ClassLoader.java" 351]
[java.lang.Class forName0 "Class.java" -2]
[java.lang.Class forName "Class.java" 348]
[clojure.lang.RT classForName "RT.java" 2212]
[clojure.lang.RT classForNameNonLoading "RT.java" 2225]
[shadow.build.closure$eval11941$loading__6737__auto____11942
invoke
"closure.clj"
1]
[shadow.build.closure$eval11941 invokeStatic "closure.clj" 1]
[shadow.build.closure$eval11941 invoke "closure.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 482]
[shadow.build.js_support$eval11935$loading__6737__auto____11936
invoke
"js_support.clj"
1]
[shadow.build.js_support$eval11935 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval11935 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[shadow.build.resolve$eval10432$loading__6737__auto____10433
invoke
"resolve.clj"
1]
[shadow.build.resolve$eval10432 invokeStatic "resolve.clj" 1]
[shadow.build.resolve$eval10432 invoke "resolve.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build.api$eval10424$loading__6737__auto____10425
invoke
"api.clj"
1]
[shadow.build.api$eval10424 invokeStatic "api.clj" 1]
[shadow.build.api$eval10424 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 1789]
[shadow.build$eval10418$loading__6737__auto____10419
invoke
"build.clj"
1]
[shadow.build$eval10418 invokeStatic "build.clj" 1]
[shadow.build$eval10418 invoke "build.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 3894]
[shadow.cljs.devtools.api$eval2025$loading__6737__auto____2026
invoke
"api.clj"
1]
[shadow.cljs.devtools.api$eval2025 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval2025 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[shadow.cljs.devtools.cli$eval138$loading__6737__auto____139
invoke
"cli.clj"
1]
[shadow.cljs.devtools.cli$eval138 invokeStatic "cli.clj" 1]
[shadow.cljs.devtools.cli$eval138 invoke "cli.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load
... Omit the rest ...
Does anyone know why this might be happening?{:mvn/version "2.16.6"}
and seems like issue is fixed.
Dealing with another issue though.
SHADOW import error /Users/w/flex-cli/.shadow-cljs/builds/test-once/dev/out/cljs-runtime/ajax.xml_http_request.js
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
Turns out I had to update cljs-ajax dependency too (from 0.7.5)========= Running Tests =======================
SHADOW import error /Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/todana.components.gigpage.api.js
/Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog/net/xmlhttp.js:173
return new XMLHttpRequest();
^
ReferenceError: XMLHttpRequest is not defined
npm install xhr2
(:require ["xhr2" :as xhr2] ..) (set! js/XMLHttpRequest xhr2)
:lein {:profiles "+cljs"}". Should that be :profile?:npm-module and included by our main web app. We also have some packages that are shared between the main app and the cljs project. Some of these shared packages require that only one instance be imported at once (singletons), for which we use peerDependencies.
However, as best as I can tell, the shadow-cljs dev server imports a second instance of those packages in its output, so the browser hits their singleton guards and fails. 😕
I hope that was clear enough. 😅 Any suggestions?peerDependencies does nothing regarding how a package is required/used at runtime:npm-module build and let webpack post process the dependencies then there should be no issue since shadow-cljs will not be providing any JS deps:js-provider or something then you'll get duplicatesshadow-cljs watch npm, when it is being yarn linked by the webpacked project? That's the situation we're having difficulty with
Maybe there's some setting we've goofed. Though :js-provider certainly isn't being set explicitly. :thinking_face:node_modules in the linked package, and bundles those as the (duplicated) deps to use for the linked module.
It seems like the problematic packages only need to be installed in the :npm-module's node_modules for the Karma test suite to run :thinking_face:The required JS dependency "crypto" is not available, it was required by "node_modules/seedrandom/seedrandom.js".
...
crypto is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.
npm install --save-dev shadow-cljs
See:
I do have shadow-cljs installed locally. Did I miss something? (crypto is used by mathjs, required in my project)require.resolving or other tricks to find out if their dependencies are available.
Do you have crypto npm installed? If so, is it a pure JS library, or is it a native (C/C++) library?crypto is a native node js library (https://nodejs.org/api/crypto.html), it is polyfilled in node-libs-browser for browser target. Here I need to include mathjs in my node build, and mathjs requires the native crypto (that must not be included in the build).:resolve {"crypto" {:target :global :global "crypto"}}
but it does not work.:resolve {"crypto" false}
seems to work as a workaround:keep-as-requires, let me find it to you...:js-options {:js-provider :shadow
:keep-native-requires true
:keep-as-require #{"atom"}}:keep-native-requires true works. If it doesn't, change the :keep-as-require to #{"crypto"} and that should work 🙂:js-provider :shadow for node builds:keep-as-require or :keep-native-requires 😛:shadow is heavily optimized for the browser and usually not required for node(:require [goog]) , that the standalone CLJS compiler need configuration to support?goog is already an implicit dependency of every cljs namespace so you do not need itaws-amplify-shadow-cljs project but I seem to have issues importing the amplify coding.
Here are the issues:
I seem to have similar issues to https://stackoverflow.com/questions/64461818/require-aws-amplify-v-3-amplify-and-auth-classes-in-clojurescript-reagent-shadow but even after I have done all those steps, it does not work.
I will leave full error log in the comment to this post.
Seems that from v4 of aws-amplify things don't work.
shadow-cljs.edn:
{:source-paths ["src"]
:dependencies [[proto-repl "0.3.1"]
[binaryage/devtools "1.0.4"]
[reagent "1.1.0"]
[re-frame "1.2.0"]
[day8.re-frame/re-frame-10x "1.1.13"]
[bidi "2.1.5"]
[kibu/pushy "0.3.8"]
[com.andrewmcveigh/cljs-time "0.5.2"]]
:nrepl {:port 3333}
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:init-fn app.core/init}}
:js-options {:provider :closure
:entry-keys ["main" "module" "browser"]}
:compiler-options {:output-feature-set :es6
:closure-defines {re-frame.trace/trace-enabled? true
day8.re-frame.tracing/trace-enabled? true}}
:devtools {:http-root "public"
:http-port 3000
:preloads [day8.re-frame-10x.preload]}}}}shadow.js.js:sourcemap:36 shadow-cljs - failed to load module$node_modules$aws_amplify$lib$index
shadow.js.jsRequire @ shadow.js.js:36
shadow.js.require @ shadow.js.js:59
eval @ app.core.js:2
goog.globalEval @ main.js:528
env.evalLoad @ main.js:1603
(anonymous) @ main.js:4961
main.js:1495 TypeError: util.inherits is not a function
at Object.shadow$provide.module$node_modules$assert$assert (module$node_modules$assert$assert.js:12)
at shadow.js.jsRequire (shadow.js.js:34)
at Object.shadow$provide.module$node_modules$http2$lib$protocol$endpoint (module$node_modules$http2$lib$protocol$endpoint.js:2)
at shadow.js.jsRequire (shadow.js.js:34)
at Object.shadow$provide.module$node_modules$http2$lib$protocol$index (module$node_modules$http2$lib$protocol$index.js:1)
at shadow.js.jsRequire (shadow.js.js:34)
at Object.shadow$provide.module$node_modules$http2$lib$http (module$node_modules$http2$lib$http.js:9)
at shadow.js.jsRequire (shadow.js.js:34)
at Object.shadow$provide.module$node_modules$http2$lib$index (module$node_modules$http2$lib$index.js:1)
at shadow.js.jsRequire (shadow.js.js:34)
reportError @ main.js:1495
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4961
main.js:1497 The above error occurred when loading "app.core.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.
reportError @ main.js:1497
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4961
shadow.module.main.append.js:4 An error occurred when calling (app.core/init)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:528
env.evalLoad @ main.js:1603
(anonymous) @ main.js:4962
main.js:1495 TypeError: app.core.init is not a function
at eval (shadow.module.main.append.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:528)
at Object.env.evalLoad (main.js:1603)
at main.js:4962
reportError @ main.js:1495
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4962
main.js:1497 The above error occurred when loading "shadow.module.main.append.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at other
(ns app.core
(:require
["/aws-exports.js" :default aws-exports]
["aws-amplify" :default amplify]
[reagent.core :as r]
[reagent.dom :as dom]
[re-frame.core :as rf]
[app.db]
[app.router :as router]
[app.components.core :as c]))
(def functional-compiler (r/create-compiler {:function-components true}))
(r/set-default-compiler! functional-compiler)
(defn pages
[page-name]
(case page-name
:inboxes [inboxes]
:profile [profile]
:become-a-chef [become-a-chef]
:recipes [recipes-page]
:recipe [recipe-page]
:log-in [log-in]
:sign-up [sign-up]
[recipes-page]))
(defn app
[]
(let [active-page @(rf/subscribe [:active-page])]
[:<>
[:div.bg-gray-100.w-screen.h-screen
[:div.container.mx-auto
[:div
[nav]
[pages active-page]]]]]))
(defn ^:dev/after-load start
[]
(dom/render
[app]
(.getElementById js/document "app")))
(defn ^:export init
[]
(.configure amplify aws-exports)
(router/start!)
(rf/dispatch-sync [:initialize-db])
(start)){
"name": "Cheffy",
"version": "0.0.1",
"description": "Cheffy - AirBnB for Chefs",
"private": true,
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"shadow:watch": "shadow-cljs watch app",
"shadow:release": "shadow-cljs release app",
"postcss:build": "cross-env TAILWIND_MODE=build postcss src/css/tailwind.css -o ./public/css/main.css --verbose",
"postcss:watch": "cross-env TAILWIND_MODE=watch postcss src/css/tailwind.css -o ./public/css/main.css --verbose -w",
"postcss:release": "cross-env NODE_ENV=production postcss src/css/tailwind.css -o ./public/css/main.css --verbose",
"dev": "run-p -l *:watch",
"release": "run-s *:release"
},
"devDependencies": {
"autoprefixer": "^10.3.3",
"cssnano": "^5.0.8",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.5",
"postcss-cli": "^8.3.1",
"react-flip-move": "^3.0.2",
"shadow-cljs": "^2.15.5",
"tailwindcss": "^2.2.4"
},
"dependencies": {
"@aws-amplify/ui-react": "^2.1.1",
"@headlessui/react": "^1.4.2",
"@heroicons/react": "^1.0.5",
"@tailwindcss/forms": "^0.3.3",
"aws-amplify": "^4.3.8",
"aws-crt": "^1.10.2",
"create-react-class": "15.7.0",
"cross-env": "^7.0.3",
"encoding": "^0.1.13",
"highlight.js": "11.1.0",
"http2": "^3.3.7",
"react": "17.0.2",
"react-dom": "17.0.2"
}
}aws-amplify was requiring http2 module which (from what I remember) was built in with node js. I installed it with npm I http2 and there seem to be some errors related to this alsoprocess.env.BROWSERLIST_DISABLE_CACHE and process is undefined. I saw you also tried to install process as an npm package (did this also but it does not fix the issue)
UDPATE:
Added this to the webpack config and it was fixed
plugins: [
// fix "process is not defined" error:
// (do "npm install process" before running the build)
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],process npm package, because there were conflicts with AWS Amplify and Storybook: both depending on Webpack, but with different versions.
And Storybook used a feature that has been removed (process). So my workaround was to include it in the Storybook UI only. But I don’t think that package should be exposed in a web site (if I’m not mistaking)..mjs files when using shadow-cljs to make a node script? i.e. ECMAScript modules.mjs files in my projects source, so dynamically at runtimejs files and consume those from shadow.mjs file (or many)js/import?(:require ["/some/place/file.mjs" :as x]).mjs files don't need to be accessible after the build:advanced optimizations so you might have to deal with externs.mjs files dynamically at runtime without shadow-cljs ever knowing about it (ie. (js/import "./that-file.mjs")(:require ["/some/place/file.mjs" :as x]) won’t workjs/import as a fail safejs/import or shadow.esm/dynamic-import
(js/import "...") => ReferenceError: import$ is not defined (shadow.esm/dynamic-import "...") => ReferenceError: shadow_esm_import is not defined
.js file
module.exports = import('./index.mjs');
then using js/require to require this .js file:node-script target and it’s working well, but I need to add some .mjs source to the project.mjs file, will that work?"mutesync_engine_win32": "file:./mutesync_engine_win32",node_modules foldernode_modules/mutesync_engine_win32 all is fine(:require ["mutesync_engine_win32" :as x]) in your codeError [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\19518\src\mutesync\shells\electron\node_modules\mutesync_engine\index.mjs
at Module.load (internal/modules/cjs/loader.js:933:11)
at Module._load (internal/modules/cjs/loader.js:776:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at C:\Users\19518\src\mutesync\.shadow-cljs\builds\electron-main-dev\dev\out\cljs-runtime\shadow.js.shim.module$mutesync_engine.js:3:41
at global.SHADOW_IMPORT (C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:64:44)
at C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:1757:1
at Object.<anonymous> (C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:1786:3)
at Module._compile (internal/modules/cjs/loader.js:1078:30):target :esm to turn the CLJS output into ESM:node-script and :esm should both be equivalent in that regardjs*?:esm is ESM and therefore will work with ESM packages:node-script is commonjs and has issues with ESM 😛import issue is a closure compiler issue, so release will likely breakimport$ thing but that still doesn't fix releasenode_modules packages in a :node-script build at allnode_modules:advanced in releaseshadow-cljs node-repl on the command line, and from there I can load toy.m2 and execute the function in thereshadow.user> (require '[toy.m2]) Execution error (FileNotFoundException) at shadow.user/eval27877 (REPL:45). Could not locate toy/m2__init.class, toy/m2.clj or toy/m2.cljc on classpath.
cljs.user=> (require '[toy.m2]) nil cljs.user=> (ns toy.m2) nil toy.m2=> f #object[toy$m2$f] toy.m2=> (f 2 3) 5
cider-jack-in-cljs seems to just hang. Which is a matter of some confusion for me.npm install (which is what i was stalled on lol)
2. cider-jack-in-cljs (shadow > browser | node )npm install now that I have, it’s asking me for a build :woman-shrugging:cider-connect-cljs ?cider-jack-in-cljs it gives me a couple default "shadow builds" of node and repl. If you start from the command line i'm not sure they are there.
looking at shadow docsshadow-cljs browser-repl
Then cider-connect-cljs -> browser-repl , would likely work except now i need to inject my nrepl deps.cider-jack-in-cljs because it injects them for me➜ toy git:(main) ✗ shadow-cljs node-repl shadow-cljs - config: /home/drewverlee/Personal/toy/shadow-cljs.edn shadow-cljs - HTTP server available at shadow-cljs - server version: 2.16.6 running at shadow-cljs - nREPL server started on port 35837
cider-connect-cljs > shadow > node-repl;; Connected to nREPL server - ;; CIDER 1.2.0snapshot (package: 20211123.1732), nREPL 0.8.3 ;; Clojure 1.10.3, Java 11.0.11 ;; Docs: (doc function-name) ;; (find-doc part-of-name) ;; Source: (source function-name) ;; Javadoc: (javadoc java-object-or-class) ;; Exit: <C-c C-q> ;; Results: Stored in vars *1, *2, *3, an exception in *e; ;; ;; ClojureScript REPL type: shadow ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/node-repl)) ;; WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information) To quit, type: :cljs/quit [:selected :node-repl]WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 3.2.2 (package: 20211117.1008) and n/a, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user> cljs.user>
:paths ["src/main" "resources"] in deps.edn and :dev-http {8000 "classpath:public"} in shadow-cljs.edn. The dev server serves index.html correctly from resources/public when requested from localhost:8000, but any other URL results in 404. From the https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, I would expect that resources/public/index.html is served, rather than resulting in 404, correct?
If I change to :dev-http {8000 "resources/public"} it works as expected. Wondering if its caused by something in shadow.http.push-state/handle.pnx-web.js:1455 Module not provided: module$node_modules$primereact$menu$menu_cjs
shadow$provide["module$node_modules$primereact$menu$menu_cjs"] = function(global,require,module,exports) ...
SHADOW_ENV.evalLoad("module$node_modules$primereact$menu$menu_cjs.js", true, "shadow$provide.module$node_modules$Primereact$menu$menu_cjs\x3dfunction(global,require,module,exports) ...
rm -rf node_modules and an npm install usually does the trick 😄 .shadow-cljs/builds and restarting shadow-cljs?:modules config but did not adjust actually loading those modules in your HTML?:output-dir and just continue loading a mix of old and new files?:closure-defines from my build hook with values it reads from local file, but updates were not propagating into the build. Here are the snippets:
app/dev.clj
(defn load-dev-vars
{:shadow.build/stage :configure}
[{:keys [:shadow.build/mode] :as build-state} relative-path]
(let [conf-path (File. (:project-dir build-state) relative-path)]
(if (and (= :dev mode) (.exists conf-path))
(let [overrides (edn/read-string (slurp conf-path))]
(println "Applying vars override:" overrides)
(update-in build-state [:shadow.build/config :closure-defines]
merge overrides))
build-state)))
shadow-cljs.edn
{...
:builds
{:front
{:target :browser
:modules {:main {:init-fn app.system/go}}
;; Dev vs Prod build vars. Override via extra config.
:build-hooks [(app.dev/load-dev-vars "local-defines.edn")]
:closure-defines {app.config/api-root "/api"}}}}
Inspecting build-state showed that overrides were applied as expected, but build contained original values... Looking at the shadow-cljs source I found that at :configure stage defines are injected into other part of build-state - :complier-options. Changing the path from [:shadow.build/config :closure-defines] to [:compiler-options :closure-defines] indeed fixed the issue.
Why not just add my defines into :dev :closure-defines in shadow-cljs.edn - I don't want to commit local configuration into version control and/or stash the changes on every pull. With an additional file, added into git and docker ignores, it's much easier to manage.
My question: is it expected behavior or just code ordering issue in configure stage of shadow-cljs? Maybe it was not supposed that users would change build configuration in hooks?..:configure hook runs the build config is already applied and as such modifying it has no effect[:compiler-options :closure-defines] directly insteadsubs.cljs:94 Uncaught ReferenceError: document is not defined
at subs.cljs:94
at worker.js:1457
at Array.forEach (<anonymous>)
at Object.env.load (worker.js:1453)
at worker.js:1489
(anonymous) @ subs.cljs:94
(anonymous) @ worker.js:1457
env.load @ worker.js:1453
(anonymous) @ worker.js:1489(ns quagga.components.dataview.worker)
(defn init []
(set!
js/self.onmessage
(fn [^js e]
(js/console.log "message received" (.. e -data))))):worker
{:init-fn quagga.components.dataview.worker/init
:depends-on #{:shared}
:web-worker true}"text/js-worker"postMessage as follows on the repl
(let [worker (js/Worker. "/js/quagga/worker.js")] (.. worker (postMessage "hello world")))
:shared? Given the stacktrace, there's some subs.cljs file in there that tries to reference js/document, which does not exist in web workers.:shared {:entries []},shared:depends-on #{} but then it says
ExceptionInfo: two modules without deps, please specify which one is the default
subs.cljs still comes from somewhere even though your web worker ns clearly doesn't depend on it. @U05224H0W Could it be a bug?:shared that the worker doesn't like?:devtools
{:preloads [day8.re-frame-10x.preload],
:watch-dir "resources/public/css/"},
:modules
{:home
{:depends-on #{:shared}, :entries [quagga.components.home.init]},
:organization
{:depends-on #{:shared},
:entries [quagga.components.organization.init]},
:settings
{:depends-on #{:shared},
:entries [quagga.components.organization.settings.init]},
:shared {:entries []},
:tabbed-dataview
{:depends-on #{:shared},
:entries [quagga.components.dataview.init]},
:user-management
{:depends-on #{:shared},
:entries [quagga.components.organization.users.init]}
:worker
{:init-fn quagga.components.dataview.worker/init
:depends-on #{:shared}
:web-worker true}},
:output-dir "resources/public/js/quagga/",:shared anything that two of the other modules may use will get moved to :shared:base module or so:shared and :worker depend on but have all the others only depend on :shared:entries [] is fine:shared has namespaces that are shared by all other modules that depend on :shared.
Thanks!:home and :settings share a required namespace the only place it can go is :shared.:modules
{:home
{:depends-on #{:shared}, :entries [quagga.components.home.init]},
:organization
{:depends-on #{:shared},
:entries [quagga.components.organization.init]},
:settings
{:depends-on #{:shared},
:entries [quagga.components.organization.settings.init]},
:shared {:entries []
:depends-on #{:base}},
:base {:entries []}
:tabbed-dataview
{:depends-on #{:shared},
:entries [quagga.components.dataview.init]},
:user-management
{:depends-on #{:shared},
:entries [quagga.components.organization.users.init]}
:worker
{:init-fn quagga.components.dataview.worker/init
:depends-on #{:base}
:web-worker true}}quagga.components.dataview.worker ns end up including the problem ns?worker.js that looks like this
SHADOW_ENV.load({}, ["goog.debug.error.js",..."day8.re_frame_10x.inlined_deps.re_frame.v1v1v2.re_frame.subs.js","shadow.cljs.devtools.client.browser.js","shadow.module.base.append.js","quagga.components.dataview.worker.js","shadow.module.worker.append.js"]);
(I have eliminated some code) could this mean that re-frame-10x might be adding some undesired js to the worker.js somehow?:devtools from my app build
;; :devtools
;; {:preloads [day8.re-frame-10x.preload],
;; :watch-dir "resources/public/css/"},:shared module. just :shared {:entries [] :depends-on #{:base} :preloads [day8.re-frame-10x.preload]}2.16.6 resulted in a 50% increase in size of our advanced build.
The increase seem to have been introduced with 2.15.13 which uses a newer version of the CLJS compiler with some various Closure updates.
Did anyone notice an increase in size as well?Hook [0 shadow.cljs.build-report/hook] failed in stage :flush NoSuchFileException: .shadow-cljs/builds/psap/release/out/main.jsDoes that ring any bell?
:browser build?:browser currently:node-library:browser 💪 Still need to confirm whether the regression is reproducible this way, too. Stay tuned.:js-options {:js-provider :require}. it won't actually run in the browser that way but the build report won't suddenly contain all the bundled npm depenendeices.cljc.cljs portions--pseudo-names and looking at the output trying to figure out where it increase is coming from--pseudo-names will make it huge regardless but at least you can figure out what the code was before optimizationsshadow-cljs --verbose --config-merge shadow-cljs-no-hash-names.edn ...the no-hash-names tries to "undo" the module-hash-names from the normal shadow-cljs.edn
{:builds {:website {:module-hash-names true}}} merged with {:builds {:website {:module-hash-names false}}} should disable it{:module-hash-names false}?{:module-hash-names :duude}, then I don't get an error-> build target: :browser stage: :flush
invalid :module-hash-names value :duude
{:tag :shadow.build.targets.browser/module-hash-names, :module-hash-names :duude}
ExceptionInfo: invalid :module-hash-names value :duude
shadow.build.targets.browser/hash-optimized-module (browser.clj:411)
shadow.build.targets.browser/hash-optimized-module (browser.clj:389)
shadow.build.targets.browser/hash-optimized-modules/fn--39881/fn--39882 (browser.clj:421)
?:local/root?:node-test or :browser-test setup in the main project running as a watch?:node-test . I have this:
main-project/shadow-cljs.edn:
{:builds
{:app {,,,}
:test {:target :node-test, :output-to "target/test/test.js"
:autorun true}}
:deps {:aliases [:dev :test]}}
main-project/deps.edn:
:deps {,,,
library/library {:local/root "../library"}
,,,}
library/deps.edn:
{:paths ["src"]
:aliases {:test {:extra-paths ["test"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.16.7"}}}}}
(The extra-deps is for the separate test runner use case).test folder which is not on the classpath when loading in the main project since that doesn't activate the :test alias:deps {:aliases [:dev :test]} would activate that.:local/root dependenciestest/cljs and trying this from there gives me a ExceptionInfo: Resource does not have expected namespace error from shadow-cljs.( "one/of_your_tests.cljs"):js-options {:js-package-dirs ["functions/node_modules"]} but when I run the script it can’t find modules that only exist in functions/node_modules . I tried running the script from the functions directory and also tried compile and release (simple) builds.scripts/index.js
• functions/node_modules
• shadow-cljs.edn functions/index.js:output-to into the dir that also has the node_modules dirfunctions . I did play with ncc at some point which also worked pretty well but not really required in this case.:js-package-dirs option would magically tell the compiled script where to find packages but I think it’s slightly different / only has that effect for browser builds(:require [react]) or any kind of symbol where shadow-cljs needs to verify you mean a npm packagefs and so on anyways given they are built-incljs.build.api/build does most of what I want, as long as I don't want advanced optimizations. Would there be a way to have pieces of shadow assist with that?:advanced build after the fact is pretty much impossible:simple might be a viable option (or even :none):advanced:simple is usually out of the question. for oz/portal/clerk that might not be of such a high concernnpx shadow-cljs release :main producing a file that has 4096 lines instead of 1? The dev build is 13M, but release build is 2M so some optimization was done, but I expected all whitespace to be gone and the build being 1 liner.npx shadow-cljs release appscript --debug fails but npx shadow-cljs compile appscript succeeds? More details in thread 😃... Any ideas on what to try next would be appreciated!npx shadow-cljs release appscript --debugfails with:
[:appscript] Compiling ...
IllegalStateException:
com.google.common.base.Preconditions.checkState (Preconditions.java:492)
com.google.javascript.jscomp.OptimizeParameters.addVariableToFunction (OptimizeParameters.java:1025)
com.google.javascript.jscomp.OptimizeParameters.optimizeFunctionDefinition (OptimizeParameters.java:933)
com.google.javascript.jscomp.OptimizeParameters.tryEliminateConstantArgs (OptimizeParameters.java:644)
com.google.javascript.jscomp.OptimizeParameters.process (OptimizeParameters.java:128)
com.google.javascript.jscomp.OptimizeCalls.process (OptimizeCalls.java:125)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:462)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:905)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:568)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/compile-js-modules (closure.clj:1102)
shadow.build.closure/compile-js-modules (closure.clj:1088)
shadow.build.closure/optimize/fn--11127 (closure.clj:1297)
shadow.build.closure/optimize (closure.clj:1283)
shadow.build.closure/optimize (closure.clj:1274)
shadow.build.api/optimize (api.clj:273)
shadow.build.api/optimize (api.clj:267)
shadow.build/optimize (build.clj:476)
shadow.build/optimize (build.clj:468)
shadow.cljs.devtools.api/release* (api.clj:339)
shadow.cljs.devtools.api/release* (api.clj:324)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--15307--auto----15979 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
But npx shadow-cljs compile appscript just succeeds?:
[:appscript] Compiling ... [:appscript] Build completed. (43 files, 42 compiled, 0 warnings, 11.39s)
shadow-cljs.edn config:
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[applied-science/js-interop "0.3.1"]]
:builds
{:appscript {;:main example.core
:target :node-library
:output-to "shadow-Code.js"
;:optimizations :advanced
:output-dir "target"
;:pretty-print false
:externs ["resources/gas.ext.js"]
:exports-var example.core/main}}}npx shadow-cljs check appscript, but I'm just getting some warnings, no errors. I'm running shadow-cljs version 2.16.8.(defn ^:export start []) and (defn ^:export main [])^export has no effect at all for :node-library:exports {:start foo.bar/start :main foo.bar/main}^:export in :node-library or :node-script builds is pointless anyways so don't use it at all 😛:exports-var?:exports-var:exports-var {:main example.core/main, :start example.core/start},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:build-id ...}
should satisfy
unquoted-qualified-symbol?:exports then:exports-var is for a single var pointing to a JS objectdefn I assume?export default function(data) { /* */} for target :node-library?:client-log-level which can be set to: :severe `:warning` `:info` `:config` `:fine` `:finer` `:finest` .
I would like to temporarily disable “info” level warnings such as “shadow-cljs: call app.core/start” that come from shadow.:exports {:default some.ns/foo} where foo is a regular defn. assuming commonjs is ok, otherwise you need to go with :target :esm:devtools {:log false} in your build configselfor navigatorproperty in k6. I Guess that rules out :esmfor the moment?
However, on the positive side of things, I got it working as :node-librarybuild hack.js
import hack from "./dist/hack.js"; export default hack.default$;
:target :esmrefers to selfand window.navigator. Guess it is the Closure Compiler introducing them. Both exist in the browser and also in deno. Don't see a way to polyfill them atm.release however should notreleasebuilds have these references.goog/base.js so thats not easily replaced. the navigator I don't knownode-script , it works fine if I run node target/main.js. However, it seems to depend on node_modules . If I move target/main.js to somewhere else, it can't find required module anymore. Is it expected? How can I have a single file bundle?Error: Cannot find module 'qs', looks like it still looking for something in node_modules. I tried to (js/require "qs"), but it seems doesn't work. Any suggestion on what should I do for further debugging?npm install qs?target/main.js without any problems. So I have no idea which side cause the problem. Is the generated target/main.js has a statement that ncc can not recognize? or I just ran into a bug of ncc.yarn add d3 which seems to have done what I expected and added a bunch of d3 modules into node_modules/
I'm requiring d3 like so:
(ns browser
(:require ["d3" :as d3]
["d3-scale" :refer [scaleLinear]]
["d3-shape" :refer [line]]))
and some of it appears to work, as I can run these refers in my REPL, and the interop functions as I'd expect
(-> (scaleLinear)
(.domain #js [1 2]))
=> #object[scale]
However I can't seem to get any 'select' type functions to work, I tried using interop:
(.select d3 "#app") Execution error (TypeError) at (<cljs repl>:1). module$node_modules$d3$src$index.select is not a functionI've also tried following the refering format but had no luck with that either:
["d3-selection" :refer [select]] (select) Execution error (TypeError) at (<cljs repl>:1). _select is undefinedDoes anyone know how I'm meant to access the select function? I'm vaguely trying to achieve what they're doing here https://github.com/scotthaleen/cljs-d3-force-direct-graph/blob/master/src/haleen/fd/graph/core.cljs#L17 except they use the global context for d3 which doesn't work either for me, and from what I've read, shouldn't really be done. Thanks for any help!
shadow-cljs - failed to load module$node_modules$d3_array$src$number js.js:74:16 shadow-cljs - failed to load module$node_modules$d3_array$src$bisect js.js:74:16 shadow-cljs - failed to load module$node_modules$d3_array$src$index js.js:74:16 shadow-cljs - failed to load module$node_modules$d3$src$index js.js:74:16 An error occurred when loading abc.js main.js:1672:15I've looked in the generated numbers.js and it seems to failing on this:
regeneratorRuntime.mark(numbers)Tried googling about
regeneratorRuntime undefined and found https://stackoverflow.com/questions/53558916/babel-7-referenceerror-regeneratorruntime-is-not-defined
I can try this but I'm not really sure what it's doing
yarn add core-js yarn add regenerator-runtime
(:require ["regenerator-runtime/runtime"]) before your d3 or other js requires(.select d3 "#app") => #object[Selection [object Object]]
npx shadow-cljs watch :app ? I don't know what they mean or how to fix them.
shadow-cljs - config: C:\Users\JaceMaverick\Downloads\quickstart-browser-master\quickstart-browser-master\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.16.8 running at
shadow-cljs - nREPL server started on port 55621
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (277 files, 0 compiled, 0 warnings, 4.96s)
Dec 13, 2021 10:00:47 PM io.undertow.server.Connectors executeRootHandler
ERROR: UT005071: Undertow request failed HttpServerExchange{ GET /}
Unexpected error macroexpanding go at (com/wsscode/pathom/connect.cljc:1177:8).
at clojure.lang.Compiler.macroexpand1(Compiler.java:7023)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:7097)
at clojure.lang.Compiler.analyze(Compiler.java:6793)
at clojure.lang.Compiler.analyze(Compiler.java:6749)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6122)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6440)
...:dependencies? Just remove it shadow-cljs already provides oneinit on both namespacesnpx shadow-cljs watch <something> will be downloaded and when I actually run watch, I won't need internet access? 🙏shadow-cljs classpath is probably the "quickest"shadow-cljs.edn and not project.clj/deps.ednclasspath downloads everything watch or server or anything else would download(defn greeting-for
[name]
{:pre [(string? name)]}
(str "Hello " name))
(greeting-for 123)
The assert will of course fail, but the only output I get back from the REPL is:
#object[Error Error: Assert failed: (string? name)]No stack trace, no mention of which function's assert failed. Is there some way to get it to actually display the details of the
Error thrown, instead of just its message field?(js/console.log *e) I guess(.-stack *e)(pst) is broken. that is what I'd be using normally$ clj
Clojure 1.10.1
(defn greeting-for
[name]
{:pre [(string? name)]}
(str "Hello " name))
#'user/greeting-for
user=> (greeting-for 123)
Execution error (AssertionError) at user/greeting-for (REPL:1).
Assert failed: (string? name)
user=> (pst)
AssertionError Assert failed: (string? name)
user/greeting-for (NO_SOURCE_FILE:1)
user/greeting-for (NO_SOURCE_FILE:1)
user/eval148 (NO_SOURCE_FILE:1)
user/eval148 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7132)
clojure.core/eval (core.clj:3214)
clojure.core/eval (core.clj:3210)
clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
clojure.main/repl/read-eval-print--9086 (main.clj:437)
clojure.main/repl/fn--9095 (main.clj:458)
clojure.main/repl (main.clj:458)
nil
user=>(pst) being broken, but good tips, thanks!npx shadow-cljs watch main and it does compile and prints watching build :main yet the browser says
> Stale output! Your loaded JS was not produced by the running shadow-cljs instance.
How do I troubleshoot this?
(I load the app via the backend server, not shadow dev server)
I even deleted the main.js before restarting shadow to make sure that it is built by shadow.
Solved: I was starting shadow in the wrong project 😅:output-dir but forget to adjust paths in HTML or so:devtools {:devtools-url ...}:devtools-url , right?build-storybook,
info => Using default Webpack5 setup ERR! => Failed to build the preview ERR! Module not found: Error: Can't resolve 'xmlhttprequest' in '/Users/me/app-frontend/public/js/stories' 64% building 14/14 entries 5634/5692 dependencies 987/1313 modulesERR! ModuleNotFoundError: Module not found: Error: Can't resolve 'xmlhttprequest' in '/Users/me/app-frontend/public/js/stories'I’m assuming this is because Kee-frame depends on some packages that support both browser & server-side routing (Reitit by default I think), but I don’t think my base shadow-cljs build is going to pull the server-side dependencies in, given it targets the browser. Here’s my shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/stories"
"src/test"]
:dependencies
[[reagent "1.1.0"]
[kee-frame "1.3.2"]
[arttuka/reagent-material-ui "5.0.0-0"]
[garden "1.3.10"]]
:dev-http {8080 "public"}
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:init-fn app.frontend.core/render!}}}
:stories {:target :npm-module
:runtime :browser
:ns-regexp "-stories$"
:output-dir "public/js/stories"}}}npm install xmlhttprequest , then I get other “Module not found” errors, with fs and child_processnpm install in your project before starting shadow and storybook?npm install, shadow-cljs release app stories and then tried to run storybook.package.json,
...
"browser": {
"xmlhttprequest": false
},
...
Had to https://github.com/defunctzombie/package-browser-field-spec what the browser configuration does. Seems like directly excluding what is known to be a server-side module from codepaths that can be assumed to execute purely client-side can be considered a bit heavy-handed, but it worked.clj directly with whatever alias you like. clj -M:whatever:foo -m shadow.cljs.devtools.cli watch app would be equiv to shadow-cljs watch app~/.shadow-cljs/config.edn and my project specific .shadow-cljs.edn would see the alias, is that correct?:deps-aliases in ~/.shadow-cljs/config.edn?{:deps-aliases [:foo]} in ~/.shadow-cljs/config.edndl-react-native-mock-render/mock but then I've added a React Native dependency and everything broke again.
So, does anyone have any tips on how to run react-native without Jest, using just :node-test or `:node- target or anything like that?react-native in node, so node targets won't work. I believe what jest does is replace any react-native require with something else but not surejest somehow hooks itself into require to do this. dunno how though. maybe its just a build tool, as in it preprocesses the code before running it:node-test with :js-options {:js-provider :shadow :keep-native-requires true :resolve {"react-native" {:target :npm :require "some-replacement"}}} etcModule not provided: @babel/runtime/helpers/interopRequireDefault--config-merge re-frame-10x.edn
re-frame-10x.edn
{:builds
{:dev
{:devtools
{:preloads [day8.re-frame-10x.preload]}
:dev
{:compiler-options
{:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release
{:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}}}
But that doesn't work, i believe it inserts into the build level, but when i do that, my app doesn't start. so i assume it overwrites.(shadow.cljs.devtools.api/watch-set-autobuild! :the-build-id false) to disable and true to enable again(cljs.analyzer/analyze in a non-bootstrapped build target? I’m “just” looking to get the AST structure for some code at runtime(js/OpenLayers.Map. "map") syntax, shadow-cljs complanis OpenLayers is not defined,
if I use (:require ["ol" :as ol]) I can define a map like (def mapp (ol/Map. "map")) but I don't know how to use constructors like (js/OpenLayers.Layer.OSM. "Simple OSM Map").
Also, using this require, I cannot send the namespace expression via the nREPL connection in Clojure-Kit from IntelliJ, because the ns macro is considered invalid (shadow-cljs compiles fine however ...).
So, what is the correct way to do stuff like this in CLJS with shadow?
Is requiring a library like this something very shadow-specific?
I guess it might be possible to require the library via the html (then the js/OpenLayers.Map. thing should work, right?) but I kind of feel like this should not be the wayol is basically OpenLayers so use that as a regular aliasjs/OpenLayers.Map. would become ol/Map.(js/OpenLayers.Layer.OSM. "Simple OSM Map") would become (ol/Layer.OSM. "Simple OSM Map")js/OpenLayers with ol/$APP.qr is undefined.
If I switch to simple compilation it works fine, if I compile everything into a single file it also works fine, but with advanced compilation and multiple modules it breaks.
So for now I've just switched to using one single file, but if anyone has any clue what's going on it'd be appreciated
This is the commit that works around it, in case you want to explore the code before/after: https://github.com/NyanCAD/Mosaic/commit/b1f484942e89509246c88b3ad12ad53c445088dashadow-cljs release frontend --pseudo-names to get an idea what $APP.qr might be$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha11756$$ color me somewhat surprised:commonnpx shadow-cljs release appand the config is setup to use the production root
{:app {:target :browser
:output-dir "local-dev/public/js/compiled"
:asset-path "/js/compiled"
:module-hash-names true
:modules {:pnx-web {:init-fn pnx-web.core/init}}
:devtools {:preloads [day8.re-frame-10x.preload]}
:dev {:compiler-options
{:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release {:output-dir "release/public/js/compiled"}
:build-options {:ns-aliases {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
is app definition.bashrc as OPEN_WEATHER and in my shadow-cljs.edn I have: :closure-defines {API-KEY #shadow/env "OPEN_WEATHER"} but when I try to use it in my app by referring to API-KEY I get an undeclared var error.(ns ) (goog-define VERBOSE false)and in shdaow-cljs.edn
:dev {:closure-defines { true}}
;; to enable always
:closure-defines { true}...{weather.core/API-KEY #shadow/env... and still getting the undeclared variable error...(ns weather.core ...) do you have (good-define API-KEY "dev") or something similar?(goog-define API-KEY "") and then that gets overridden by the shadow-cljs compiler?:source-map (Boolean) defaults to `true` during development, `false` for `release`.
> :source-map-detail-level `:all` or `:symbols` (`:symbols` reduces overall size a bit but also a bit less accurate)
shadow-cljs release app --source-maps or shadow-cljs release app --debug will also enable them temporarilyDevTools failed to load source map: Could not load content for : Connection error: net::ERR_CONNECTION_CLOSEDMy shadow-cljs build is loaded from an iframe in a Google Sheets sidebar. I would like to replace
with .:asset-path controls that. you can set it to a full domain. there is also :compiler-options {:source-map-inline true}, so they'll become part of the file itself with no extra request. makes the files rather huge though.import React from "react";
import { Rental } from "../models";
I set things up as per https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects with this layout:
.
├── package.json
├── shadow-cljs.edn
└── src
└── main
└── amplify_rental_reagent_app
└── core.cljs
└── js
├── .babelrc
└── ui-components
└── CardACollection.jsx
└── gen
├── models
└── index.js
└── index.d.ts
└── ui-components
└── CardACollection.js
Also have set up to use the webpack build as described in https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
:js-options {:js-provider :external
:external-index "target/index.js"}
The problem is that the import statement in the ui-component code is causing shadow-cljs to error out with:
[:app] Build failure: FileNotFoundException: /Users/rberger/work/aws/amplify-rental-reagent-app/src/gen/models (Is a directory)Is there a way to make that not happen? This JSX/JS code is all being generated by Amplify Studio and would prefer not to have to manually change that code… The repo with all this is at https://github.com/rberger/amplify-rental-reagent-app
import { Rental } from "../models"; to import { Rental } from "../models/index.js";:js-provider :js-external mechanism. Is there a way to tell shadow-cljs to include a tree of JS code in the :externa-index in addition to the npm modules to be processed by the external webpack process?
At least I think that is what would fix it. The actual issue is that import { Rental } from "../models/index.js"; has the file parsed, but Rental is not set properly.
I logged when Rental is set in `models/index.js
const { Rental } = initSchema(schema);
console.log("index.js Rental: ", Rental);
export { Rental };
and after the import in CardACollection.js
import { Rental } from "../models/index.js";
console.log("Rental: ", Rental);
And I see in the console:
index.js Rental: ƒ Model(init) {
var instance = (0,immer__WEBPACK_IMPORTED_MODULE_1__.produce)(this, function (draft) {
initializeInstance(init, modelDefinition, draft);
var …
main.js:1455 ReferenceError: Rental$$module$models$index is not defined
at eval (CardACollection.js:27)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:488)
at Object.env.evalLoad (main.js:1563)
at main.js:1744.babelrc to make this work better?ui-components are being processed by babel. The models code is vanilla from what is pulled in with amplify pullmodels stuff into the bundle.js:js-provider since no other JS tool will have access to your classpath https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js(:require ["my-models" :as foo]) will end up emitting require("my-models") in the JS file processed by webpackmy-models to resolve wherever you put it. eg. via alias https://webpack.js.org/configuration/resolve/#resolvealiasalias does that. basically alias: { "my-models":the-path-to-that }./ or ../ is looked up on the "filesystem" (classpath in shadow-cljs)node_modules, or gets redirect via alias:ssl cannot be overwritten easily since it is only setup when shadow-cljs is startedlein or clj(shadow.cljs.devtools.server/start! the-config)(-> (shadow.cljs.devtools.config/load-cljs-edn) (dissoc :ssl) (shadow.cljs.devtools.server/start!))start! with no args will just load shadow-cljs.edn and call the 1-arity start!. so you could load the config yourself and modify it however you wantjs/import.meta.url from import$.meta.url to import.meta.url?import.meta.url is not supported by the closure compiler so it won't work either way(js* "import.meta.url") but don't tell anyone I said that 😉release builds don't work?js* but that ends up as the samepackage.json of my library when people call it with nbb --version. of course I could keep the version in some different file/namespacepackage.json might be nice__dirname but then in the ES6-style(:require ["esm:../package.json" :as pkg-json]) might work?(ns nbb.macros (:require [clojure.data.json :as json])) (defmacro get-in-package-json [k] (get (json/read-str (slurp "package.json") :key-fn keyword) k))
(ns nbb.core (:require-macros [nbb.macros :as macros])) (defn version [] (macros/get-in-package-json :version))
Cannot redefine property: unstable_ClassNameGenerator. This comes from the index.js where it seems to be doing some treeshaking, importing, stuff. (I say stuff cause I'm not super familar with all the different approaches to this in JS world).:asset-path could be set to a full domain. That fixed my problem.> npx shadow-cljs compile app ... shadow-cljs - dependencies updated [:app] Compiling ... The required namespace "cljsjs.react-bootstrap" is not available, it was required by ...however, package cljsjs.react-bootstrap is in shadow-cljs.edn (also added to package.json in case there were hidden js dependencies).
npm install and npx shadow-cljs classpath don't show anything amiss.
how can I check what's going on? 🙂 shadow-cljs --verbose compile shows the same error, but nothing more[Error] ReferenceError: Can't find variable: j reportError (main.js:1455) (anonymous function) (main.js:1565) Global Code (main.js:1633) [Warning] The above error occurred when loading "cljs.pprint.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others. (main.js, line 1457)
:target :browser I assume?sentry?multi-module branch where I experimented with possibility of creating a shared module then separate modules for each cljs file such that one could potentially directly reference a cljs file in a script tag and a parcel transformer plugin could then create a shadow-cljs module per file along with shared module which might make cljs code artifacts in parcel feel more natural. This doesn’t work well for creating libraries but perhaps in the context of parcel web app bundle it could work.
I was also able to import ts file form cljs using the (:require ["esm:/src/ts/util.ts" :as ts]) syntax (on multi-module branch) however I found I needed to use an “absolute” path as it was relative to the target file rather than src file which sorta sucks but probably a way to add some sort of resolver extension to shadow-cljs to make that work better.:js-options {:js-provider :import}. otherwise shadow-cljs will bundle react and such and parcel will bundle it again for the TS parts.
• parcel HMR should be disabled for the cljs sources if you can. the "already declared" errors are not safe to ignore:target :npm-module for such deep interop things for nowesm: as a literal and doesn't do anything with it. I suppose you could add an alias for parcel so esm:ts/util.ts or so works:npm-module is basically your desired multi-moduletarget/cljs-runtime/module$node_modules$lodash$lodash.js for use in cljs
I then tried to add the :js-options {:js-provider :import} but keep the :target :esm and found it started complaining about not finding react dependency…
So… ATM
:`target :npm-module` works for cljs and npm dependencies from cljs but cannot import other local ts files.
:target :esm can do all the things but any external libraries used in cljs and ts would be duplicatedesm: which actively tells the compile to do nothing and emit the import as isesm:…esm: is a signal to the compiler to leave that import as is and NOT touch it at all"./src/ts/util.ts" tells the compiler to looks for that file and include it as part of the build just as any other CLJS or JS fileesm: leaves it as is parcel will find it and process itrequire('./src/ts/util.ts') not require('esm:./src/ts/util.ts') as parcel doesn’t know what to do with the esm prefix… so I think the esm prefix should signal to shadow-cljs to not do anything with the file but I don’t see how it is useful to emit require('esm:./src/ts/util.ts') since the esm prefix is only meaninful to shadow-cljsesm: as a standard loader prefix of some sort but its not clear to me what its meaning would be for something like parcel or webpack other than to strip it and resolve the nameesm: is only valid in :target :esm builds:npm-module you should go back to creating an alias for parcel. something I'd honestly always do for JS projects"my-project":"./src/ts" or so(:require ["my-project/util.ts"])@project or LOCAL or whatever else fits your style"@project/src/ts/util.ts""@project": "./src/""./src/src/ts/util.ts":target :esm config is entirely different than :target :npm-module. so :modules for examples does nothing:init-fn is also not supported by :npm-module{:output-dir "target/" :target :npm-module} thats basically the relevant part of the build config right now:npm-module is intergrating with other JS tools such as parcel:js-options {:js-provider :import} though to prevent bundling npm deps right?:npm-module never does that anyways:js-provider is an option but it defaults to :require which is what you want:import is indeed :esm only:runtime :browser in the build configif (process.env.NODE_ENV === 'development') { require("../path-to-output-dir/shadow.cljs.devtools.client.browser.js") }NODE_ENV and conditional require support:preloads is also not a thing for :npm-moduleshadow-cljs server running and then run shadow-cljs release app whenever you need it (or have another watch trigger it if you must){:infer-externs :auto} so I wrote {:infer-externs false} worked as I wanted but then I searched on github what are the valid values for :infer-externs` on documentation only refers to :all` and :auto so I tried random values like :none , :hello , true all worked same as false so what is the correct value to turn offfalse.(defmacro ...)?
I have two different builds (one for browser and one for node) and I would like to generate different code from the macro.:compiler-options similar to how cljs-devtools doesjscomp.inherit , which has come up on this channel before and apparently it's an issue with correct polyfill loading. I don't know if there's helpful information I can report?2.16.12 in an attempt to fix another issue.goog.iter.es6.js.:output-feature-set do you use? ideally you set :compiler-options {:output-feature-set :es8} (or higher if you can). then this error should disappear completely.npm i and npm start to get things running:
{
"private": true,
"scripts": {
"start": "npx shadow-cljs watch app" <=====================
},
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-refresh": "^0.8.1",
"react-router-dom": "^5.1.2",
"react-slider": "^1.3.1",
"shadow-cljs": "^2.8.94",
"todomvc-app-css": "^2.4.1",
"todomvc-common": "^1.0.5"
}
}
My deps.edn is
{:paths ["src" "src/demo" "src/mxreact"]
:deps {lilactown/helix {:mvn/version "0.1.1"}
binaryage/devtools {:mvn/version "0.9.7"}
thheller/shadow-cljs {:mvn/version "2.15.1"}
tiltontec/matrix {:mvn/version "4.1.7-SNAPSHOT"}
cljs-http/cljs-http {:mvn/version "0.1.46"}}}
The dependency not retrieved by the build is Matrix.
The build then complains about a Matrix namespace not being found. Inspection of .m2 confirms the deficit.
If I execute clojure -P the dependency is pulled from Clojars and the build succeeds. Yay.
My shadow-cljs.edn is :
;; shadow-cljs configuration
{:deps true
:builds
{:app {:target :browser
:output-dir "js"
:asset-path "/js"
:modules {:app {:entries [app.core]}}
:devtools {:http-root "."
:http-port 8888
:reload-strategy :full
:preloads [devtools.preload
demo.dev]}}}}
My app.core NS is:
(ns app.core
(:require
[tiltontec.model.core :as md]
[react]
[mxreact.mxreact :as mxr]
["react-dom" :as rdom]
[demo.demo :as dmo]
["react-slider" :default ReactSlider]
[tutorial.x100-hello-world.lesson :as app]
))
Can anyone see why clojure -P was needed to get the dependency downloaded? Or is that just part of the drill when new dependencies are added?
Thx! 🙏clojure does. if you set :deps true when running shadow-cljs watch app it will call clojure -M -m shadow.cljs.devtools.cli watch app and let clojure handle all dependency resolution and classpath creation. shadow-cljs will not attempt to download anything itself in that case. I do not know why it may not download something. In general I'd stay very far away from SNAPSHOT dependencies and instead use :local/root or :git/url if you candeps.edn does require a shadow-cljs restart. just leaving the watch running won't work.shared.js:1552 TypeError: Super expression must either be null or a function, not undefined
at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:44)
at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:32)
at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:1)
at Object.shadow$provide.module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
Here's how the import statement looks like
["react-leaflet-vectorgrid" :default VectorGrid]import VectorGrid from 'react-leaflet-vectorgrid';https://www.npmjs.com/package/react-leaflet-vectorgrid
:compiler-options {:output-feature-set :es-next} in your build config:compiler-options inside of (defmacro ...)? Say, I have {:compiler-options {:xyz "23"}}. What is the path to "23" in &env?@cljs.env/*compiler* :options is basically :compiler-options from your build confignpm start command indirectly starts a watch, but I control-c'ed it each time, once it announced the missing dependency.
Yes, I have :deps true in my shadow-cljs.edn,
I am surprised to hear SNAPSHOT is a bad idea. Is that not a standard part of the ecosystem? I have noticed they do not work as dynamically as is really needed for iterative devlopment.This could be a breakthru! 🙂
I never heard of :local/root or :git/url options. To what are those options? I'll look around.
I will also see what the clojure CLI crew has to say about dependency resolution.
Thx!:local/root and :git/url are tools.deps optionsnpm start does not imply that there is not a previous running servercontact-book.core/main which I can't call in my index.html script because js does not allow hyphens. Am I understanding that correctly? Wherever my main function is should not have a hyphenated namespace or am I doing something else wrong?contact-book.core/main will become contact_book.core.main in JS:dev-http {8081 "resources/public"
8444 {:root "resources/public"
:ssl true}}
I just get two http endpoints
I would expect to have to supply a jks keystore too...:dev-http {8081 {:root "resources/public"
:ssl-port 8444
:ssl true}}
doesn't seem to work eithernpx shadow-cljs watch fooperhaps
watch is not leveraging dev-http...?:ssl config in the top level? https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl:ssl true I don't see that documented anywhere in the user guide:ssl false for :dev-http where you can opt out of ssl for specific serversEnter the JavaScript object you want to extern: and I don’t really know what that question means:js-options fix it or what error did it reveal? where is the rest of the stacktrace?
AssertionError Assert failed: (map? rc) ...
(defn node-repl
[]
(shadow/node-repl {:config-merge [{:js-options {:js-package-dirs ["functions/node_modules"]}
,,,}]}))
Is this a valid thing to specify with node-repl? We’ve split our package.json between frontend/backend recently and it looks like the node REPL isn’t able to find packages that only exist in the backend node_modules.(shadow/node-repl {:pwd "functions"}) so it runs the node repl process in the functions dirnode won't find them at runtimejs-options one around too? just with :pwd I’m getting the same “cannot find module” errors as before:pwd isn’t working 😄node-repl that may still be running and running node-repl again may just have reused that process?(js/process.cwd) should tell you if :pwd worked:js-options you need to keep if you have any (:require [a-symbol-pointing-to-npm-package ...])(:require [react])react is actually meant to be a npm require if needs to check the package dirs(:require ["react"]) does not need that check since it knows that string requires are not valid for CLJS namespacesjs/process.env.PWDconfig-merge option instead of to shadow/node-repl directly--config-merge '{:closure-defines {shadow.cljs.devtools.client.env/log false}}'
I was expecting shadow-cljs: load JS something/something.cljs logging to go away after looking at what seems to be relevant source code, but it’s still there. Am I supposed to be able to control this?:devtools {:log false} in your build config (or merged)(defc ui-node [local?]
(bind {:keys [id data] :as props} (get-in @state-atom [:id 1]))
(bind local-data (when local? (atom data)))
(bind data (if local?
(g/watch local-data)
data))
...)
would get me in trouble, https://github.com/thheller/shadow-experiments/blob/master/doc/components.md the hook type changes if local? changes. What I'm trying to achieve: if local?, work with local state (initialized to the value of global state), else work with global state.(bind {:keys [id data] :as props} (get-in @state-atom [:id 1])) this should also never be done. that will only ever deref once so it'll never updates if you change the value in state-atom(bind {:keys [id data] :as props} (get-in @state-atom [:id 1]))
was a stand-in for a Fulcro hook. If I do a watch on state-atom then I'll chain two AtomWatches, which is a no-no 🙂
So, I can move my conditionals to render, though this means that
(bind local-data (atom data)) (bind local-data-watch (g/watch local-data))will initialize needlessly in instances where local state is not needed. I would also need to do
(bind local-data (atom (get-in @state-atom [:id 1 :data])))to avoid the
AtomWatch chaining, but that is what I want: I want to read this only on initialization of the instance.
It seems to me like local state is the right 'pattern' for what I need (state per component instance). Storing it in a central atom/db for each instance seems like overkill (would also have to handle component lifecycle). This is how I had it set up in Fulcro with initLocalState. Happy to hear suggestions on how to handle it differently 🙂:data attribute is stored in a central db. Depending on some conditions, instances of a component using this attribute should either:
1. share this value in the central db (i.e. read current value from and update it in central db)
2. or read and store the value only on component instance initialization, then only update the value tied to that instance. Remove the value (wherever it is stored) once the component instance is destroyed.:expanded-in-foo-context true :expanded-in-bar-context false:expanded-in-contexts #{:foo :bar} :expanded-for #{[:some/ident 1] [:other/ident 2]}:expanded for every component instance. There is absolutely no sharing (in certain contexts). The context simply defines whether the state should be shared globally, not what it should be.{id-of-component-instance {:expanded true}}.id-of-component-instance. there is id-your-created-in-data-somewhere that is passed to your defc component as a prop"5.1.0" was required by jar:file:/Users/rick/.m2/repository/com/kiranshila/cybermonday/0.3.139/cybermonday-0.3.139.jar!/deps.cljs NPM dependency "remark-parse" has installed version "9.0.0"I confess the relationship between npm/yarn/shadow-cljs/clojurescript and clojurescript deps from mvn etc isn’t exactly clear to me
package.json2.15.12 without getting test failures.
I’m not sure what happened in 2.15.13 that is causing them but I’m assuming it’s somehow related to the closure/clojurescript version bump and perhaps I need to do something with the flag :global-goog-object&array :thinking_face::nrepl false and :socket-repl false in your shadow-cljs.edn config?(start! {:nrepl false :socket-repl false}) yes but note that pretty much all in shadow-cljs assumes the presence of a shadow-cljs.edn. so if you attempt to make that not a thing you will lose features 🙂(-> (config/load-cljs-edn)
(assoc :socket-repl false :nrepl false)
(server/start!))config being shadow.cljs.devtools.config(start!) without args(config/load-cljs-edn) has those defaults merged in/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} cider/cider-nrepl {:mvn/version "0.24.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl", "shadow.cljs.devtools.server.nrepl/middleware"]'.nrepl.edn also works I believe. just need to add the shadow.cljs.devtools.server.nrepl/middleware middleware ns somehowpackage.json ever?npm install <packages> where packages comes from your dependencies declaring :npm-deps.package-lock.json in version controlpackage.json yourself.npx shadow-cljs watch app , but I want to run it in the background. How do I do that?& at the end of the command. But in practice i like having it in the foreground so i can easily stop, see compiler output, etc. so i prefer to just use a dedicated terminal tab for itnpx shadow-cljs node-repl and eval that presumably the output will show up in the terminal?❯ npx shadow-cljs node-repl
shadow-cljs - config: /Users/dan/projects/work/metabase/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> shadow-cljs - #5 ready!
cljs.user=> (let [tn (js/setTimeout #(println "hello") 1000)]
(println tn))
#object[Timeout 52]
nil
cljs.user=> helloMultiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "dataico/model/bank.cljc"] still waiting for #{dataico.model.payment}
I’m getting these in my CI system, but the compile is fine locally.
No other info. The exception does not show a cause.par-compile is the parallel compile and threads wait if dependencies they need are still compiling. after 60sec they abort since that usually means something went wrong and compilation cannot finish. is there something in dataico.model.payment that might cause a huge wait time? eg. some macro expanding into something gigantic or just taking very long?:build-options {:par-timeout 120000} to increase the timeout to 2min (its msec) but unlikely that changes much unless you CI system is running on a toaster 😉[:app] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/Users/rqf595/.m2/repository/thheller/shadow-cljs/2.16.12/shadow-cljs-2.16.12.jar!/shadow/remote/runtime/obj_support.cljc:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.remote.runtime.obj-support -------^------------------------------------------------------------------------ Invalid :refer, var cljs.repl/error->str does not exist -------------------------------------------------------------------------------- 2 | (:require 3 | [clojure.datafy :as d] 4 | [clojure.pprint :refer (pprint)] 5 | [clojure.spec.alpha :as spec] --------------------------------------------------------------------------------
[2022-01-13 15:53:12.679 - INFO] duplicate resource goog/....shadow-cljs clj-repl and ( "cljs/repl.cljs"). I'm guessing that is not yielding the expected clojurescript jarshadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.16.12 running at shadow-cljs - nREPL server started on port 57233 shadow-cljs - REPL - see (help) To quit, type: :repl/quit shadow.user=> ( "cljs/repl.cljs") #object[java.net.URL 0x418341f9 "jar:file:/Users/rqf595/.m2/repository/com/owoga/tightly-packed-trie/0.2.3/tightly-packed-trie-0.2.3.jar!/cljs/repl.cljs"] shadow.user=>
[2022-01-14 09:31:54.403 - INFO] duplicate resource goog/mochikit/async/deferred.js on classpath, using jar:file:/Users/rqf595/.m2/repository/com/owoga/tightly-packed-trie/0.2.3/tightly-packed-trie-0.2.3.jar!/goog/mochikit/async/deferred.js over jar:file:/Users/rqf595/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20211011-0726fdeb/google-closure-library-third-party-0.0-20211011-0726fdeb.jar!/goog/mochikit/async/deferred.jsand similar messages before it.
tightly-packed-trie is overruling my ClojureScript version? Shouldn’t it be using the most recent version when there’s a conflict…?tightly-packed-trie is actually itself containing the cljs sources and others it shouldn't contain:backend alias in your shadow-cljs.edn? :deps {:aliases [:frontend :backend :test]}?2.16.12
fs.readFile to cljs seems to be not as straight forward (I think I'm missing something):
(ns ...
(:require ...
["fs" :as fs]))
(fs/readFile ...)
doesn't seem to work: react-dom.development.js:11341 Uncaught TypeError: shadow$empty.readFile is not a function
What am I missing? (I'm using shadow-cljs, obviously and I'm using cljs with a browser target)import { TemplateHandler } from 'easy-template-x';
const response = await fetch('');
const templateFile = await response.blob();
const data = {
posts: [
{ author: 'Alon Bar', text: 'Very important\ntext here!' },
{ author: 'Alon Bar', text: 'Forgot to mention that...' }
]
};
const handler = new TemplateHandler();
const doc = await handler.process(templateFile, data);
Somehow, whenever I fetch a docx template, it seems it's not valid docx.
(-> (fetch/get filePath {:headers {:accept "application/vnd.openxmlformats-officedocument.wordprocessingml.template"} })
(.then (fn [response] (:body response)))
(.then (fn [template]
(.process templateHandler template #js{}) ))
results in:
Uncaught (in promise) Error: Malformed file detected. Make sure the file is a valid docx file.
It's a fresh docx file. I suppose there's something wrong with fetching and reading it. It doesn't matter how, but did anyone ever generate a docx in-browser (from a template)?Zip.load line fails. It fails when I fetch it first, so there must be something in making the response a valid zip.
async loadDocx(file) {
// load the zip file
let zip;
try {
zip = await Zip.load(file);
} catch (_unused) {
throw new MalformedFileError('docx');
} // load the docx filejs/fetch:
(-> (js/fetch filePath)
(.then (fn [response]
(.blob response)))(.then (fn [response] (:body response))) this doesn't work because response is a JS object and keyword looks only work for clojure maps(:body response) returned something, but not something valid 🙂 . Just plain js interop seems to work fine..blob doesn't exist in the library.:external JS provider and configured Webpack for the final bundle phase. I have one dependency that relies on React and ReactDOM (both v16.x) among others. However, when I release the build with shadow-cljs, I get the following warning:
> shadow-cljs release web (...) [:web] Compiling ... ------ WARNING #1 - ----------------------------------------------------------- Resource: shadow.js.shim.module$react_dom.js:3:34 variable shadow$bridge is undeclared -------------------------------------------------------------------------------- nil [:web] Build completed. (...)Am I missing something in this configuration? I'm using shadow-cljs v2.16.12. You can get more details from this Github issue: https://github.com/thheller/shadow-cljs/issues/978 Looking up in this channel, I found someone that got the same warning https://clojurians.slack.com/archives/C6N245JGG/p1632299596117200, but I couldn't find any more references on this matter. Thanks for your time reading this report.
shadow-cljscli to write the output of shadow-cljs pomto a different file than pom.xml?artifactId and groupId it generates from? right now it's groupId=artifactId=directoryName it seems? can this be changed?NullPointerException: NAME module$contents$goog$testing$storage$FakeMechanism_FakeMechanism 94:10 [length: 13] [source_file: goog/testing/storage/fakemechanism.js] [original_name: FakeMechanism]
NullPointerException: NAME module$contents$goog$testing$storage$FakeMechanism_FakeMechanism 94:10 [length: 13] [source_file: goog/testing/storage/fakemechanism.js] [original_name: FakeMechanism] com.google.common.base.Preconditions.checkNotNull (Preconditions.java:897) com.google.javascript.jscomp.RemoveUnusedCode.getVarForNameNode (RemoveUnusedCode.java:895) com.google.javascript.jscomp.RemoveUnusedCode.traverseNameNode (RemoveUnusedCode.java:751) com.google.javascript.jscomp.RemoveUnusedCode.traverseNode (RemoveUnusedCode.java:571) com.google.javascript.jscomp.RemoveUnusedCode.traverseChildren (RemoveUnusedCode.java:1305) com.google.javascript.jscomp.RemoveUnusedCode.traverseNode (RemoveUnusedCode.java:581) com.google.javascript.jscomp.RemoveUnusedCode.access$1200 (RemoveUnusedCode.java:83) com.google.javascript.jscomp.RemoveUnusedCode$Continuation.apply (RemoveUnusedCode.java:1829) com.google.javascript.jscomp.RemoveUnusedCode.traverseAndRemoveUnusedReferences (RemoveUnusedCode.java:412) com.google.javascript.jscomp.RemoveUnusedCode.process (RemoveUnusedCode.java:386) com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317) com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:462) com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232) com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592) com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966) com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127) com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014) com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963) com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:905) jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:564) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) shadow.build.closure/compile-js-modules (closure.clj:1102) shadow.build.closure/compile-js-modules (closure.clj:1088) shadow.build.closure/optimize/fn--12464 (closure.clj:1297) shadow.build.closure/optimize (closure.clj:1283) shadow.build.closure/optimize (closure.clj:1274) shadow.build.api/optimize (api.clj:273) shadow.build.api/optimize (api.clj:267) shadow.build/optimize (build.clj:476) shadow.build/optimize (build.clj:468) shadow.cljs.devtools.api/release* (api.clj:339) shadow.cljs.devtools.api/release* (api.clj:324) shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28) shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25) shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49) shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38) shadow.cljs.devtools.cli-actual/main/body-fn--17177--auto----17893 (cli_actual.clj:166) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132) clojure.core/apply (core.clj:671) clojure.core/apply (core.clj:662) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:667) clojure.core/apply (core.clj:662) shadow.cljs.devtools.cli/-main (cli.clj:75) shadow.cljs.devtools.cli/-main (cli.clj:67) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:667) clojure.main/main-opt (main.clj:514)§ clojure.main/main-opt (main.clj:510) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)
.shadow-cljs/builds/<your-build-id> and recompile. please let me know if that fixes it:dev-http instead(def x (js/WebSocket. ..) then yes that'll disconnect by design, defonce might help{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[better-cond "2.1.0"]
[binaryage/oops "0.7.0"]
[camel-snake-kebab "0.4.2"]
[data.deque "0.1.0"]
[instaparse "1.4.10"]
[metosin/potpuri "0.5.3"]
[com.rpl/specter "1.1.3"]
[net.cgrand/xforms "0.19.2"]
[org.clojure/algo.monads "0.1.6"]
[org.clojure/core.match "1.0.0"]
[org.clojure/test.check "1.1.1"]]
:builds
{:main {:target :node-library
:output-to "out/yadayada.js"
:exports {:createParser yadayada.core/create-parser}}
:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun false}}
:nrepl {:port 8777}
:open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}cljs.user> (nw/number-lookahead "one")
"one"
cljs.user> (nw/parse frame)
; unexpected result, make minor change
; like adding a tap> call
[:main] Compiling ...
[:main] Build completed. (82 files, 2 compiled, 0 warnings, 2.19s)
cljs.user> (nw/number-lookahead "one")
Execution error (TypeError) at (<cljs repl>:1).
yadayada.number-words/number-lookahead is not a function
At that point, everything is messed up. In this example number-lookahead is an IFn. I can see it's value but it no longer produces invoke just an error when used as a fn. Some functions or constants are seemingly inaccessible. Often, after the compile, nothing works, but it varies.
I have noticed that the watch is not recompiling most of the time. The problems start when it does, but it seems odd in retrospect that the recompiles are so inconsistent.
I'll grab a shot of everything that happens next time, though I'm not sure it will be much more. I'm monitoring the nrepl messages to see if something shows up there. I can work for a random stretch making changes without any recompiles and then suddenly it happens. There's a loose association with adding in tap> calls, but that neither makes sense as an explanation nor is definitive. I'm really not sure how to get a lead here.
Again, I really appreciate the help and reply. Thanks. Let me know how I can further clarify. Sorry it's so vague...node-repl or browser-repl when doing mostly REPL driven stuff. the hot-reload tends to get in the way and is sort of at odds with the REPLdefn to a def with IFn maybe?:node-library build so no browsertap> and Inspect instead if pprint so that doesn't have that issue?(tap> value) and it'll show up in the inspect ui, usually available at http://localhost:9630/inspect(def main-js
"When making a release, the filename will be appended with a hash;
that is not the case when running the regular shadow-cljs watch process.
Relies on the :module-hash-names being set to true in shadow-cljs.edn."
(if-let [url (io/resource "public/js/compiled/manifest.edn")]
(-> url slurp edn/read-string first :output-name)
"main.js"))
(def development?
"Source of truth for whether this is a development build or not. "
(= main-js "main.js"))
goog/DEBUG?:release. see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration:closure-defines abovenpx shadow-cljs clj-repl --config-merge '{:jvm-opts ["-Duser.home=blah"]}'project.clj is not part of a distributed package. it is only used to generate pom.xml which actually drives the maven distribution. so the :npm key does absolutely nothing since it is not transfered to pom.xmldeps.cljs file with {:npm-deps {"foo" "1.2.3"}} which would make shadow-cljs run npm install on compile(let [p ^js (<p! (current-authenticated-user))
email (.. p -attributes -email)
first-name (.. p -attributes -given_name)
last-name (.. p -attributes -family_name)]
(log/debug "werker-session" email first-name last-name)
{:werker-session
{:werker/id tid
:werker/email email
:werker/first-name first-name
:werker/last-name last-name
:werker/status :signed-in}})
Which generates these errors:
Cannot infer target type in expression (. inst_60203 -given_name) Cannot infer target type in expression (. inst_60205 -family_name)The code works just fine. I tried everything I read on Google, to no avail. Any suggestions? Thanks in advance! Actually here’s the body of the code:
(go
(let [tid (tempid/tempid)]
(try
(let [p ^js (<p! (current-authenticated-user))
email (.. p -attributes -email)
first-name (.. p -attributes -given_name)
last-name (.. p -attributes -family_name)]
(log/debug "werker-session" email first-name last-name)
{:werker-session
{:werker/id tid
:werker/email email
:werker/first-name first-name
:werker/last-name last-name
:werker/status :signed-in}})
(catch js/Error err
(log/error "init-werker-session error" err)
{:werker-session
{:werker/id tid
:werker/email ""
:werker/first-name ""
:werker/last-name ""
:werker/status :not-signed-in}}))))go function.go. ^js hints are lost in most places and generates a lot more code than it would outside gogo can’t be moved outside thought.^js did the trick.shadow$empty.readFileSync is not a function what is this error message?(shadow.cljs.devtools.api/repl :app)
:target for :app in your shadow-cljs.edn?fs node module. It is only available in node and you are running in a browserSHADOW import error /Users/kurt.harriger/projects/Logseq-Things-3-Plugin/shadow-electron-starter/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
App threw an error during load
/Users/kurt.harriger/projects/Logseq-Things-3-Plugin/shadow-electron-starter/node_modules/ws/lib/websocket.js:414
...options
^^^
SyntaxError: Unexpected token ...
It appears that the ws module in previous version was 3.3.3 and is now updated to 7.5.6 and this new version seems to use es6 spread syntax that the old version did not.
Oddly if I run npm run build and then electron . it still works but seems dev build doesn’t work.
Any ideas? I guess I could fork ws and add a bunder step to ensure it exports es5 but I’m confused why upgrading shadow-cljs would pull in new ws version if shadow-cljs didn’t support it and why a release bulid works but dev build does not? maybe there is an option that needs added to the config?node -v?"dependencies": {
"electron": "^16.0.7",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"shadow-cljs": "^2.16.12"
}
node version v16.13.0npm install electron-prebuilt -g npm install shadow-cljs -g
npx electron and npx shadow-cljs. that'll use the version installed in the project and not some global:esm and runtime :node?
The build configuration:
{:target :esm
:js-options {:js-provider :import}
:runtime :node
:output-dir "out/esm"
:modules
{:script {:entries [my.script.core]
:exports {init my.script.core/init}}}}
The output produced by npx shadow-cljs watch ... for this build seems to not connect to the server and node out/esm/script.js exists immediately.
I have tried to make it connect to the server by requiring the namespace shadow.cljs.devtools.client.node in my.script.core .
But then running the output with node ... reports the following error:
var socket = (new shadow.esm.esm_import$ws(ws_url,({"rejectUnauthorized": false})));
^
TypeError: shadow.esm.esm_import$ws is not a constructor
at shadow$cljs$devtools$client$node$start (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.node.js:122:15)
at Object.attempt_connect_BANG_ (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
at file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.node.js:431:36node-script as a target but that doesn't seem to be an option with some npm packages that are ESM only (e.g., the latest version of chalk).:esm yet. you can try setting :runtime :custom :devtools {:client-ns some.ns} where some.ns is just a copy of https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs with the ["ws" :as ws] changed to ["ws$default" :as ws]. maybe thats enough?SHADOW_IMPORTED and SHADOW_IMPORT. It looks like these are defined in node_bootstrap.txt for node targets. It seems shadow/boot/esm.js is supposed to replace (some of) that. I have tried to fix these errors. It seems to work alright so far but it is clearly a nasty hack:
;; these implementations replace the first three functions in shadow.cljs.devtools.client.node
(defn node-eval [{:keys [js source-map-json] :as msg}]
(let [result (js* "(0,eval)(~{});" js)]
result))
(defn is-loaded? [src]
(true? (js/SHADOW_ENV.setLoaded src)))
(defn closure-import [src]
{:pre [(string? src)]}
(js/console.log src)
(when-not (= src "goog.base.js")
;; goog base doesn't work with this kind of import?
(js/globalThis.shadow_esm_import (str "./cljs-runtime/" src)))
(js/SHADOW_ENV.setLoaded src))
;; this interface implementation replaces the current one for the type cljs-shared/Runtime
api/IEvalJS
(-js-eval [this code]
(js* "(0,eval)(~{});" code))
node impl assumes it can do sync imports but the shadow_esm_import is async so all of the code needs to be adjusted to not assume syncfs/readFileSync and then eval'ingimport statements. I opened https://github.com/thheller/shadow-cljs/issues/979"./cljs-runtime" to src seems especially fragile. Is there a better way to do that?ReferenceError: window is not defined
at [path]/.shadow-cljs/builds/test/dev/out/cljs-runtime/accountant/core.cljs:21:35
at [path]/.shadow-cljs/builds/test/dev/out/cljs-runtime/accountant.core.js:16:3
at global.SHADOW_IMPORT ([path]/target/test/test.js:64:44)
at [path]/target/test/test.js:1701:1
at Object.<anonymous> ([path]/target/test/test.js:1781:3)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
===============================================window or js/window?js/window. so it just isn't compatible with anything that doesn't have that. from the looks of it there are many other things that expect a full browser@react-three/fibre or @react-three/drei is enough to get this error.
Closure compilation failed with 2 errors --- node_modules/three-stdlib/index.cjs.js:2 Illegal variable reference before declaration: i --- node_modules/three-stdlib/index.cjs.js:2 Illegal variable reference before declaration: t
:js-options { :resolve {"three-stdlib" {:target :file :file "node_modules/three-stdlib/index.js"}
"@react-three/drei" {:target :file :file "node_modules/@react-three/drei/index.js"}
"@react-three/fiber" {:target :file :file "node_modules/@react-three/fiber/dist/react-three-fiber.esm.js"}}}:preprocess option for foreign libs in clojurescript compiler. Are there any plans to leverage that for npm libs in shadow-cljs?electron work with lmdbnodeIntegratrion it should work also on the renderer processnode_modules/ag-grid-enterprise/ag-grid.js for example, but either that or trying to use the full path doesn't worknpx shadow-cljs cljs-repl foo` to connect to one of them.
Is there an easy way to swith to a repl on the other browser?shadow-cljs clj-repl and then (shadow/repl :foo {:runtime-id 123}) where the runtime id is either listed here http://localhost:9630/runtimes or in the browser console on start shadow-cljs: #3 ready!:cljs/quit drops you back down to the clj repl. so you can switch between the runtimes if neededgit clean -fdx and reinstalled d3 through npm.lein shadow watch app but I still get errors in the console. Anyways, if this is unrelated to shadow-cljs I'll try to google more myself 🙂(:require ["regenerator-runtime/runtime"]) somewhere before you require the npm lib causing the problem2.12.1 seems to be from April last year. I'll try upgrading.shadow-cljs in embedded mode from a build.clj.
Here’s what I’m running, I arrived at this by digging around the https://shadow-cljs.github.io/docs/UsersGuide.html#embedded of the docs, as well as https://github.com/thheller/shadow-cljs/issues/490.
(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/compile*
{:target :browser
:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"}
{})
…Running clj -M build.clj, I get a error:
Jan 27, 2022 9:45:35 AM io.undertow.Undertow start INFO: starting server: Undertow - 2.2.4.Final Jan 27, 2022 9:45:35 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.8.0.Final Jan 27, 2022 9:45:35 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.8.0.Final Jan 27, 2022 9:45:35 AM org.jboss.threads.Version <clinit> INFO: JBoss Threads version 3.1.0.Final shadow-cljs - server version: 2.16.12 running at shadow-cljs - nREPL server started on port 54818 [null] Compiling ... Syntax error (AssertionError) compiling at (build.clj:28:1). Assert failed: (keyword? build-id)I’d really like to be able to pass the build configuration right in my
build.clj. Does anyone see what I’m doing wrong?:build-id :app or something needs to be in that map:target :browser. :main does not apply there.(shadow.cljs.devtools.api/compile*
{:build-id :app
:target :browser
:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"}
{}):modules:output-to also does nothing. :modules {:main {:entries [hello-world.core]}} will create a main.js in :output-dirmain.js in my :ouput-dir. Is that default/fixed behavior?:output-to, as you mentioned):main module produces main.js in :output-dircompile though? watch and release are the common ones, compile is kinda rare?compile caught my eye first. What’s the different from release?release creates a optimized release build. compile creates an unoptimized development build, same as watch just without the watch parts (no hot-reload, REPL, etc)watch. compile is not designed for it and will not work.watch just loads it once and keeps it in memory making incremental compiles rather fast:type java.lang.AssertionError, :message \"Assert failed: (set? ns-roots)\", :at [shadow.build.cljs_hacks$shadow_find_ns_starts_with invokeStatic \"cljs_hacks.cljc\" 645]}],
shadow-cljs… I’m just toying around and trying to replace the functionality with other standard Clojure tools for learning purposes.
(clojure.core.server/start-server
{:accept 'cljs.core.server/io-prepl
:address "127.0.0.1"
:port 6776
:name "build"
:args [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
:server-daemon false})
(org.httpkit.server/run-server
(compojure.core/routes
(compojure.route/files "/" {:root "public"}))
{:port 8000})
(cljs.build.api/build ;; or watch with path
{:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"})
(println "Now connect through inf-clojure to port 6776.")
(println "Then, refresh the web page.")(clojure.core.server/start-server
{:accept 'cljs.core.server/io-prepl
:address "127.0.0.1"
:port 6776
:name "build"
:args [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
:server-daemon false})
(org.httpkit.server/run-server
(compojure.core/routes
(compojure.route/files "/" {:root "public"}))
{:port 8000})
(cljs.build.api/build ;; or watch with path
{:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"})cljs.build.api/build to find my npm dependencies. shadow-cljs is so, so good at that, I was hoping there’d be an easy way to just “swap out” those compile calls.:prepl {12345 :app} and that will give a a prepl on port 12345 for build :app (all in shadow-cljs.edn of course):npm-deps on the ClojureScript compiler would work properly….shadow-cljs always solve the problem. Should the caches from different build be separated?.shadow-cljs and I don't hear much of others doing that. what issues are you running into? deleting the caches should absolutely not be happening and caches are already separated, so they cannot affect each other.$arr is not definded, $cljs is not defined.:output-dir). outputting into the same directory may cause files to be overridden and as such cause issuesresources/public/js and resources/public/js/workspaces.watch files and watch may overwrite the release filesshadow-cljs watch app and then shadow-cljs release app may interfere with each other.shadow-cljs would not do anything other than cause a rebuildsources and sourcesContent so it should be all fine assuming all the paths map and such.m2, so I don't know where that info would come from:source-map-use-fs-paths true, which you definitely should not be setting for browser builds.css files). Is there a way to access this information from a build hook - either from the build state or the general clojure environment? Or do I need to get the src dirs and read them myself?
EDIT I sole and adopted a function from shadow.build.classpath which seems to do exactly what I want. Let me know if there is a better way out there thought!
(defn classpath-files
"searches classpath source source files"
[build]
(let [cp (:classpath build)]
(for [^File cp-entry (classpath/get-classpath-entries cp)
:when (and (.isDirectory cp-entry)
(not (classpath/is-gitlib-file? cp-entry)))
:let [root-path (.toPath cp-entry)]
^File file (file-seq cp-entry)
:when (not (.isHidden file)
:let [file-path (.toPath file)
resource-name (-> (.relativize root-path file-path)
(.toString)
(rc/normalize-name))]
:when (not (classpath/should-ignore-resource? cp resource-name))]
resource-name)))remote-relay?.... What can I do to make it quicker? Here is my network:path/to/dir and have it load the index.js file at that path? In other words, I’m trying to override what happens when shadow detects a directory path? It currently fails and throws FileNotFoundException with a note that it’s a directory.
I’m trying to compile an existing js project, but webpack handles that situation by default so I need a way to replicate that behavior:require-macros section rather than the :require section as it should (presumably because it was first). There were a couple of these, and when I removed them the problem went away. When I put them back, the problem returned. I don't understand why that would produce the problems I saw, but the causality seems pretty clear. Thanks again for all your help; I very much appreciate it!clj -M:shadow-cljs clj-repl then running (shadow/watch :app). I like having that repl there. What is the best way to go about adding functions to this namespace? Can I somehow provide my own namespace and just require the functions that shadow.user does and add my own?:nrepl {:init-ns phrasing.user} to my shadow-cljs.edn and tried adding {:repl-init-ns phrasing.user} to :builds :app :devtools:repl {:init-ns phrasing.user} as well(require 'phrasing.user) (in-ns 'phrasing.user):nrepl
{:extra-deps {nrepl/nrepl {:mvn/version "0.9.0"}}
:main-opts ["-m" "nrepl.cmdline"
"--connect"]}}}
which loads in the user namesapce. I tried lein repl :connect and that seems to have worked! So thank you!!
Do you happen to know why the clojure.tools version isn’t working?user> as the prompt. After the first command it prints my designated namespace:compile-prepare). I update [shadow.build/config :modules :main :entries] and add the clojure namespaces there. I can confirm they are both on my build path and in the build config. However, when I make changes to these files, shadow-cljs does not recompile.
1. Is there something I need to do to add them to the watch?
2. The eventual goal is to set up different modules, but I was going for MVP by adding them to entries. Would it be possible to dynamically load different modules from a build hook?
For context, I’m trying to set up something similar to next.js with directory based routing. So as I add more files, I read the classpath, build all the route into, then add files to the build. Modules would be great for code-splitting in the future but not needed for now:target. build hooks are definitely not meant to do any additional compilation and are not setup to do soshadow-cljs.edn file and run the watch command with nodemon - sounds like that might be the fastest solution?
In the meantime do you have any info on writing a custom :target? I assume you mean a build would have :target :custom-browser ?:browser you also picked the most complex one 😛:node-script is much simpler:shadow.build/stage where the target impl can decide what it needs to do:node-library generates a source and adds it to the build https://github.com/thheller/shadow-cljs/blob/8b7f3964e732bc13a9981ba390908dd90f70f2e0/src/main/shadow/build/targets/node_library.clj#L88-L103:modules at all and instead generate it{:target :browser :modules {:main {:init-fn }}} and then you generate either or some file it includesdefn and put some metadata on itns itself could also have metadata if needed:browser build, nothing is ever generated elsewhere:modules but it doesn't need to berequiremanifest.cljs with a bunch of require statements[shadow.cljs.ui.db.*] would make me feel extremely dirty 😛(:require [my.app.routes]) and then you generate (ns my.app.routes (:require [my.app.route-a] [my.app.route-b])) with some tool?pre-compile stage, and it would generate that new file?npm install captain-cljs npx captain-cljs start mkdir -p src/pages echo "(ns pages.index) (defn +render [] [:div :hello-world])" > src/pages/index.cljs
create-react-app users that came to CLJS and didn't have a single clue how react actually workscaptain-cljs, I’m sure I’ll post here with questions and updatesshadow.cljs.devtools in my code (to start a shadow-cljs server and watch a target), I get errors like these:
; Syntax error compiling at (shadow/build/js_support.clj:1:1). ; namespace 'shadow.build.closure' not foundand:
; Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2). ; Could not initialize class com.google.javascript.jscomp.DiagnosticGroupsDoes this sound familiar to anyone?
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups exception:frontend and :backend or whatever:backend deps in the root :deps and then adding CLJS stuff via alias is bad(defn run-in-repl []
(server1/start)
(server2/start)
(shadow.cljs.devtools.server/start!)
(shadow-watch :frontend)
:ready)clojure.lang.Compiler/analyze (Compiler.java:6812) clojure.lang.Compiler$InvokeExpr/parse (Compiler.java:3824) clojure.lang.Compiler/analyzeSeq (Compiler.java:7113) clojure.lang.Compiler/analyze (Compiler.java:6793) clojure.lang.Compiler$BodyExpr$Parser/parse (Compiler.java:6124) clojure.lang.Compiler$FnMethod/parse (Compiler.java:5471) clojure.lang.Compiler$FnExpr/parse (Compiler.java:4033) clojure.lang.Compiler/analyzeSeq (Compiler.java:7109) clojure.lang.Compiler/analyze (Compiler.java:6793) clojure.lang.Compiler/eval (Compiler.java:7178) clojure.core/eval (core.clj:3202) clojure.core/eval (core.clj:3198) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87) clojure.core/apply (core.clj:667) clojure.core/with-bindings* (core.clj:1977) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87) clojure.main/repl (main.clj:437) clojure.main/repl (main.clj:458) clojure.main/repl (main.clj:368) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:84) nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:56) nrepl.middleware.interruptible-eval/interruptible-eval (interruptible_eval.clj:152) nrepl.middleware.session/session-exec (session.clj:218) nrepl.middleware.session/session-exec (session.clj:217) java.lang.Thread/run (Thread.java:833)
clj with whatever aliases you have(require 'shadow.cljs.devtools.api)user=> (require 'shadow.cljs.devtools.api) Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2). Could not initialize class com.google.javascript.jscomp.DiagnosticGroups user=>
*e#error {
:cause "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "Syntax error macroexpanding at (closure.clj:77:5)."
:data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
:at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
{:type java.lang.NoClassDefFoundError
:message "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:at [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]}]
:trace
[[jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
[jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
[java.lang.reflect.Method invoke "Method.java" 568]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7186]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[shadow.build.js_support$eval15994$loading__6737__auto____15995 invoke "js_support.clj" 1]
[shadow.build.js_support$eval15994 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval15994 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[shadow.build.resolve$eval14164$loading__6737__auto____14165 invoke "resolve.clj" 1]
[shadow.build.resolve$eval14164 invokeStatic "resolve.clj" 1]
[shadow.build.resolve$eval14164 invoke "resolve.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build.api$eval14156$loading__6737__auto____14157 invoke "api.clj" 1]
[shadow.build.api$eval14156 invokeStatic "api.clj" 1]
[shadow.build.api$eval14156 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build$eval13806$loading__6737__auto____13807 invoke "build.clj" 1]
[shadow.build$eval13806 invokeStatic "build.clj" 1]
[shadow.build$eval13806 invoke "build.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 3204]
[shadow.cljs.devtools.api$eval5278$loading__6737__auto____5279 invoke "api.clj" 1]
[shadow.cljs.devtools.api$eval5278 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval5278 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval5274 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval5274 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.core$eval invoke "core.clj" 3198]
[nrepl.middleware.interruptible_eval$evaluate$fn__976$fn__977 invoke "interruptible_eval.clj" 87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1977]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1977]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[nrepl.middleware.interruptible_eval$evaluate$fn__976 invoke "interruptible_eval.clj" 87]
[clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
[clojure.main$repl$fn__9119 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl doInvoke "main.clj" 368]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84]
[nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
[nrepl.middleware.interruptible_eval$interruptible_eval$fn__1007$fn__1011 invoke "interruptible_eval.clj" 152]
[clojure.lang.AFn run "AFn.java" 22]
[nrepl.middleware.session$session_exec$main_loop__1075$fn__1079 invoke "session.clj" 202]
[nrepl.middleware.session$session_exec$main_loop__1075 invoke "session.clj" 201]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 833]]}
user=>( "com/google/javascript/jscomp/DiagnosticGroups.class")#object[java.net.URL 0x736dd229 "jar:file:/Users/stefanmm/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20211006/closure-compiler-unshaded-v20211006.jar!/com/google/javascript/jscomp/DiagnosticGroups.class"]
( "shadow/build.clj")#object[java.net.URL 0x60101212 "jar:file:/Users/stefanmm/.m2/repository/thheller/shadow-cljs/2.16.12/shadow-cljs-2.16.12.jar!/shadow/build.clj"]
Clojure 1.10.3
user=> (require 'shadow.cljs.devtools.api)
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.deps.ModuleLoader/createRootPaths (ModuleLoader.java:257).
'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
user=> *e
#error {
:cause "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "Syntax error macroexpanding at (closure.clj:77:5)."
:data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
:at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
{:type java.lang.NoSuchMethodError
:message "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
:at [com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]}]
:trace
[[com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 147]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 48]
[com.google.javascript.jscomp.deps.ModuleLoader$Builder build "ModuleLoader.java" 139]
[com.google.javascript.jscomp.deps.ModuleLoader <clinit> "ModuleLoader.java" 408]
[com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 182]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
[jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
[jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
[java.lang.reflect.Method invoke "Method.java" 568]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7186]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[shadow.build.js_support$eval10891$loading__6737__auto____10892 invoke "js_support.clj" 1]
[shadow.build.js_support$eval10891 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval10891 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 619]
[shadow.build.resolve$eval9061$loading__6737__auto____9062 invoke "resolve.clj" 1]
[shadow.build.resolve$eval9061 invokeStatic "resolve.clj" 1]
[shadow.build.resolve$eval9061 invoke "resolve.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build.api$eval9053$loading__6737__auto____9054 invoke "api.clj" 1]
[shadow.build.api$eval9053 invokeStatic "api.clj" 1]
[shadow.build.api$eval9053 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 2793]
[shadow.build$eval8682$loading__6737__auto____8683 invoke "build.clj" 1]
[shadow.build$eval8682 invokeStatic "build.clj" 1]
[shadow.build$eval8682 invoke "build.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 3204]
[shadow.cljs.devtools.api$eval153$loading__6737__auto____154 invoke "api.clj" 1]
[shadow.cljs.devtools.api$eval153 invokeStatic "api.clj" 1]
[shadow.cljs.devtools.api$eval153 invoke "api.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7170]
[clojure.lang.Compiler load "Compiler.java" 7640]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$load_one invoke "core.clj" 5892]
[clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
[clojure.core$load_lib invokeStatic "core.clj" 5936]
[clojure.core$load_lib doInvoke "core.clj" 5917]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 5974]
[clojure.core$load_libs doInvoke "core.clj" 5958]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 5996]
[clojure.core$require doInvoke "core.clj" 5996]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval149 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval149 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.core$eval invoke "core.clj" 3198]
[clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
[clojure.main$repl$fn__9119 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl_opt invokeStatic "main.clj" 522]
[clojure.main$main invokeStatic "main.clj" 667]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}com.google.common.collect is in guava I assume?Error: Namespace "goog.debug.Error" already declared.
at Object.goog.module (webpack-internal:///./cljs/cljs_env.js:163:13)
at eval (webpack-internal:///./cljs/cljs_env.js:1891:8)
at Object.goog.loadModule (webpack-internal:///./cljs/cljs_env.js:404:27)
at eval (webpack-internal:///./cljs/cljs_env.js:1888:6)
I’ve seen similar issues other people have posted about and they all seem related to producing two cljs builds. This is not my current scenario, but rather using it in a js ecosystem with React Fast Refresh. Any tips on how to fix or debug here?goog.debug.Error twice since that definitely never changes between compilesNamespace "goog.debug.Error" already declared, same error happens if there is more than one page and in that case, it happens during the compilation already.goog.provide does as shown in the link above?2.6.10, but as soon as I update the version, I'm using 2.19.8 now, I start to get the error above.next-cljs example repo you linked above. none. it will trigger a re-compile and I suspect that next is doing the hot-reload?import "../src/cljs/shadow.cljs.devtools.client.browser.js") here https://github.com/nathanqueija/next-cljs/blob/master/src/main/shadow/next_js.clj#L30error - src/cljs/shadow.cljs.devtools.client.websocket.js (26:14) @ shadow$cljs$devtools$client$websocket$start
error - ReferenceError: WebSocket is not defined
at shadow$cljs$devtools$client$websocket$start (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.websocket.js:25:18)
at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:549:135)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:1117:20)
at eval (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.browser.js:1358:40)
at ./src/cljs/shadow.cljs.devtools.client.browser.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:725:1)
at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///./pages/index.js:5:106)
at ./pages/index.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:198:1)
at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
at __webpack_exec__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:1268:39) {
page: '/'
}
24 | shadow.cljs.devtools.client.websocket.start = (function shadow$cljs$devtools$client$websocket$start(runtime){
25 | var ws_url = shadow.cljs.devtools.client.env.get_ws_relay_url();
> 26 | var socket = (new WebSocket(ws_url));
| ^
27 | (socket.onmessage = (function (e){
28 | return shadow.cljs.devtools.client.shared.remote_msg(runtime,e.data);
29 | }));var $CLJS = require("./cljs_env"); and it's exactly this file that throws the error online 1448 in this statement goog.module("goog.debug.Error"); . So as soon as the file with the patch is loaded the error will be thrown before any of the actual code from the pages being executed.cljs_env.js but not sure that changes anythingset! replacements somewhere but I don't know:dev {:closure-defines {foo.core/DEV true}}
and inside src/cljs/foo/core.cljs
(ns foo.core) (goog-define DEV false) (def dev? (true? DEV))Is working correctly but I cannot use
dev? inside components. Since the application is loaded from that calls foo.core/init! and inside foo.core all the rest of the reagent components are loaded sequentially, if I (:require [foo.core :refer [dev?]]) inside a component is doing a circular reference.
So the question is, how can I define variables at compile time that I can use inside components without creating a circular reference?foo.config namespace that you can reference everywhere. the problem is having this in foo.core so just move it out. I personally have a my.app.env namespace in every app for such purposesvar s = _interopRequireWildcard(require("@solana/web3.js"));
^ this line is from a compiled file. This compiled file is from a package that the js code depends on. Somewhere deeper in the file when this function is used, I get an error saying that s is not defined.
Has anyone faced this before? I've been stuck on it for the past 2 days. I have made sure that the module is present.
I have also manually imported this module in my core file. Its present there (I'm able to console.log), but it isn't available for a js package that relies on it.(:require ["/some/thing.js" :as x])? ie. not a file in node_modulesapp/core.cljs(:require ["@solana/web3.js" :as sol]) what is (js/console.log sol)?packages/that-stuff and use :js-package-dirs ["packages" "node_modules"] in your build configthat-stuff can pretend to be a full npm package(:require ["that-stuff"])js-package-dirs ?terser plugin in rollup minified in a way that was incorrect for CLJS (and Dart).
For some reason, it works fine for Nextjs based projects.node_modules in your projectdeps.edn nothing in info matters basicallydeps.edn overrides all of itshadow-cljs install is just the actual shadow-cljs CLI tool. you can just remove it, it won't affect compilation in any way.shadow-cljs yes.cpcache is not something shadow-cljs ever looks at or usesnode-repl no JS is compiled by shadow-cljs and it just emits require("whatever") if you use a node librarynode part implies the same, unless you override :js-providernode_modulesumd_helper is just the wrapper for the :node-library output, so it'll be on the stacktrace but itself it doesn't do anything that mattersbackend.test_file_store
Thrown:
RangeError: Maximum call stack size exceeded
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:4:114)
/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js?:exports that exports itself?(:require ["something"]) would be referring to itself?:npm-module:node-library is really meant to create a standalone actual node library(defprotocol P (a [_])) (a (throw ""))which results in:
------ WARNING #1 - :undeclared-var -------------------------------------------- File: /home/p-himik/tmp/cljs-compiler-bug/src/a/b.cljs:6:1 -------------------------------------------------------------------------------- 3 | (defprotocol P 4 | (a [_])) 5 | 6 | (a (throw "")) -------^------------------------------------------------------------------------ Use of undeclared Var a.b/ignore --------------------------------------------------------------------------------Maybe this line https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L823 is simply missing the symbol
ignore?ignore be in that set?ignore is coming from?ignore is defined here:
https://github.com/clojure/clojurescript/blob/a4673b880756531ac5690f7b4721ad76c0810327/src/main/clojure/cljs/analyzer/impl.cljc#L29
And it ends up being as a tag because of this, I think: https://github.com/clojure/clojurescript/blob/5e7fd72f7fa25e10241f229998e5620d79bc0aad/src/main/clojure/cljs/analyzer.cljc#L1537
The repro is literally those 3 lines that I posted, and a bare-bones shadow-cljs.edn.
But I can create a repo with the repro if you want.ignore stuff before when looking through analyzer code 😛npm i && npx shadow-cljs watch main.npx shadow-cljs release app
The required JS dependency "buffer" is not available, it was required by "node_modules/amplitude-js/amplitude.umd.js". Dependency Trace: viderahealth/events/common_test.cljs viderahealth/events/common.cljs viderahealth/amplitude.cljs node_modules/amplitude-js/amplitude.umd.js Searched for npm packages in: /Users/mitchellharris/src/patient-fe/node_modules See:We do have
shadow-cljs listed in our package.json, so It isn’t likely to be https://clojurians-log.clojureverse.org/shadow-cljs/2020-05-27
Any ideas?npm install buffer? it should already be installed but I guess its not?(:require [acme.myproto.a])) matching whatever name is in goog.provide or goog.moduleloader is trying to load a module that I didn't specify. I have a configuration and source files similar to the below:
;; shadow-cljs.edn
{:builds {:client {:target :browser
:module-loader true
:modules {:client {:entries [my-app.client]}
:room {:entries [my-app.components.room]
:depends-on #{:client}}}}}}
;; my-app.client
(require-lazy '[my-app.components.room :refer [Room])
client and room modules are generated in my output-dir and the module mapping file
When I navigate to the page that loads the room module, I get a runtime exception from failing to load the module. However, it's not failing because it can't load room; rather it seems like shadow attempts to load a module with components moduleID when that module doesn't exist
Is that because I have a namespace defined at my-app.components.room, and it expects the existence of a parent components module? I don't have a my_app/components.cljs filecljs.env - https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/env.cljccomponents module. I don't know what require-lazy is though? if that is emitting a module load for components then that is out of shadow-cljs controlrequire-lazy might be the source of the bug and is extracting the wrong module name. it's from the Rum library: https://github.com/tonsky/rum/blob/9feb2a1781e3ef716361f9788150a01ea7f791b6/src/rum/lazy_loader.cljc#L31-L52my-app.components namespace that re-exports all of the components from my-app.components.*? Then create an associate :components module?(set-loaded! :module-id) if I use the macro you shared:base-api-root, etc. I'm not sure what's the best way of doing something like this.cljs.env. that is something from the compiler. you wouldn't use it in a regular build:closure-defines and environment variables are probably easier(ns some.ns) (goog-define FOO "default-value")goog-define as def so (def FOO "default-value")[:builds :app :closure-defines] to something like this: {:base-api-root #shadow/env ""}
Now what should I do?{:base-api-root #shadow/env ""} this is not quite right. this will look up the environment variable called ""some.ns/FOO:compiler-options {:closure-defines ...}. both workCLOSURE_DEFINES should be of no concern to you. if you are trying to use it you are doing something incorrectly.:target build?goog-define?{:builds {:build-id {:target :browser :closure-defines {goog.json.USE_NATIVE_JSON true}}} in shadow-cljs.ednCLOSURE_DEFINES is of no concern. it is an implementation detail. forget it exists.:target :browser buildlein uberjar-app:uberjar-app {:prep-tasks [["shadow" "release" "app"]
"compile"]}
release of the app build:advanced build. this will be optimized and no traces of the CLOSURE_DEFINES will be left. so you definitely cannot look that up thereCLOSURE_DEFINES in release builds is not possiblewatch or compile but not releaseJSON.parse if thats available? so it won't use eval if that is available?shadow release app --debug. that'll give you source maps and use pseudo namesgoog.json should be $goog$json.shadow-cljs to make it works again. I have the error stack, I'm not sure whether it will help or not, the build target is node-script.View file details?$cljs.node right?npx shadow-cljs ... ?npx shadow-cljs watch app and emacs cider jack-in or somethingnpx shadow-cljs watch app would cause this two if executed fast enough. meaning before one becomes "ready" and thus the second thinking it was first and starting as normalnpx shadow-cljs server. But I don't think I started it twice.npx shadow-cljs server manually yourself.shadow-cljs?.shadow-cljs/builds/app/... and one .shadow-cljs/builds/test/...app build they will both write to .shadow-cljs/builds/app/...jps. that should list all running java processesjinfo <pid> from jpsps I guess if you are on a mac/linuxshadow-cljs release app:
Closure compilation failed with 1 errors --- app/components/user/payment.js:2 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)payment.js
import { firebaseapp } from 'goog:app.helpers.firebase';
import firebase from 'firebase/compat/app'; <--- error here
import 'firebase/compat/functions';
(...)
(ns app.components.user.index (:require ["antd" :refer (Avatar Button Dropdown Menu Skeleton Spin)] ["@ant-design/icons" :refer (LoadingOutlined)] [reagent.core :as r] ["firebase/compat/app" :default firebase] [app.helpers.macros :refer [if-let-n]] ["./payment" :refer (onAuth openCheckout openCustomerPortal onActiveSubscription)] <---- imports [re-frame.core :as rf] [cljs.core.match :refer [match]]))Stuck on debugging this. I hope someone can help 🙂
import { firebaseapp } from 'goog:app.helpers.firebase'; should be import firebaseapp from 'goog:app.helpers.firebase';import firebase_helper from 'goog:app.helpers.firebase'; firebase_helper.firebaseapp assuming thats a def in the ns?import firebase_helper from 'goog:app.helpers.firebase';
import firebase from 'firebase/compat/app'; <-- error points to this line
import 'firebase/compat/functions';
const { firebaseapp } = firebase_helper;
(...)
app.helpers.firebase.cljs
(ns app.helpers.firebase
(:require ["firebase/compat/app" :default firebase]
["firebase/compat/auth"]
["firebase/compat/firestore"]
[app.envvars.core :refer [APP_ENV]]))
(...)
(def ^:export firebaseapp (.initializeApp firebase (if (= APP_ENV "production") firebase-prod-config firebase-dev-config)))
shadow-cljs watch app still works though.[:nav {:class "hidden md:flex space-x-10"}
After: [:nav {:class " hidden md:flex space-x-10 "}
@thheller I wonder if there is some setting which would make class names automatically recognizable?./target/cljsbuild/public/js/app.jstarget/cljsbuild/public/js/cljs-runtime that isrelease builds you can point it at just the app.jsw-1.5 -> w-1*5w-1.5 is not a valid classname. I generally just keep everything in :class "..." and don't use :div.class at allw-1.5 is a valid classname, it is just that div.w-1.5 is not valid reagent syntax (that is why we changed it). See the docs here to see w-1.5:
https://tailwindcss.com/docs/width:optimize-constants that I think I've bisected down to 2.15.13 (`2.15.12` and before seem to work fine, 2.15.13 and after seem to have the issue).
In particular, after 2.15.13, many keyword constants in the code seem to not be assigned. Some keywords (like var cljs$cst$keyword$shouldComponentUpdate=new cljs$core$Keyword(null,"shouldComponentUpdate",
"shouldComponentUpdate",1795750960)) are properly created once and all callsites properly reference this global cljs$cst$keyword$XXXXXXXX var, others (like new cljs$core$Keyword(null,"body","body",-2049205669)) are created new every time.
Has anyone observed anything similar to this before? Appreciate any help.:body maybe only used in one place? maybe the closure compiler is trying to be too smart for its own good?:body is used 36 times. My most extreme example is :recur (due to plenty of cljs.core.async), which is allocated at 3560 callsites as new cljs$core$Keyword(null,"recur","recur",-437573268).:optimize-constants is not a thing in shadow-cljs so maybe something else is going on?:compiler-options {:shadow-keywords true}. that optimizes them a little more:shadow-keywords and still have the same issue (some keywords are fine, others are repeatedly reallocated).
I did see that 2.15.13 bumped the cljs / closure compiler versions (https://github.com/thheller/shadow-cljs/commit/7fefe5b3f604ff11d33539e4899e160dd1ff6eb0) -- maybe that's where the issue lies.2.17.0. thanks for the report. there really should be a test for this. went unnoticed for too long.:npm-module, and :esm. I read a bunch of issues about various tradeoffs. Was unsure what to pick.
But a coworker of mine just tried target :browser and loading that into webpack works perfectly fine. Maybe I'm missing it, but it seems like from the documentation that isn't what I'd expect. It seems like those other targets are there to make it work with existing js apps.
Now there was one limitation, I couldn't control exports at a fine-grained level, just exporting whole namespaces. Adding a simple little js with some imports and re-exports fixed that all though.
So I guess my question is, am I missing something?
Is there a reason I shouldn't use target browser + a shim to do this? Is this something that just happens to work but might break in the future? Could target :browser add an exports like esm and make it work with existing js stuff without the nested namespace object?:npm-module for metabase.
• shadow-cljs.edn:
• exported var:
• imported into js:
• webpack: and :npm-module. Also the talk of deprecation made me a bit hesitant. Thanks for the links though 🙂:npm-module is best for integration with other tools currently. :browser by default will bundle all JS dependencies on its own in a way that webpack can't see. so you'll end up with duplicated ones such as react for example:npm-module design it'll likely stay as is:npm-module. Right now, that limitation isn’t too big of a deal for us though, we don’t have dependencies in common with the js project. But that will probably change over time.
Glad to hear that :npm-module will stay put. Makes me feel better about using it.browser builds take so much longer to compile compared to react-native builds? At first thought it was standard cljs->js compilation but if the native builds are much faster for same app must be other reasonsbrowser builds bundle JS so if you include 5000 npm deps that'll take a while. react-native does not bundle since metro will be doing that, so technically you have to add the metro time.:target :react-native in shadow-cljs or react-native alonenode_modules folder. Is it possible to make shadow-cljs reload when changes are made to dist files of a package in node_modules ?touch node_modules/that-package/package.json to make shadow-cljs reload itnode_modules folder on change. I have added the package path to :paths in config. And instead of using it as @pkg/name is use it as /@pkg/name . This forces shadow to treat it as source code and perform HMR on change.@pkg/name (drop the /).require() of ES Module /home/ribelo/code/alzey/node_modules/node-fetch/src/index.js from /home/ribelo/code/alzey/build/alzey.js not supported.this is the first time I have encountered such a problem
node-fetch version to one that has the commonjs files:target :esm may have all sorts of other challenges 😉react navigation (for react native) checks whether a component’s fn name is capitalized.
The issue is that even if I capitalize the component, the namespace name is being appended.
e.g. Home becomes myapp.Home
Can anyone think of a workaround for this?
Not sure if shadow-cljs or clojurescript handles this, and if proper avenue would be to find a solution in cljs or open up issue / fork libraryfn.name won't even exist in release builds so I don't know what this check is supposed to dodisplayName and fallback to the function namefunction whatever() to function () if the name is never directly usedGot a component with the name 'app$client$mobile$app$register_screen' for the screen 'Register'. React Components must start with an uppercase letter. If you're passing a regular function and not a component, pass it as children to 'Screen' instead. Otherwise capitalize your component's name.
(set! js/console.warn
(fn [message]
(when-not (str/includes? message "React Components must start with an uppercase letter.")
(js/console.warn message))))js/console.warn somewhere?:compiler-options (specifically :closure-defines) for dev vs release builds?:builds in shadow-cljs.edn?(ns tech.coderaanalytics.d3test.views (:require ["d3" :as d3]))Returns the following in the browser console
"regenerator-runtime/runtime" to your ns :require just before requiring the d3 stuff(ns tech.coderaanalytics.d3test.views
(:require ["regenerator-runtime/runtime"]
["d3" :as d3]))npm install regenerator-runtime{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ee9d868f8a8199c38d82849daedcc0dfd9c0de"}, :content ("[email protected]")} I am going to try create a new project from scratch and see if I can reproduce this problem.manifest.edn files).:karma target and getting Uncaught ReferenceError: global is not defined if i use npx shadow-cljs compile test && npx karma start --single-run
works fine if i use release: npx shadow-cljs release test && npx karma start --single-run
Am i missing anything?
The relevant part of shadow-cljs.edn is :
:test {:target :karma
:output-to "out/karma-test.js"
:compiler-options {:source-map true}
:autorun true}}
Thanksglobal access is coming from. if code you use uses global then you need to change that I guessnpx shadow-cljs compile test is
❯ npx karma start --single-run
08 02 2022 23:13:39.899:INFO [karma-server]: Karma v6.3.15 server started at
08 02 2022 23:13:39.902:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
08 02 2022 23:13:39.906:INFO [launcher]: Starting browser ChromeHeadless
08 02 2022 23:13:41.448:INFO [Chrome Headless 98.0.4758.80 (Mac OS 10.15.7)]: Connected on socket 63bK4JwP5wscOyTgAAAB with id 826372
Chrome Headless 98.0.4758.80 (Mac OS 10.15.7) ERROR
Uncaught ReferenceError: global is not defined
at karma-test.js:8:15
ReferenceError: global is not defined
at karma-test.js:8:15
So it happens in the very beginning of the karma-test.js, the relevant part is:
1 │ var shadow$provide = {};
2 │ var $jscomp = {};
3 │ var CLOSURE_NO_DEPS = true;
4 │ var CLOSURE_BASE_PATH = 'js/cljs-runtime/';
5 │ var CLOSURE_DEFINES = {"goog.DEBUG":true,"goog.LOCALE":"en","goog.TRANSPILE":"never","goog.ENABLE_DEBUG_LOADER":false};
6 │ var COMPILED = false;
7 │ var goog = goog || {};
8 * │ goog.global = global;
9 │ goog.global.CLOSURE_UNCOMPILED_DEFINES;
10 │ goog.global.CLOSURE_DEFINES;
Basically before it gets to my codeglobal but no longer?:output-feature-set to :es6 helps:
{:target :karma
:output-to "out/karma-test.js"
:compiler-options {:source-map true
:output-feature-set :es6}
:autorun true}
shadow.build.targets.karma/configure it’s set to :es8 unless explicitly specified.
So, i just specified :es6 in my config and it worked.global is?:output-feature-set key and it still works,
Line 8 looks different from the time when it didn’t work
1 │ var shadow$provide = {};
2 │ var $jscomp = {};
3 │ var CLOSURE_NO_DEPS = true;
4 │ var CLOSURE_BASE_PATH = 'js/cljs-runtime/';
5 │ var CLOSURE_DEFINES = {"goog.DEBUG":true,"goog.LOCALE":"en","goog.TRANSPILE":"never","goog.ENABLE_DEBUG_LOADER":false};
6 │ var COMPILED = false;
7 │ var goog = goog || {};
8 * │ goog.global = this || self;
9 │ goog.global.CLOSURE_UNCOMPILED_DEFINES;
10 │ goog.global.CLOSURE_DEFINES;
const docRef = await db
.collection('customers')
.doc(firebaseapp.auth().currentUser.uid)
.collection('checkout_sessions')
.add({
price: 'price_XXXXXXX',
success_url: window.location.origin,
cancel_url:
window.location.origin + '/logout',
});(ns app.components.user.index (:require ["antd" :refer (Avatar Button Dropdown Menu Skeleton Spin)] ["@ant-design/icons" :refer (LoadingOutlined)] [reagent.core :as r] ["firebase/compat/app" :default firebase] [app.helpers.macros :refer [if-let-n]] ["./payment" :refer (onAuth openCheckout openCustomerPortal onActiveSubscription)] <---- imports [re-frame.core :as rf] [cljs.core.match :refer [match]]))
payment.js file. How?
2. don’t do optimizations on the keys of this specific object. How?const docRef = await db
.collection('customers')
.doc(firebaseapp.auth().currentUser.uid)
.collection('checkout_sessions')
.add({
"price": 'price_XXXXXXX',
"success_url": window.location.origin,
"cancel_url":
window.location.origin + '/logout',
});
:infer-externs and :externs:
:builds
{:app {:target :browser
:asset-path "/js"
:modules {:main {:init-fn app.core/main}}
:output-dir "public/js"
:devtools {:http-root "public"
:http-port 3001
:preloads [day8.re-frame-10x.preload]}
:compiler-options {:externs ["/app/components/user/payment.js"]
:infer-externs :auto}
:dev
{:compiler-options
{:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release
{:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
:js-options {:ignore-asset-requires true}}shadow.cljs.devtools.server and shadow.cljs.devtools.api from Clojure REPL.
I tried leaving all the front-end deps in shadow-cljs.edn, and added only thheller/shadow-cljs to project.clj.
But it doesn't compile my stuff. It keeps complaining about missing dependencies. What I am missing?npx shadow-cljs compile :app, but when I do it from within the REPL, like so:
(require '[shadow.cljs.devtools.api :as shadow]) (require '[shadow.cljs.devtools.server :as server]) (server/start!) (shadow/compile :app)it fails to find required namespaces
:infer-externs and :externs:
:builds
{:app {:target :browser
:asset-path "/js"
:modules {:main {:init-fn app.core/main}}
:output-dir "public/js"
:devtools {:http-root "public"
:http-port 3001
:preloads [day8.re-frame-10x.preload]}
:compiler-options {:externs ["/app/components/user/payment.js"]
:infer-externs :auto}
:dev
{:compiler-options
{:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:release
{:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
:js-options {:ignore-asset-requires true}}^js but that tag not being present still results in an incorrectly minified name?
My guess is that name was used in e.g. Closure library. Are there any other potential causes?(set! *warn-on-infer* false) turns everything off, just in case that is in the file?set!.
Here's the code, with some crud removed:
(defn replace-track-source! [^js playlist track-name src]
(loop [tracks (.-tracks playlist)]
(when-first [track tracks]
(if (= (.-name track) track-name)
(do
(-> (to-audio-buffer src playlist)
(.then (fn [audio-buffer]
(set! track -src audio-buffer)
(.setBuffer track audio-buffer)))))
(recur (next tracks))))))
:advanced renamed .setBuffer.setBuffer seems like it may exist:pseudo-names?--debug - it became .$setBuffer$. Adding ^js in front of track in the when-first form fixes that..shadow-cljs/builds/app/release dir should be a externs txt filesetBuffer is actually not in there:build-hooks [(shadow.build/tap-hook)]in your build config
:compiler-env -> :cljs.analyzer/namespaces -> your.ns -> :shadow/js-* should contain it.then is not there, even though it definitely works, but .resolve is there..then is definitely in the default externs.resolve? Huh.Promise.resolve so why would there be a generic .resolve?track by the analyzer are any and clj-nil.when-first - it gets expanded into essentially (let [track (first (seq tracks))] ...). And seems like that seq makes CLJS analyzer forget about the ^js tag.:compiler-options {:externs ["/app/components/user/payment.js"]
i get this:
[:app] Compiling ...
[BABEL] Note: The code generator has deoptimised the styling of /Users/simonchristensen/Documents/Developer/movenation/calculator/node_modules/@firebase/firestore/dist/index.esm2017.js as it exceeds the max of 500KB.
{:type :missing-externs, :extern "/app/components/user/payment.js", :shadow.build.log/level :warn}
{:type :missing-externs, :extern "/app/components/user/payment.js", :shadow.build.log/level :warn}
[:app] Build completed. (3727 files, 3616 compiled, 0 warnings, 95.37s)/ prefix: :compiler-options {:externs ["app/components/user/payment.js"]JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 1 : 0 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 2 : 0 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 5 : 0 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: object destructuring. at EXTERNS:app/components/user/payment.js line 5 : 6 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 6 : 0 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 7 : 0 JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 9 : 0
:browser-test target, is there any way to influence the path it uses in the index.html file?
<script src="/js/test.js">
(I mean the /js/test.js there, I'd like to change that path)
I tried setting :asset-path, like one would for the :browser target, but that was ignored.:node-library target that has one basic interface point between the clojurescript and javascript worlds. I use a deftype with Object methods to provide the javascript-side interface, e.g.,
(deftype Mediator Object (opA [this] ...) (opB [this in] ...) ...)When done this way, I get the
Cannot infer target type warnings on the deftype expression. I set :infer-externs :auto in compiler options, which does not fix the warnings. The warnings do go away when instead when I do deftype ^js Mediator, but that turns the Mediator type into a POJO requiring js-style operations on the object inside the methods (e.g., set! works but not assoc). This is fine, and I can live with it.
I am curious, however, about best practices for this use case. What is the best way to create a javascript object interface to clojurescript code with shadow-cljs? Will the javascript methods (e.g., opA and opB ) be externed properly this way under advanced compilation? And is it necessary to make the mediating type a mutable POJO or is it possible to have clojurescript data that is treated as an opaque object on the javascript side? I'd appreciate hearing what other people do in this situation. Thanks!^js) should not generate inference warnings?this as a POJO in the methods.deftype vs defrecord?deftype with Object methods are completely fine but without knowing more about what exactly you are doing its hard to give a accurate answer26 | (deftype Mediator [frame options env] -------^------------------------------------------------------------------------ Cannot infer target type in expression (. (. MathLingo -prototype) -render) -------------------------------------------------------------------------------- 27 | Object 28 | (render [this] 29 | (str "TBD" (process frame))))With
^js, there inference error goes away.
On the second point, you're right, my mistake. I did a deftype here, not a defrecord. I had done it earlier with defrecord and then changed it with the type hint but foolishly ignored that (even as I typed it), so of course assoc no longer worked. Apologies.
The remaining questions are why is the ^js needed, and is there a better way to achieve this goal than what I'm doing here. Thanks!deftype Mediator but (. MathLingo -prototype)?(. Mediator -prototype). Not really on my game today 🙂{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[better-cond "2.1.0"]
[binaryage/oops "0.7.0"]
[camel-snake-kebab "0.4.2"]
[data.deque "0.1.0"]
[instaparse "1.4.10"]
[metosin/potpuri "0.5.3"]
[com.rpl/specter "1.1.3"]
[net.cgrand/xforms "0.19.2"]
[org.clojure/algo.monads "0.1.6"]
[org.clojure/core.match "1.0.0"]
[org.clojure/test.check "1.1.1"]]
:builds
{:main {:target :node-library
:output-to "out/mathlingo.js"
:exports {:createParser mathlingo.core/create-parser}
:compiler-options {:infer-externs :auto}
:devtools {:repl-pprint true}}
:test {:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun false}}
:nrepl {:port 8777}
:open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}(deftype Mediator [frame options env]
Object
(render [this]
"TBD"))npx shadow-cljs info=== Version jar: 2.16.12 cli: 2.16.12 deps: 1.3.2 config-version: 2.16.12 === Paths cli: /.../node_modules/shadow-cljs/cli/dist.js config: /.../shadow-cljs.edn project: /... cache: .shadow-cljs === Java openjdk version "15.0.1" 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
(set! *warn-on-infer* false) before the deftype or so and turn it back on again aftercider-jack-in-clj&cljs attempts to use the same process to start two separate repls. This was possible with figwheel. Shadow is a separate process so you cannot start a single lein and then create two repls from it, one clj and one cljscljs.test setup from https://clojurescript.org/tools/testing and I can run my tests fine from the REPL using cljs.test/run-tests. I also followed the instructions in https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test but when I run shadow-cljs compile test on my terminal I get this exception:
shadow-cljs - connected to server
[:test] Compiling ...
NullPointerException:
shadow.build.node/configure (node.clj:59)
shadow.build.node/configure (node.clj:45)
shadow.build.targets.node-script/configure (node_script.clj:37):output-to configured in your build config?:bootstrap build with shadow-cljs 2.17.0 (where originally it was 2.11.7) fails with:
------ ERROR ------------------------------------------------------------------- File: jar:file:/home/p-himik/.m2/repository/org/clojure/clojurescript/1.10.914/clojurescript-1.10.914.jar!/cljs/js.cljs:9:1 -------------------------------------------------------------------------------- 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns cljs.js -------^------------------------------------------------------------------------ null The alias env is already used for namespace cljs.env.macros -------------------------------------------------------------------------------- 10 | (:refer-clojure :exclude [require eval]) 11 | (:require-macros [cljs.js :refer [dump-core]] 12 | [cljs.env.macros :as env]) 13 | (:require [clojure.string :as string] --------------------------------------------------------------------------------Presumably because
cljs/js.cljs has both [cljs.env.macros :as env] in its :require-macros and [cljs.env :as env] in its :require.
Is there a way to fix this?:as-aliasenv as alias for two different namespaces 😛shadow-cljs: reloading code but no :after-load hooks are configured!
:after-load hook configured, and I can evaluate the function of the hook, but somehow nothing happens when I save a file. It's a :browser target, but with an Electron host:after-load configured? it is much easier to have ^:dev/after-load in the metadata of your code:devtools option. None worked:preloads){:target :browser
:output-dir "static"
:asset-path "."
:modules {:main {:init-fn cljs.atom.view/start!}}
:js-options {
:keep-native-requires true}
;:js-provider :require}
:devtools {:before-load cljs.atom.view/start
:after-load cljs.atom.view/after-load}}cljs.atom.view is in the config, and when I save the file, I see on Electron's console:
shadow-cljs: reloading code but no :after-load hooks are configured! browser.cljs:20 shadow-cljs: load JS cljs/atom/view.cljs
(println "testing") for now...start before loading new code?cljs.* is reserved. no hooks in those are discovered or used^:dev/before-load-async, but that's in a file on the browser side. Can I have something similar but in clj, not cljs?npm-run-all. as for example in this repo using postcss+tailwind.edn resources).edn files but maybe this already solves whatever it is https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745.edn files for translations (i18n) that's why I wanna reload frontend after some changes in them. I think it's a popular case. Isn't it?
So you haven't any plans to extend this tracking?The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js".
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:js-options {:provider :closure
:entry-keys ["main" "module" "browser"]}}:js-options {:resolve {"http2" false}} in your build config. that will disabled that require. I'm guessing that'll just break stuff though. it shouldn't be using a node-http-handler for a browser build:source-paths ["src/frontend"], maybe this helps https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html:dev-http server with classpath:public to serve my SPA. The documentation reads:
> By default these will serve all static files from the configured paths, and fall back to `index.html` when a resource is not found
Everything is working fine when I just load the root of the site, but when I try any other path, eg /foo/bar I get a 404 with text Not found. Missing index.html. I do indeed have an index.html file in that public folder, and as I've said it works fine at the root address...resources/public fixed itcljc file?
For some reason my build was only compiling properly when the cljs macros were defined and used in separate files.
So single file macro usage was failing:
;; myapp/ui.cljc (ns myapp.ui #?(:cljs (:require-macros [myapp.ui]))) #?(:clj (defmacro defc [])) #?(:cljs (defc component []))But splitting up the definitions and consumption got it working:
;; myapp/ui-macros.cljc (ns myapp.ui-macros #?(:cljs (:require-macros [myapp.ui-macros]))) #?(:clj (defmacro defc [])) ;; myapp/ui.cljs (ns myapp.ui (:require [my-app.ui-macros :refer [defc]) (defc component [])Is this expected? Or could there be something wrong with my application code that may be worth trying to reproduce minimal example?
.clj file (or :clj slice in a .cljc file) since they are Clojure code that runs at compile time..clj file and require it from your clj{s,c} file..cljc is much harder and much easier to make mistakes. generally easier to have two filesfoo and also refers to a foo symbol
(ns myapp.my-ns
(:require [myapp.ns1 :as foo]
[myapp.ns2 :refer [foo]]))
;; how i use them:
foo/var1 ;; resolves to myapp.ns1/var1
foo ;; resolves to myapp.ns2/foo
"Error: The alias foo is already used for namespace myapp.ns1"
Reverting to 2.16.12 has no such issue.2.17.2rewrite-clj. I naively thought this would just work, but it seems the three dependencies get to share the same version of rewrite-clj.rewrite-clj, because I am only really using rewrite-cljs ... Trying this, but it doesn't work:
[pez/cljfmt "0.0.5-SNAPSHOT" :exclusions [rewrite-clj]]
firebaseui, utilizes the browser window object. When I require the dependency e.g. (:require ["firebaseui" :as firebaseui]) , shadow is unable to compile the build. Is there a way around this?
Should I try to lazy-load the dependency so that I can check for js/window before bringing the dependency into the build? If so, is there a way to lazy-load the NPM module directly, or do I need to create a standalone module my-app.firebaseui that imports firebaseui , then lazily load my-app.firebaseui into the rest of my app?
I'm going to try ^ and report back on how it goesjs/window , then try to lazy-load a separate my-app.firebase module containing the firebaseui import, shadow-cljs is still unable to compile. I could definitely be doing something wrong here - would appreciate your input. Here's a simplified example of what I have:
;; shadow-cljs.edn
{:builds {:client {:module-loader true
:modules {:client {:entries [my-app.client]}
:firebaseui {:entries [my-app.firebaseui]
:depends-on #{:client}}}}}
;;
(ns my-app.firebaseui
(:require ["firebaseui" :as firebaseui])
(defn init-firebaseui [] ...)
;;
(ns my-app.sign-in
(:require [shadow.lazy :as lazy])
(when js/window
(lazy (lazy/loadable my-app.firebaseui/init-firebaseui)
(fn [init-firebaseui] (init-firebaseui)))):target :browser isn't meant to run on node:target :browser build, my Node build doesn't know that those modules exist. However, the Clojurescript compiler is still going to build the dependency tree and attempt to load those (undefined in Node) modules. As a result, my :node build is failing to compile due to an error with macroexpanding shadow.lazy/loadable on namespaces that don't have a module mapping. I believe the :modules config is specific to :browser builds and isn't supported for :node builds, so this seems to be expected behavior
How should I approach making those modules compatible / ignoring those modules for the Node build? Is that something I should also handle via host-specific namespaces?(re-find #"^\b([a-z\-]+)\b(?<!render|ignoreme)-test" "first-render-test")
:devtools {:build-notify } whereas that points to a regular defn receiving on argument which is a map which is the same as this msg https://github.com/thheller/shadow-cljs/blob/8ef958f332c0e0648fd84eb2a3d5205602487f6b/src/main/shadow/cljs/devtools/client/hud.cljs#L263------ ERROR ------------------------------------------------------------------- File: jar:file:/home/tianshu/.m2/repository/org/clojure/core.async/1.3.618/core.async-1.3.618.jar!/cljs/core/async/impl/channels.cljs:23:3 -------------------------------------------------------------------------------- 20 | (deftype PutBox [handler val]) 21 | 22 | (defn put-active? [box] 23 | (impl/active? (.-handler box))) ---------^---------------------------------------------------------------------- null ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.NamedI'm sure I have only one jvm running. Everytime the error is different, but I've seen
clojure.lang.KeywordLookupSite multiple times[org.clojure/core.async "1.4.627"]@mui/x-data-grid": "5.2.0" does not load as expected : compilation with shadow-cljs watch app` runs fine, but when loading the page http://localhost:3000/#/about i get the following error :
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$material$node$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs @ index-cjs.js:3
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2782
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$x_data_grid$index_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2782
app.js:1455 TypeError: Cannot redefine property: ModalManager
at Function.defineProperty (<anonymous>)
at eval (index.js:2038:10)
at Array.forEach (<anonymous>)
at Object.shadow$provide.module$node_modules$$mui$material$node$index (index.js:2034:21)
at shadow.js.jsRequire (js.js:66:18)
at Object.shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs (index-cjs.js:3:118)
at Object.shadow.js.jsRequire (js.js:66:18)
at Object.shadow.js.require (js.js:113:20)
at eval (reagent_mui.x.data_grid.js:2:62)
at eval (<anonymous>)
reportError @ app.js:1455
env.evalLoad @ app.js:1565
(anonymous) @ app.js:2782
app.js:1457 The above error occurred when loading "reagent_mui.x.data_grid.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.
p-himik already provided a lot of https://clojurians.slack.com/team/U2FRKM4TW, unfortunately the error does still persist.
any help would be helpful, as the perspective to switch back to bare javascript does not trigger any joy.
Thanks a lot for your time !
Cheers, clement.@mui/x-data-grid expecting a difference @mui/material version?"@material-ui/core": "4.11.3",
"@mui/material": "5.2.4",
"@mui/x-data-grid": "5.2.0",@mui/material the new "@material-ui/core"? why do you have both?package.json accordingly :
"dependencies": {
"@emotion/react": "11.0.0",
"@emotion/styled": "11.0.0",
"@mui/material": "5.2.4",
"@mui/x-data-grid": "5.2.4",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
and then npm install & shadow-cljs watch app leider still getting the same error in the dev tools :
shadow-cljs - failed to load module$node_modules$$mui$material$node$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs @ index-cjs.js:3
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2779
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$x_data_grid$index_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2779
app.js:1455 TypeError: Cannot redefine property: ModalManager
at Function.defineProperty (<anonymous>)
at eval (index.js:2038:10)
at Array.forEach (<anonymous>)
at Object.shadow$provide.module$node_modules$$mui$material$node$index (index.js:2034:21)
at shadow.js.jsRequire (js.js:66:18)
at Object.shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs (index-cjs.js:3:118)
at Object.shadow.js.jsRequire (js.js:66:18)
at Object.shadow.js.require (js.js:113:20)
at eval (reagent_mui.x.data_grid.js:2:62)
at eval (<anonymous>)
reportError @ app.js:1455
env.evalLoad @ app.js:1565
(anonymous) @ app.js:2779
app.js:1457 The above error occurred when loading "reagent_mui.x.data_grid.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.:js-options {:entry-keys ["module" "browser" "main"]}} in your build config[reagent-mui.x.data-grid :refer [data-grid]] require is now working !
but when using the data-grid component in the hiccup i now get the following error :
index-esm.js:6943 Uncaught TypeError: Cannot read properties of undefined (reading 'useRef')
at eval (index-esm.js:6943:25)
at Xi (index-esm.js:6942:12)
at Ss (index-esm.js:8390:3)
at eval (index-esm.js:9742:10)
at renderWithHooks (react-dom.development.js:14986:18)
at updateForwardRef (react-dom.development.js:17045:20)
at beginWork (react-dom.development.js:19099:16)
at HTMLUnknownElement.callCallback (react-dom.development.js:3946:14)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:3995:16)
at invokeGuardedCallback (react-dom.development.js:4057:31)
eval @ index-esm.js:6943
Xi @ index-esm.js:6942
Ss @ index-esm.js:8390
eval @ index-esm.js:9742
renderWithHooks @ react-dom.development.js:14986
updateForwardRef @ react-dom.development.js:17045
beginWork @ react-dom.development.js:19099
callCallback @ react-dom.development.js:3946
invokeGuardedCallbackImpl @ react-dom.development.js:3995
invokeGuardedCallback @ react-dom.development.js:4057
beginWork$1 @ react-dom.development.js:23965
performUnitOfWork @ react-dom.development.js:22780
workLoopSync @ react-dom.development.js:22708
renderRootSync @ react-dom.development.js:22671
performSyncWorkOnRoot @ react-dom.development.js:22294
eval @ react-dom.development.js:11328
exports.unstable_runWithPriority @ scheduler.development.js:469
runWithPriority$1 @ react-dom.development.js:11277
flushSyncCallbackQueueImpl @ react-dom.development.js:11323
flushSyncCallbackQueue @ react-dom.development.js:11310
scheduleUpdateOnFiber @ react-dom.development.js:21894
updateContainer @ react-dom.development.js:25483
legacyRenderSubtreeIntoContainer @ react-dom.development.js:26038
exports.render @ react-dom.development.js:26104
reagent$dom$render_comp @ dom.cljs:18
eval @ dom.cljs:48
eval @ dom.cljs:38
luminus_reagent_material_ui$core$mount_components @ core.cljs:132
eval @ env.cljs:211
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:220
G__58170 @ env.cljs:220
eval @ env.cljs:249
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:220
eval @ env.cljs:256
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:43
eval @ browser.cljs:93
eval @ shared.cljs:32
shadow$remote$runtime$shared$process @ shared.cljc:164
eval @ shared.cljs:289
shadow$cljs$devtools$client$shared$remote_msg @ shared.cljs:16
eval @ websocket.cljs:16
Show 11 more frames
react-dom.development.js:20086 The above error occurred in the <ForwardRef> component:
at eval ()
at cmp ()
at div
at cmp ()
at div
at div
at section
at cmp ()
at cmp ()
Consider adding an error boundary to your tree to customize error handling behavior.
Visit to learn more about error boundaries.:entry-keys) sometimes some requires change:as becomes :default or so[:js-optons :js-package-dirs]. I’m providing absolute paths to files that exist, but for some reason I am getting the follow error on every build ~ even though it immediately succeeds afterwards. I’ve tried trashing .shadow-cljs and emptying the trash but that doesn’t seem to fix it
[CLJ] [:browser] Build failure: [CLJ] The required JS dependency "faunadb/dist/faunadb" is not available, it was required by "routes/index.cljs". [CLJ] [CLJ] Dependency Trace: [CLJ] captain/loader/index.cljs [CLJ] captain/loader/router.cljs [CLJ] captain/manifest.cljs [CLJ] routes/index.cljs [CLJ] [CLJ] Searched for npm packages in: [CLJ] /Users/barrell/.Trash/.captain 17-47-55-522/node_modules [CLJ] [CLJ] See: [CLJ] [CSS] Done in 47ms. [CLJ] [:browser] Build completed. (217 files, 2 compiled, 0 warnings, 0,20s)
.Trash?:js-package-dirs did you set? maybe there is a symlink or so?.Trash:npm-module and running into this issue
https://github.com/thheller/shadow-cljs/issues/908
Except mine is
internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/promise/promise.js"]
{:dep [:shadow.build.classpath/resource "goog/promise/promise.js"]}
ExceptionInfo: internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/promise/promise.js"]
Happy to try to work on a reproducing case. Just wanted to see given its similarity to the existing issue if there is anything I should be looking at or could possibly do to fix the issue. (Sadly :node-library is not an option and one of my deps doesn't play well with :esm.)defclass from your shadow.cljs.modern namespace, but I keep getting errors like "cannot infer target on expression". For example, at this code:
(modern/defclass TextEditor (constructor [this params]) Object (sommething [this]))
Cannot infer target type in expression (. (. TextEditor -prototype) -sommething)
(set! *warn-on-infer* false) before the defclass and back to true afterreagent-expo yesterday to upgrade it to work with Expo SDK 44 and EAS Build. I also added a way to block Expo Web’s fast refresh and removed that section from the README. If you have a chance to check it, please let me know if I need to change anything 🙂
https://github.com/thheller/reagent-expo/pull/10reagent-expo repo
• run yarn to install the dependencies
The development instructions are unchanged.
The instructions for building a standalone app that you can submit to the App/Play stores is now just basically “run eas build ...” because npx shadow-cljs release app is run as part of the build.
So for example you can run:
eas build --platform=android --profile=preview
which will build a .apk that you can install on an Android device. The first time you do this it will ask for the Android package (which is normally something like io.github.shadowcljs.reagentexpo (Android doesn’t like dashes there for some reason)). If you build for iOS then it will ask for a bundleIdentifier which is basically the same thing for iOS (but dashes are allowed there.) It will also generate a default eas.json config file.reagent-expo README basically said :man-shrugging:
2. The classic build system will be going away at some point
I will attempt to answer questions people have if you direct them to the Expo forums
Thanks for your time and for Shadow CLJS 🙂:asset-path dynamically? Via e.g. setting a top-level JS var on window ? I'm dealing with a convoluted setup that must have the asset path being an absolute URL, even in development, e.g. doing :asset-path "", which works fine, but then I'd like to also test on my phone which means that localhost won't do.shadow.loader.init ? It seems to be working in my setup. My generated HTML file is doing roughly
<script src={base-module}>
<script src={main-module}>
<script>shadow.loader.init("")</script>
:module-loader-init set to false)shadow.loader.init after the base module? As, at the time main-module gets loaded, React begins to render so it may trigger asynchronous loading...init method is that it doesn't accept any arguments, so I have to append an extra script tag in my index.html to do this kind of dynamic thing.<meta name="my-base-path" value="whatever"> in your html(js/document.querySelector "meta[my-base-path]") to get it out<script>_BASE_PATH = "whatever"</script> before the other script takesjs/MY_BASE_PATH in the init fnundefined and I can't call function on them anymore - I start the "watch" process, connect my Javascript app, but as soon as it tries to run anything that's on the ClojureScript side, it simply fails with TypeError: Cannot read property 'after_load' of undefined for example (`after-load` is a function defined on CLJS side). I found out that if, just after I connect to the JS app, I reload a specific namespace (by saving the file) then things work. Is there a way to either debug this issue, or force-reload of this namespace all the time?(defn ^:dev/after-load after-load []
(println "Reloaded!"))
(defn start []
;; ..setup here..
(p/do! ;; promesa
(p/delay 2000) ;; wait 2s
(after-load)))
(ns lib.foo) and the (defn after-load []) in thatvar lib = {}; the ns will be gone@react-pdf/renderer is incompatible (wasm) with the standard bunding approach. That means an extra step to run webpack after shadow-cljs compile to build a single js file.
Wondering what the best way to handle the dev time case. Should I use :build-hooks to trigger the webpack after each build?Module not provided: shadow.js.shim.module$react
:internal-index generated by shadow-cljs. it should contain require("react"):external-indexreact-pdf actually wrapsproject/node_modules instead of the local module's project/module/node_modules). Is there a way to enable verbose logging to get more details on the situation?clojure -M:shadow-cljs compile ... rather than npx shadow-cljs compile ...deps.edn. A newer version was used in package.json but it seems shadow-cljs will prefer using the clojure-cli one?package.json only controls the version if using shadow-cljs.edn onlydeps.edn usually know what they're doing. Thanks for answering my questions!reader/**alias-map*,* but then override `reader/resolve-symbol` to which doesn’t appear to have access to those aliases directly (though the analyzer is building up aliases in its own way, i presume) https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/compiler.clj#L312sub/wrapmacros.cljs and macros.cljc file. if I delete the .cljs file and use only .cljc with the self-require there, the symbol expands as expected.cljs file present, in the first “pass” there are no :require’s found by the analyzercljc file, it finds the sub-macros namespace on the first (non-macros) pass.cljs file or the .cljc file? it is technically speaking in a :cljs branch of the .cljc file but loading in CLJ mode since it is a macro(ns bootstrap-test.macros (:require-macros bootstrap-test.macros) (:require [bootstrap-test.sub-macros]))
ana/resolve-symbol is the only thing that can see them?sub but that's not being seen or used by ana/resolve-symbolana/resolve-symbol sees things in the analyzer data. any ns data is added to thatsub/wrap symbol, sub is found in ns-aliases but resolve-symbol doesn't find itbootstrap-test.macros does a self :require-macros but in a cljs file separate from the cljc file (ns bootstrap-test.macros (:require-macros bootstrap-test.macros))so there is no sub alias?
:as-alias a couple months ago. maybe that messed something up?do-analyze-cljs-string supposed to expand macros https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/compiler.clj#L2782.8.36?[:failed-to-compare "^1.2.0" "1.2.2" #error {
:cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:via
[{:type java.lang.NullPointerException
:message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}].cljs file makes an alias available during the macro pass of a .cljc file - as you described above(:require ["@heroicons/react/solid" :refer [CheckIcon ChatIcon]])While the following does not:
(:require ["@heroicons/react/solid/CheckIcon" :as CheckIcon]
["@heroicons/react/solid/ChatIcon" :as ChatIcon])
Is there any way to require without repeating "@heroicons/react/solid" over and over?
I tried with:
(:require ["@heroicons/react/solid" ["CheckIcon" :as CheckIcon]
["ChatIcon" :as ChatIcon]])
Which causes: Invalid namespace declaration:require to allow the nested stuff is not an option since that would break compatibility with standard CLJS:refer only actually imports what was referred is a substantial amount of work, which I simply don't have time for currently. it is also non-standard behavior and basically something webpack invented.[:compiler-env :cljs.analyzer/namespaces 'your.ns :defs 'foo :meta] in the build state$.clearTimeout is not a function
the corresponding call is here:
goog.functions.debounce = function(f, interval, opt_scope) {
'use strict';
let timeout = 0;
return /** @type {function(...?)} */ (function(var_args) {
'use strict';
goog.global.clearTimeout(timeout);
const args = arguments;
timeout = goog.global.setTimeout(function() {
'use strict';
f.apply(opt_scope, args);
}, interval);
});
}; :target is this and what is it actually running in?npx shadow-cljs release main --debug for :target = :browser{:paths ["src/main" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
com.fulcrologic/fulcro {:mvn/version "3.5.9"}}
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.914"}
thheller/shadow-cljs {:mvn/version "2.16.9"}
binaryage/devtools {:mvn/version "1.0.4"}
cider/cider-nrepl {:mvn/version "0.27.4"}}}}}:browser is not supposed to be bundled by webpack again?IllegalArgumentException No matching field found: getAbsolutePath for class clojure.lang.PersistentHashMap. I know it's probably an error with the way I'm importing the lib, but is there something else I can do to debug this issue?monaco-editor, the full require is ["monaco-editor/esm/vs/editor/editor.api" :as monaco].
This is the stacktrace on the shadow-cljs console:
IllegalArgumentException No matching field found: getAbsolutePath for class clojure.lang.PersistentHashMap
clojure.lang.Reflector.getInstanceField (Reflector.java:397)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
shadow.cljs.devtools.errors/fn--13467 (errors.clj:228)
shadow.cljs.devtools.errors/fn--13467 (errors.clj:222)
clojure.lang.MultiFn.invoke (MultiFn.java:239)
shadow.cljs.devtools.errors/error-format (errors.clj:449)
shadow.cljs.devtools.errors/error-format (errors.clj:440)
shadow.cljs.devtools.errors/error-format (errors.clj:443)
shadow.cljs.devtools.errors/error-format (errors.clj:440)
shadow.cljs.devtools.server.worker.impl/build-failure/fn--14276 (impl.clj:133)
shadow.cljs.devtools.server.worker.impl/build-failure (impl.clj:132)
shadow.cljs.devtools.server.worker.impl/build-failure (impl.clj:128)import from a css file even valid? Why does Monaco is trying to import it? facepalm:js-options {:ignore-asset-requires true}Failed to inspect file
app/node_modules/fsevents/fsevents.node
it was required from
app/node_modules/fsevents/fsevents.js
Errors encountered while trying to parse file
app/node_modules/fsevents/fsevents.node
{:line 1, :column 0, :message "Character '�' (U+FFFD) is not a valid identifier start char"}:target :esm as some of the npm packages I use are esm-only.{:target :esm
:output-dir "resources/js/compiled/backend"
:output-to "resources/js/compiled/backend/main.mjs"
:modules {:main {:init-fn app.backend/main}}}require('./fsevents.node') which fails as the thing is a native module...require fn here?) to not parse *.node as potential js files?:js-options {:js-provider :require} seems to resolve the issue. Hm...file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
^
ReferenceError: WebSocket is not defined
at shadow$cljs$devtools$client$websocket$start (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14)
at Object.attempt_connect_BANG_ (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
at file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.browser.js:1230:36
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:65:12):js-options {:js-provider :import} in your build config:runtime :node (not in :js-options):browser and trying to bundle everything (which is not required for node):js-provider :import variant.:devtools key in builds that are not in the user manual…
{:http-port 8022
:http-resource-root "public"
:http-root "resources/public/js/test"}
is there additional documentation where it’s described how these work?shadow-cljs 2.17.2 (thanks thheller for the help and documentation!). Deploy went well and without issue!
Today we deployed a new version of the app, which included an upgrade to shadow-cljs 2.17.4 . Otherwise we made no changes to the build/compilation process. After the deploy, some users experienced the app crashing; in most scenarios, refreshing the app in-browser fixed things. In looking through our logs, it seemed like some of bundled modules were unable to be loaded. Multiple errors with
Error loading <module>: Consecutive load failuresLooking at the recent commits on https://github.com/thheller/shadow-cljs/commits/master, it seems there were some changes to the Google Module loader. Would those changes have potentially caused breakage for modules built on
2.17.2 vs. modules built on 2.17.4 ?
Also Clojars has 2.17.4, but that version isn't reflected anywhere in the Github repo. Curious to know what's the best way to compare 2 versions via Github to check the diff of commits. Thanks!:module-hash-names that is. works fine without too, just requires telling the server to send proper headers so cache is validated properlyshadow.lazy and shadow.loadable and specifying the modules in shadow-cljs.edn
Our main client.js bundle is cachebusted via appending a client.js?<GIT_SHA>, but the lazy-loaded modules are referenced by only their <module_name>.cljs without a hash. Based on what you described above, the issue could've been a result of the updated client.cljs?<GIT_SHA> bundle loading cached, out-of-date modules (due to browser cache). Is that right?
I don't think we're currently setting any cache-related headers. Sounds like we can either modify those or utilize :module-hash-names . Thanks!:module-hash-names is the safest option yeah. you should look into setting proper headers as well though. never hurts, especially with :module-hash-names you only get the full benefit with proper headers:module-hash-names builds still live on my servermodule-hash-names builds but not delete them? I recall the build process replacing the files each time, but I will double-check thisreact_devtools_backend.js:4061 shadow-cljs - failed to load module$node_modules$react_popper$lib$cjs$index
<snip>
react_devtools_backend.js:4061 TypeError: Cannot redefine property: Popper
at Function.defineProperty (<anonymous>)
at Object.shadow$provide.module$node_modules$react_popper$lib$cjs$index (VM20697 module$node_modules$react_popper$lib$cjs$index.js:1:165)
at Object.shadow.js.jsRequire (js.js:66:18)
at Object.shadow.js.require (js.js:113:20)
at eval (VM20698 nosco.ui.popup.js:7:62)
at eval (<anonymous>)
at Object.goog.globalEval (base.js:503:11)
at Object.env.evalLoad (base.js:1564:12)
at eval (VM20252 main.js:45:12)
at eval (<anonymous>)
It was working but we changed the order of some imports and now we're seeing this. We unfortunately have two version of Popper in our node_modules (v1, v2), they use a different npm artifact. But it seems that if you load them in one order, they work, but not in another order. Other than scouring our deps and removing the old version, could there be any other way to troubleshoot/fix this?watch I assume? not releaseglobal.Popper and also a reference to Object.defineProperty(exports, "Popper", function()...)exports which is never global[2022-02-23 08:42:12.108 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (clojure/tools/reader/edn.clj:75:9). #:clojure.error{:phase :compile-syntax-check, :line 75, :column 9, :source "clojure/tools/reader/edn.clj"}
clojure.lang.Compiler.analyze (Compiler.java:6812)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3824)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7113)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$IfExpr$Parser.parse (Compiler.java:2841)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6124)
clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6440)
Caused by:
RuntimeException No such var: err/throw-no-dispatch
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7392)
clojure.lang.Compiler.resolve (Compiler.java:7362)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7323)
clojure.lang.Compiler.analyze (Compiler.java:6772)
clojure.lang.Compiler.analyze (Compiler.java:6749)
08:42:18.498 [main] INFO io.undertow - starting server: Undertow - 2.2.4.Final[org.clojure/tools.reader "1.3.6"]$ lein run -m shadow.cljs.devtools.cli compile app WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean? 2022-02-23 16:28:48,959 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider [:app] Compiling ... The required namespace "project.core" is not available. "project/core.clj" was found on the classpath. Should this be a .cljs file?
$ npx shadow-cljs compile app shadow-cljs - config: /path/to/project/shadow-cljs.edn WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean? 16:20:38.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider [:app] Compiling ... [:app] Build completed. (340 files, 6 compiled, 13 warnings, 6.31s)
:source-paths or :dependencies in shadow-cljs.edn do not apply:source-paths are just incorrect or missing:cljs profile in project.clj, but top level is fine tooUncaught SyntaxError: Unexpected identifieri've tried a simple or whitespace compilation, i've tried to release with -debug, i've tried to check externs... but i'm really stuck now and don't know where to look... what can i do to get more info about this error?
:release {:compiler-options {:optimizations :whitespace}} right?:advanced for using too much memory or so[:app] Build completed. (1896 files, 0 compiled, 0 warnings, 11.17s) i'm getting that at the end:browser build? are you maybe testing in a really old browser?npm dep).
Back then, I would rm -rf .shadow-cljs , then run the build again to get an entirely fresh build:output-feature-set? it doesn't seem to like the yield:compiler-options {:output-feature-set :es-next} in the build config:es2021 :es2020 etcyield not giving correct js?output-feature-set:es6:pseudo-names true in the compiler options, that may help locate the problem. @teawaterwirecljs.user=> (require '[sicmutils.env :refer [+ ->infix]]) nil cljs.user=> (let [f +] (->infix (f 'x 'x))) "x + x" cljs.user=> (->infix (+ 'x 'x)) ------ WARNING - :invalid-arithmetic ------------------------------------------- Resource: <eval>:1:10 cljs.core/+, all arguments must be numbers, got [cljs.core/Symbol cljs.core/Symbol] instead --------------------------------------------------------------------------------
:require-macros in this nsinfix thing is a macro so for CLJS this needs a self-require (:require-macros [sicmutils.env]):refer. that was just about regular +$ clj -M -m cljs.main Failed to launch a browser: No X11 DISPLAY variable was set, but this program performed an operation which requires it. You can instead launch a non-browser REPL (Node or Nashorn). You can disable automatic browser launch with this REPL option :launch-browser false and you can specify the listen IP address with this REPL option :host "127.0.0.1" Waiting for browser to connect to ... ClojureScript 1.10.866 (+ 'x 'x) WARNING: cljs.core/+, all arguments must be numbers, got [cljs.core/Symbol cljs.core/Symbol] instead at line 1 <cljs repl> "xx"
foo at line X is being replaced if foo is defed elsewhere. Is there a way I can stop that? The project is using shadow-cljs version 2.16.7.(def foo 1) and then (def foo 2) later?def is top level only and shouldn't be used anywhere(defn hello [x] (def x x) (str "Hello " x))Then after I call
(hello "foo") i can evaluate (str "Hello " x) to inspect how my function works.:compiler-options {:warnings {:redef-in-file false}} to disable this particular warning. although I don't recommend doing so since this is a useful warning to warn that you left some debug code which may have unintended side effects for :advanced or so(set! that-def "later")moment library, using moment()
(without params) just works, but when passing any kind of parameter
(e.g. date or string) to the same function, Shadow-cljs raises an
exception.
I've already tried importing and using moment
from cljs and it works well with & without params, so this problem
is only present when using it in JSX code and importing it to cljs.
Someone have had this problem or know any solution?
Thanks!
Here's the stack trace when calling it as moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString() (calling it as moment().toString() doesn't give any problem)
[:app] Compiling ...
[:app] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.classpath/resource "components/common/components/Button/Button.js"] [:shadow.build.classpath/resource "components/common/components/Tag/Tag.js"] [:shadow.build.classpath/resource "components/common/components/Card/hooks/useCard.js"] [:shadow.build.classpath/resource "components/common/components/Card/Card.js"]]}
ExceptionInfo: failed to convert sources
shadow.build.closure/convert-sources*/fn--12611 (closure.clj:1540)
shadow.build.closure/convert-sources* (closure.clj:1534)
shadow.build.closure/convert-sources* (closure.clj:1419)
shadow.build.closure/convert-sources (closure.clj:1759)
shadow.build.closure/convert-sources (closure.clj:1691)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1454)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:463)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:540)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:495)
shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942/fn--15950 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--15941 (util.clj:241)
java.lang.Thread.run (Thread.java:829)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
null
Node(CALL): components/common/components/Card/Card.js:56:6
moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString()
Parent(GETPROP toString): components/common/components/Card/Card.js:56:74
moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString()
com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2907)
com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
com.google.javascript.jscomp.ConstParamCheck.process (ConstParamCheck.java:63)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:566)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/convert-sources*/fn--12611/fn--12612 (closure.clj:1538)
shadow.build.closure/convert-sources*/fn--12611 (closure.clj:1535)
shadow.build.closure/convert-sources* (closure.clj:1534)
shadow.build.closure/convert-sources* (closure.clj:1419)
shadow.build.closure/convert-sources (closure.clj:1759)
shadow.build.closure/convert-sources (closure.clj:1691)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1454)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:463)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:540)
shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:495)
shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942/fn--15950 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--15941 (util.clj:241)
java.lang.Thread.run (Thread.java:829)
Caused by:
NullPointerException: moment(new Date()).toString() raises the same exception.moment though? I mean how was it imported?import moment from 'moment';and in package.json is
"moment": "^2.29.1",(here's the library URL https://momentjs.com/)
["moment" :as moment]
when using the REPL, it just works:
(.toString (moment "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)")) => "Fri Feb 25 2022 12:40:18 GMT-0600"
"2.16.12", I'll update it and try againconst moment = require("moment");
function getFriday() {
const d = "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)";
return moment(d);
}
module.exports = {
getFriday,
};
By replacing the import to
import moment from "moment";will output the error.
import { formatISO } from "date-fns"
and also exporting the function using
export default myFunction
and that works fine when importing into ClojureScript.["moment" :as moment]
when using the REPL, it just works:
(.toString (moment "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)")) => "Fri Feb 25 2022 12:40:18 GMT-0600"
cljs.test/run-testscider-jack-in-cljs in emacs ,the selecting shadow as the repl type
;; ClojureScript REPL type: shadow ;; [:app] Configuring build. [:app] Compiling ... [:app] Build failure: The required namespace "react" is not available, it was required by "reagent/core.cljs". To quit, type: :cljs/quit [:selected :app]It appears to work when I run it from cli:
npm run dev ... shadow-cljs - server version: 2.11.23 running at shadow-cljs - nREPL server started on port 3333 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (165 files, 164 compiled, 0 warnings, 17.84s)What could be a reason for that? It worked fine the last week
Target is it trying to get? like what is the full url of the .map?:devtools {:loader-mode :script} in your build confighost? I mean this is the root of your problem. it doesn't help if you change it 😛:modules:
:shared {:entries []}
:main {:entries [main]
:depends-on #{:shared}
:preloads [dev-preload]}
:worker-pricemeter
{:init-fn workers.pricemeter/init
:depends-on #{:shared}
:web-worker true}
Any ideas?:loader-mode :script to no success:devtools? it won't apply anywhere else. I don't know what "Unknown error" is so I don't have any guesses what it could be:target :browser shadow build?:advanced optimisations, but include some js in the source that's not been modified at all... By include I mean inline.
===== EDIT =====
Ok, I've managed to get it to build, but not sure how to get the js code to inline in correctly?
(I'm also wondering is the appropriate thing to do is to just cat <path to js files> >> shadow-generated.js or is there something better?
I'd like to do everything cljs land, but at the moment generating the correct structures is not going well....js file.gs which is broadly v8 compatible which is what the target is(js* "onOpen(e) { attendomat.core.create_menu(); }") in my .cljs ns instead of appending it 😛/**
* Returns the domain for a given name
* @param {"Apple"} name The value or range of cells
* to lookup the domain for.
* @return The domain of the website
* @customfunction
*/
function WEBSITE_LOOKUP(name) {
Array.isArray(name) ?
name.map(row => row.map(cell => fetch_sitedata(cell, 'domain'))) :
fetch_sitedata(name, 'domain');
}
function test_WEBSITE_LOOKUP() {
Logger.log(String(WEBSITE_LOOKUP("Google")));
}:advanced will otherwise kill it{:source-paths
["src/dev"
"src/main"
"src/js"
"src/test"]
:dependencies
[[applied-science/js-interop "0.3.1"]]
:builds
{:appscript {:output-to "Code.js"
:output-dir "target"
:compiler-options {:externs ["resources/gas.ext.js"]}
:exports-fn humble-app-script.core/generate-exports
:js-options {:js-provider :shadow}
:release {:compiler-options {;:optimizations :whitespace
:pretty-print true}}
:target :npm-module
:entries [example.core]}}}:npm-module or :node-library or :browser?:target :google-appscript or something:target is for. this is neither a browser nor node so none of the above fit.Target ":appscript" for build :appscript was not found. The built-in targets are: - :browser - :browser-test - :node-script - :node-library - :npm-module - :karma - :bootstrap
function normalFunction() {}
async function asyncFunction() {}
function* generatorFunction() {}
var varFunction = function() {}
let letFunction = function() {}
const constFunction = function() {}
var namedVarFunction = function alternateNameVarFunction() {}
let namedLetFunction = function alternateNameLetFunction() {}
const namedConstFunction = function alternateNameConstFunction() {}
var varAsyncFunction = async function() {}
let letAsyncFunction = async function() {}
const constAsyncFunction = async function() {}
var namedVarAsyncFunction = async function alternateNameVarAsyncFunction() {}
let namedLetAsyncFunction = async function alternateNameLetAsyncFunction() {}
const namedConstAsyncFunction = async function alternateNameConstAsyncFunction() {}
var varGeneratorFunction = function*() {}
let letGeneratorFunction = function*() {}
const constGeneratorFunction = function*() {}
var namedVarGeneratorFunction = function* alternateNameVarGeneratorFunction() {}
let namedLetGeneratorFunction = function* alternateNameLetGeneratorFunction() {}
const namedConstGeneratorFunction = function* alternateNameConstGeneratorFunction() {}
var varLambda = () => {}
let letLambda = () => {}
const constLambda = () => {}
var varAsyncLambda = async () => {}
let letAsyncLambda = async () => {}
const constAsyncLambda = async () => {}
Or that are a custom function in the form I gave earlier(defn ^{:export "onOpen"} my-on-open [e] ...)goog.exportSymbol("onOpen", function(e) { ... }) which is not recognized>>(defn hook
{:shadow.build/stage :flush}
[build-state & args]
(spit
(io/file "regular" "out.js")
(slurp (io/file "file-to-append.js"))
:append true)
build-state):target :node-library
and it doesn't like this:
'use strict'; var b, a = global;error:
ReferenceError: global is not defined (anonymous) @ (anonymous) @ (anonymous) @
:node-library the target EXPECTS a node runtime:browser but then disable everything browser related:devtools {:enabled false} in the build configbrowser-repl or node-repl anytime. that is not affected in any waynpx shadow-cljs browser-repl anytime. requires no build config or soargs in the hook you gave contain the final build path?(io/file "regular" "out.js")
build/targets directory on github for how to navigate that 😃(:require ["./entry_points" :as entry-points])
(defn generate-exports []
#js {:fetch_sitedata entry-points/fetch_sitedata})
I've got this in shadow-cljs.edn:
:output-to "Code.js" :exports-fn example/generate-exportsSo when I look inside the
target/main.js there is no fetch_sitedata function defined, I've been grepping for the name and it's not there...
Also not sure why it's ignoring my :output-to instruction and is just generating the file main.js inside target dir...:target:target :browser does not have a :output-to option and neither does it have a :exports-fn optionentry_points.js you are adding it to your build:advanced. which I thought you were trying to avoid?entry_points.js which has some wrapper code which I'm slowly going to be getting rid of, but probably should go through the pipeline and custom_functions.js which I'm appendingentry_points.js need to be called in my clojurescript and for some reason though they're in my :exports-fn example/generate-exports in shadow-cljs.edn, it's not appearing inside the final main.js:target :node-library recognizes :exports-fn. no other target does, so it will do nothing for those. and the only thing that will appear for :node-library is module.exports = your.ns.generate_exports();your.ns.generate_exports() part may be renamed and shortened by :advancedentry_points.js and export them so they're available in the final output.
Should I just create something like this:
(ns example
(:require [clojure.string :as str]
[applied-science.js-interop :as j]
["./entry_points" :as entry-points]))
(def ^:export fetch_sitedata entry-points/fetch_sitedata)
;; OR
(defn ^:export fetch_sitedata [] (entry-points/fetch_sitedata))n("example.fetch_sitedata", vf.fetch_sitedata);
}).call(this);
The definition of fetch_sitedata is missing... vf is probably some import, but one that doesn't seem to contain any of the original fetch_sitedata definition(println (keys build-state)) in the build hook(tap> build-state) and then look at it in tap> in cljs projects:output-to "Code.js" has no effect for :browsertarget/main.js:output-dir + the keys in the :modules mapMakefile or another hook, to copy it to the correct location and append the other file?{:source-paths
["src/dev"
"src/main"
"src/js"
"src/test"]
:dependencies
[[applied-science/js-interop "0.3.1"]]
:builds
{:appscript
{:target :browser
:output-dir "target"
:modules {:main {:entries [app-script.core]}}
:devtools {:enabled false}
:build-hooks [(app-script.hooks/build-hook)]
:compiler-options {:externs ["resources/gas.ext.js"]}}}target/main.js file?entry_points.js isn't getting exportednpx shadow-cljs pom then import pom.xml in cursive as a projectfunction mult_vals(a, b) {
return a * b;
}export function mult_vals(a, b) {
return a * b;
}mult_vals is accessible via entry-points/mult_vals:exports do what you want and it never will(def ^:export mult_vals [a b] (* a b))
entry_points.js indirection does absolutely nothingentry_points stuff? like what does the final generated JS need to look likeentry_points.js contains effectively working code that is broadly legacy.
When I was porting it to cljs I realised that because app-script has it's own weird formats and rules I'd have to feed it javascript to be able to work around some behaviours.
So I split it up into custom_functions.js and the original entry_points.js.
The idea was that anything we couldn't just port over that was externally facing could live inside custom_functions.js. Any legacy stuff that was still in the process of being ported over that was internal behaviour could live in entry_points.js which could be called and wrapped by clojurescript code.
So we have functions like mult_vals which need to be called by functions in the clojurescript code or by functions in custom_functions.js. But are not by themselves public.
I'd prefer to run as much as possible through the closure compiler to minimise / remove stuff we don't need. But in the worst case we can just use simple optimisations for now.entry_points.js and custom_functions.js to the outputjs/mult_vals or whatever in the CLJS codeexport in the .js and re-exporting it so app-script can find it WILL NOT WORK!:export them and refer to them by the full name via the JS that is not going through the closure compilerpublic folder and put the entry_points.js thereindex.html that loads them via <script src="/entry_points.js"> and <script src="/js/main.js">shadow-cljs.edn add :dev-http {3000 "public"} and set :output-dir "public/js" will access to the functions via js/mult_vals or whatever:prepend and :append options in :modules but they only take strings. so doesn't make sense if its too long:modules {:main {:init-fn :append "\n// yo\n"}}}:test {:target :node-test
:output-to "target/test.js"
:ns-regexp "-test$"}
I can get it to work if I pass in the NS directly with like node target/test.js --test=foo.foo-test. It successfully finds 4 -test$ NS's, but no others... I tried using ".*" as the regex also to no avail. I can also confirm that the namespaces are correctly built and are loaded (by chucking a console.log into the built namespace in .shadow-cljs/builds/tests/dev/out/cljs-runtime/foo.foo_test.js). Any ideas?--test optioncljs.test , deftest, and the async macronode target/test.js?--test does is filter out tests that don't match--test does not affect compilation in any way.(async done blah) but didn't call (done) and so stopped the rest of the tests running. But weird that the test completed at all@uiw/react-textarea-code-editor )shadow-cljs info)project.clj or deps.edn? if so the version listed by info does not apply{:asset-path "/js"
:modules {:main {:init-fn app.core/main}}
:output-dir "public/js"
:target :browser}
I can create a minimal projet if you want{:git/url ""
:sha "36894d9fd348576e265a6c129664fba159c4b319"
:exclusions [thheller/shadow-cljs]}
but in the shadow-cljs.edn:source-paths ["src/main" "../that-checkout/src/generated"] or so?:require'd somewhere.shadow-cljs & node_modules/ anything else? (Also tried other places like ~/.cljs which I’m pretty sure shadow doesn’t use)cljs code to the project using a simple config like this from the README:
{:source-paths ["src/cljs"]
:builds {:code
{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [foo]}}}
Seems to work great, I can use it from the js code and it works. Yay!!
I'd now like to make it run seamlessly for everyone using the project (they only use JS).
For me, seamlessly would imply no one else has to run anything else than npm ci , npm test and npm start
The two options I'm looking at are:
• a separate project that would produce a separate npm module and importing that
• hacking it into some sort of public/js build folder and checking in the compiled js files
Is there a recommended way to do this?require("shadow-cljs/some.ns") from the JSnode_modules/whatever instead of use whatever/some.nsmonorepo/ backend1/ backend2/ common-stuff/ ui/
ui is a webpack project, and common-stuff is a clojure project used by both backends.
The idea would be to have parts of that be also accessible to the ui project.ui project and those are the users I'd like to spare knowing about clj at all.:browser-repl resolves an npm dep?(ns town.lilac.solid.web (:require ["solid-js/web/dist/web.cjs" :as web] ["solid-js/h" :as h]))this will pull in both
web/dist/web.cjs from the explicit require, and web/dist/server.cjs as a transitive dependency of solid-js/hsolid-js/package.json instead of the solid-js/web/package.json I believe:js-options {:resolve
{"solid-js/web"
{:target :npm
:require "solid-js/web/dist/web.cjs"}}}
☝️:skin-tone-2: using that in my :app build config fixed it. might help for anyone else who runs across this and for figuring it out later"browser" overridesns with {:skip-goog-provide true} https://github.com/thheller/shadow-cljsjs/blob/master/src/main/firebase/app.cljs. Is it specific to shadow-cljs only?
(ns
{:skip-goog-provide true}
(:require ["@firebase/app" :refer (firebase)]))initializeApp
// Input 293
var firebase = {app:{}}; <------------------------------------------------------------- goog.provide?????
firebase.app.node$module$_CIRCA_firebase$app = __webpack_require__(5752);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d firebase \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d (.-initializeApp firebase) \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app.initializeApp);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d firebase.initializeApp \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app.initializeApp);
goog.exportSymbol("firebase", firebase.app.node$module$_CIRCA_firebase$app);
// Input 294
com.degel = {};
com.degel.re_frame_firebase = {};
com.degel.re_frame_firebase.core = {};
if ("undefined" === typeof com || "undefined" === typeof com.degel || "undefined" === typeof com.degel.re_frame_firebase || "undefined" === typeof com.degel.re_frame_firebase.core || "undefined" === typeof com.degel.re_frame_firebase.core.firebase_state) {
com.degel.re_frame_firebase.core.firebase_state = cljs.core.atom.call(null, cljs.core.PersistentArrayMap.EMPTY);
}
com.degel.re_frame_firebase.core.set_firebase_state = function($var_args$$) {
for (var $args__4824__auto__$jscomp$316_argseq__4825__auto__$$ = [], $len__4818__auto___51875$$ = arguments.length, $i__4819__auto___51876$$ = 0;;) {
if ($i__4819__auto___51876$$ < $len__4818__auto___51875$$) {
$args__4824__auto__$jscomp$316_argseq__4825__auto__$$.push(arguments[$i__4819__auto___51876$$]), $i__4819__auto___51876$$ += 1;
} else {
break;
}
}
$args__4824__auto__$jscomp$316_argseq__4825__auto__$$ = 0 < $args__4824__auto__$jscomp$316_argseq__4825__auto__$$.length ? new cljs.core.IndexedSeq($args__4824__auto__$jscomp$316_argseq__4825__auto__$$.slice(0), 0, null) : null;
return com.degel.re_frame_firebase.core.set_firebase_state.cljs$core$IFn$_invoke$arity$variadic($args__4824__auto__$jscomp$316_argseq__4825__auto__$$);
};
com.degel.re_frame_firebase.core.set_firebase_state.cljs$core$IFn$_invoke$arity$variadic = function($JSCompiler_temp_const$jscomp$9$$) {
$JSCompiler_temp_const$jscomp$9$$ = cljs.core.__destructure_map.call(null, $JSCompiler_temp_const$jscomp$9$$);
var $JSCompiler_temp_const$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "get-user-sub", "get-user-sub", 1337447940)), $JSCompiler_temp_const$jscomp$0$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "set-user-event", "set-user-event", -2139443858)), $JSCompiler_inline_result$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "default-error-handler", "default-error-handler",
2070828115));
$JSCompiler_temp_const$jscomp$9$$ = cljs.core.swap_BANG_;
var $JSCompiler_temp_const$jscomp$1$$ = $JSCompiler_temp_const$jscomp$9$$.call, $JSCompiler_temp_const$jscomp$2$$ = com.degel.re_frame_firebase.core.firebase_state, $JSCompiler_temp_const$jscomp$3$$ = cljs.core.assoc, $JSCompiler_temp_const$jscomp$4$$ = new cljs.core.Keyword(null, "set-user-fn", "set-user-fn", -1107518278);
$JSCompiler_temp_const$jscomp$0$$ = iron.re_utils.event__GT_fn.call(null, $JSCompiler_temp_const$jscomp$0$$);
var $JSCompiler_temp_const$jscomp$5$$ = new cljs.core.Keyword(null, "get-user-fn", "get-user-fn", -1714413522);
$JSCompiler_temp_const$$ = iron.re_utils.sub__GT_fn.call(null, $JSCompiler_temp_const$$);
var $JSCompiler_temp_const$jscomp$6$$ = new cljs.core.Keyword(null, "default-error-handler", "default-error-handler", 2070828115), $JSCompiler_temp_const$jscomp$7$$ = iron.re_utils.event__GT_fn, $JSCompiler_temp_const$jscomp$8$$ = $JSCompiler_temp_const$jscomp$7$$.call;
$JSCompiler_inline_result$$ = cljs.core.truth_($JSCompiler_inline_result$$) ? $JSCompiler_inline_result$$ : alert;
return $JSCompiler_temp_const$jscomp$1$$.call($JSCompiler_temp_const$jscomp$9$$, null, $JSCompiler_temp_const$jscomp$2$$, $JSCompiler_temp_const$jscomp$3$$, $JSCompiler_temp_const$jscomp$4$$, $JSCompiler_temp_const$jscomp$0$$, $JSCompiler_temp_const$jscomp$5$$, $JSCompiler_temp_const$$, $JSCompiler_temp_const$jscomp$6$$, $JSCompiler_temp_const$jscomp$8$$.call($JSCompiler_temp_const$jscomp$7$$, null, $JSCompiler_inline_result$$));
};
com.degel.re_frame_firebase.core.set_firebase_state.cljs$lang$maxFixedArity = 0;
com.degel.re_frame_firebase.core.set_firebase_state.cljs$lang$applyTo = function($seq51872$$) {
return this.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null, $seq51872$$));
};
com.degel.re_frame_firebase.core.initialize_app = function($firebase_app_info$$) {
return firebase.initializeApp(cljs.core.clj__GT_js.call(null, $firebase_app_info$$)); <--------------------------- initializeApp is not a function
};:foreign-libs definition. figwheel supports those, so in theory you don't need the shadow-cljsjs hack:foreign-libs
[{:file "node_modules/@firebase/app/dist/index.cjs.js"
:provides ["@firebase/app"]
:module-type :commonjs}]
Think I need to do this for other @firebase/* (database, firestore). Can I assume CLJS compiler can infer the externs?:target :bundle but how you mock away cljsjs deps I don't know(:require ["@firebase/app"]) directly in your code and not the cljsjs/firebase namespaces then you don't need any of this :foreign-libs stuff:target :bundle and using (:require ["@firebase/app" :as firebase]) seems to work, instead of using js/firebase. Foreign-libs is not need. Thanks$ npx shadow-cljs -A:app release :app
[:app] Compiling ...
relative require ./getComputedStyle from /Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js outside package /Users/redacted/my-project/node_modules/dom-helpers/css
{:package-dir #object[java.io.File 0x7ce3710f "/Users/redacted/my-project/node_modules/dom-helpers/css"], :file #object[java.io.File 0x20ce9d1c "/Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js"], :require "./getComputedStyle"}
ExceptionInfo: relative require ./getComputedStyle from /Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js outside package /Users/redacted/my-project/node_modules/dom-helpers/css
shadow.build.npm/resolve-rel-require (npm.clj:579)
shadow.build.npm/resolve-rel-require (npm.clj:570)
shadow.build.npm/find-resource (npm.clj:783)
shadow.build.npm/find-resource (npm.clj:751)
shadow.build.resolve/find-npm-resource (resolve.clj:122)
shadow.build.resolve/find-npm-resource (resolve.clj:93)
shadow.build.resolve/eval13299/fn--13302 (resolve.clj:262)
clojure.lang.MultiFn.invoke (MultiFn.java:244)
shadow.build.resolve/find-resource-for-string (resolve.clj:80)
shadow.build.resolve/find-resource-for-string (resolve.clj:69)
shadow.build.resolve/resolve-string-require (resolve.clj:453)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:478)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:478)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:478)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:478)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-string-require (resolve.clj:478)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:673)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6829)
clojure.core/reduce (core.clj:6812)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
Does this ring any bells? I downgraded shadow-cljs for now and that’s working, so it’s not urgent :):devtools-url we have to hard-code the port which breaks when the default port (9630) is unavailable. The workaround I found is to add
;; toplevel
:devtools {:use-document-host false}
;; in the build
:closure-defines {shadow.cljs.devtools.client.env.server_host ""}
…which works, but feels like a hack b/c if I put the closure-define as a normal var rather than “munged” (`shadow.cljs.devtools.client.env/server-host`) then it gets overridden somewhere.:http {:host "whatever"} and that will be usedclojure script) wherein I can use it to run my project, compiling it on the fly every time I run it; and I find that convenient.
Thanks!shadow-cljs start && shadow-cljs compile <build> && node path/to/compiled/script.js:node-library target that I would like to use both within node/commonJS and from ES6/import style js code (e.g., react). I'm producing a release js file with shadow-cljs using :advanced optimizations. While I'm clear on how to load js code of different types into clojurescript, I'm less clear from the users guide what if anything is required to go the other way. Is it usable as is with both commonJS and ES6 imports? Or is a further transpiling step needed? And if so, what is the best practice for doing that transformation? Thanks:node-library is meant to run in node as the name implies. so if this is a library intended to run in the browser :target :esm might be better:npm-module is another option:node-library is fine too as long as you don't use node specific things too much:esm is probably the trickiest of the bunch, so maybe avoid that one:js-options {:js-provider :import}Starting development server? thats not a shadow-cljs message(node:33893) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. when I do npm start in the CRA directory.
If this doesn't work, do you have any other suggestions? Thanks again!:esm doesn't work then don't use :esm 😉:npm-module was meant for node/webpack integration, so depending on what you need that may fit best:node-library with conversion is not working. I can try :node-module I suppose. If :esm doesn't work...my list of options grows thin. I had guessed that others have used cljs libraries in a js/react codebase...right?^:export what the JS stuff wants to access:node-library this is done via build config. in :npm-module that is done via metadata in the namespaces:npm-module, does the :entries config require all namespaces to be compiled or only the top-level (export-containing) namespaces?:npm-module build into a`local` directory within the react app project and did import { foo } from './local/main.namespace.js'; where foo is the name of one of several exported symbols. Does that seem right? Webpack is taking a go at it. It's been about 10 minutes so far and it's still working..babelrc into the local dir{
"ignore": ["*.js"]
}.babelrc but that may have changed:esm target for the library, creating a "fake" npm project with the shadow-cljs output file as the index.js, and pointing the "browser" tag in package.json to that file. I then did a local install of the fake npm project. And apparent success.... phew. (I was pretty worried there.) I'm assuming that would then work if packaged to npm as well.
Would it mess up shadow-cljs at all if I put an analogous package.json entry (i.e., using the "browser" tag) in my shadow-cljs project? That would make it pretty straightforward to use this way.
Thanks againshadow-cljs-repl and this gets its value directly from cider's init form. Cider gets a list of builds, converts to keywords, and passes that directly to shadow/nrep-select. I'm thinking that maybe in 1.3 (or for some other reason like local context), the build is not getting set properly when the init form in CIDER is created. Just a hypothesis, but there's not much other action between that and the assertion failure.(cljs.repl.node/repl-env) or whatever the exact form is to init a default CLJS replshadow-cljs-repl. I could be mistaken and I juust took a quick look in response to @U19EVCEBV's query, but that's how it appears. I think this is more likely a CIDER issue. Maybe config if the cider build variable is set strangely...(do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/repl :your-build-id)) var js = FS.readFileSync(filePath);. Am I missing some obvious control on how I would tell the compile job to output a node-library suitable for a browser env?:node-library is intended to run in node:target :npm-module if you want to include in a webpack build or something like that:node-libraryhttps://shadow-cljs.github.io/docs/UsersGuide.html#NodeLibrary instead since it allows for a finer level of control over exports and optimization.
?:node-library works too. just assumes the presence of node for compile and watch builds. release build will also work in the browser:target :npm-module with :runtime :browser will work more reliable and also with compile/watchrelease builds should actually be publishedshadow-cljs release the-build --pseudo-names to make it easier:compiler-options {:optimizations :simple} but that'll make the build much much larger(defn ^:export foo [] ...) is that.ns.foo() in JSVector3, Matrix4 , but something is weird about the way they’re written. what is causing the module$node_modules etc output?[To redirect Truffle log output to a file use one of the following options: * '--log.file=<path>' if the option is passed using a guest language launcher. * '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher. * Configure logging using the polyglot embedding API.] [engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation. The guest application code will therefore be executed in interpreted mode only. Execution only in interpreted mode will strongly impact the guest application performance. For more information on using GraalVM see . To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.Adding
-Dpolyglot.engine.WarnInterpreterOnly=false does remove it in its entirety. But that's only possible because I use deps.edn. Would people using shadow-cljs.edn for their dependencies also be able to suppress the warning?
Maybe this warning something that shadow-cljs can suppress itself?{:paths ["src"]
:deps {thheller/shadow-cljs {:mvn/version "2.17.8"}
superstructor/re-highlight {:mvn/version "1.1.0"}}}
Removing superstructor/re-highlight removes the warning. That dependency doesn't have any CLJS dependencies - only deps.cljs that has this:
{:npm-deps {"highlight.js" "11.1.0"}
:npm-dev-deps {"react" "17.0.2"
"react-dom" "17.0.2"
"shadow-cljs" "2.15.1"
"karma" "6.3.4"
"karma-chrome-launcher" "3.1.0"
"karma-cljs-test" "0.1.0"
"karma-junit-reporter" "2.0.1"}}:npm-deps versions in deps.cljs filesre-highlight has one and removing that will not cause that part of the code to rundeps.cljs files:npm-deps {:install false} in shadow-cljs.edn should also get rid of the warningssemver.js.
If I, say, rewrote that in CLJ, would you use that instead of evaluating semver.js on GraalJS?not=.deps.cljs with version ranges out thereevery? within some within every? within some. :)node-semver seems to be in exactly the same boat...
As an alternative, seems that you can use npm exec to run packages without having to install them - they will be fetched to an internal npm cache that won't interfere with anything, or at least it seems that way.
The current CLI of node-semver doesn't allow for range intersection, but maybe it can be extended.
At least this works:
npm exec --package=semver -- semver -r '1.0.0 - 2.1.0' 1.5.0
node to evaluate semver.js. If npm is installed, then node is installed, and I think it's possible to get its path reliably.semver.js, you can't do anything but keep on warning, right? Even if the ranges are perfectly fine.:npm-deps declared dependencies that overlap or conflict. can only install one. which one do you pick?1.0.0 - 2.0.0 and the other 1.1.0 - 1.9.0 while the installed version is 1.5.0.
There's nothing to warn about, it's all consistent. But how can you check for it without semver.js?1.0.0 - 2.0.0 is not version range ever used in npm^17.0.0 or whatever^ and compare against the othernpm install for :npm-deps found in deps.cljs files:npm-deps but some donpm does not use ranges, but :npm-deps allows it?1.0.0 - 2.0.0 is not version range ever used in npm
^2.0.1 or ~2.0.1. I don't even know what these all mean and really don't care enough to figure that outshadow-cljs install-npm-deps or somethingsemver.js or whatever else
• Just install the highest version and hope for the best (but how will you know which one is the highest without parsing the ranges?)
• Install something according to one found version range and warn if there are other version ranges that aren't byte-for-byte the same
npx shadow-cljs install-npm-deps." seems fine to menpx shadow-cljs audit-npm-depsnpm just won't let you install something that doesn't satisfy the ranges unless you --force it.
Maven/`deps.edn` will just resolve everything and use whatever's available, without complaining. The user will have to explicitly run a command to check if there are any conflicts.||, and it has the highest precedence - the spaces are implied as &&. So something like >1 <8 >2 >3 || <1 is a valid version string.
So:
1. Gather all :npm-deps
2. merge-with them with concatenating the version strings with spaces (replace empty versions with "*")
3. Add to those the contents of package.json, but only for dependencies that were in :npm-deps
4. Run npm install for every accumulated dependency with an explicit version
If there are conflicts, npm will loudly fail. If there are no conflicts, the required dependencies will be installed, if they haven't been installed before.DevTools failed to load source map: Could not load content for : HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
status code 404 suggests that your :asset-path is likely wrong:asset-path is correct. The file is clearly missing, but I have no idea what is attempting to load it. What is supposed to generate that .map file?Receiver reference in function ribelo.fatum.Fail changes meaning when namespace is collapsed. Consider annotating @nocollapse; however, other properties on the receiver may still be collapsed.
(defn Fail
[msg data]
(this-as this
(set! (.-message ^js this) msg)
this))
^{:jsdoc ["@constructor"]}. thats actually importantshadow-cljs - remote-error Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
eval @ shared.cljs:305
shadow$cljs$devtools$client$shared$remote_error @ shared.cljs:18
eval @ websocket.cljs:29
error (async)
shadow$cljs$devtools$client$websocket$start @ websocket.cljs:26
eval @ shared.cljs:324
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shared.cljs:509
eval @ browser.cljs:337
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2245npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :app:
Mar 13, 2022 2:23:42 PM io.undertow.server.handlers.proxy.ProxyHandler$ProxyClientHandler cancel ERROR: UT005027: Timing out request to /vis-network.min.js.mapWhat is the
undertow server for? How can I stop this error?{:source-paths
["src"]
:dependencies
[[re-frame "1.3.0-rc3"]
[com.degel/iron "0.4.0"]]
:builds
{:library
{:target :node-library
:output-to "out/re_frame_firebase.js"
:exports {:initializeApp com.degel.re-frame-firebase.core/initialize-app}}}}
This project is imported as an npm dependency in another project's (`second project`) package.json. On npm install the first project's npm module gets installed successfully.
When I run the second project with shadow-cljs watch app this is the error I get -
[:app] Build failure: The required JS dependency "re-frame-firebase/out" is not available, it was required by "app/fb/init.cljs".I have checked the the npm_modules of the second project -
$ ls node_modules/re-frame-firebase/out re_frame_firebase.jsWhy cant the second project find the above dependency, what am I doing wrong ?
resolve did the trickresolve if you can, it is not ideal.shadow.loader/loadshadow.lazy looks really useful — thanks!lazy-component helper based on shadow.lazydeps.edn and use a git dependencysecond project it is fine to include the sources directly too. no point in writing libraries with exactly one consumer 😉include it from a local directorysecond project "re-frame-firebase": "file:../re-frame-firebase",npm install includes the compiled version along with sources under the node_modulesshadow-cljs.edn by adding :source-paths ["src" "../that-library/src"]package.json through npmjs . But why at the end its a regular js file, how does it matter if I distribute it via clojars (jar) or npmjs (node module) ?lein install on the re-frame-firbase (first project), the jar will just include the sources, and then the shadow-cljs in the second-project will compile it to js ?(def ^:export ...) ?(defmacro defoo [name] `(def ^:export ~name 42))but inspecting the output (I’m targeting
:npm-module) the resulting def doesn’t appear to be exported:
(defoo bar)compiles to
myns.bar = (42);
Object.defineProperty(module.exports, "bar", { enumerable: false, get: function() { return myns.bar; } });enumerable: true if the def is exported(defmacro defoo [name]
`(def ~(with-meta name {:export true}) 42))goog-define ? I'm trying to figure out whether I can have a debug macro that basically disappears in production builds.:reader-features to conditionally execute some top-level code (basically #?(:my-feature (reset! my-atom :my-value))) at the start of a namespace in a library I'm including my build (in order to control how a few macros work), but this code doesn't seem to actually get executed at compile time.
Is this intended, and if so, is there some other way to get build-specific compile-time configuration into a library?cljs.env/*compiler* atom. that has an :options key which is :compiler-options from the build config. so you can set stuff there and do conditional stuff in the macro:reader-features name implies it happens at read time. so emitting them in a macro is not possible:clj reader conditionals end up getting evaluated.:compiler-options will invalidate so it sort of works with caching:jvm-opts in my project.clj) and it seems to work — just one problem: I only want this behavior sometimes. Is is possible to control whether the property is set or not from the command line?shadow-cljs.edn, but I can't see how to control which profile gets applied when invoking shadow-cljs)JAVA_OPTS. (It initially seemed like it wasn't being picked up by leiningen, but that was because I'd made a mistake).:main or :app to browser, I can get a successful repl call to something like (js/alert 1) to work, but can't load any files from my project template (cljs) in repl. I thought my issue may have been emacs/cider specific, but even following the guide on shadow-cljs and said binary to make a client connection presented the same failure - I tried going through the shadow-cljs documentation for that section to no avail - any idea what I may be messing up?shadow-cljs ready log in the browser consoleshadow-cljs watch the-build-id process is runningout/background.js:null:null: var cljs$cst$symbol$response = new cljs.core.Symbol(null, "response", "response", 572107335, null);...............:whitespace regardless though. at the very least :simple better :advanced. I doubt that is responsible for any issue you might seeshadow-cljs release app --pseudo-names and go browsing through the code. through pseudo names you can sort of tell where code comes from and how it got thereNew code readability requirements:simple should be finevar cljs$cst$symbol$response = new cljs.core.Symbol(null, "response", "response", 572107335, null);$ in the variable name or what? 😛:compiler-options {:shadow-keywords true} in the build config. maybe its happy with that? somehow doubt that change anything but it will change that code a little bit[To redirect Truffle log output to a file use one of the following options: * '--log.file=<path>' if the option is passed using a guest language launcher. * '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher. * Configure logging using the polyglot embedding API.] [engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation. The guest application code will therefore be executed in interpreted mode only. Execution only in interpreted mode will strongly impact the guest application performance. For more information on using GraalVM see .
deps.cljs filesmain module and several 'per-view' modules (let's say view-a, view-b, ...). All these modules, including main import a specific ns (let's call it my-ns), but only some of the modules actually use it.
Still, almost all the code from my-ns ends up in main.js. Is there a way to 'move' this code out of main, so that it doesn't get loaded except in the views that use it?shared modules but tbh I'm not sure. I tried code splitting and ran into weird bugs with React or something.:entries [] and have the mods depends on that too. that gives it a chance to move more maybe:advanced can split but the code in namespaces but only if actually used in certain places. if 2 or more places use a thing it can't move:modulesinline to load some resource from the public folder? Or... what is a better place to store resources?
864 | (def resistor-icon (rc/inline "public/css/icons/resistor.svg")) --------------------------^----------------------------------------------------- Encountered error when macroexpanding shadow.resource/inline. Resource not found: public/css/icons/resistor.svg at line 864 nyancad/mosaic/editor.cljs
:source-paths and that solved it:shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@monaco-editor/loader/lib/cjs/loader/index.js", :requires [{:line 135, :column 2}]}
At line 135:
require(['vs/editor/editor.main'], function (monaco) {
storeMonacoInstance(monaco);
state.resolve(monaco);
}, function (error) {
state.reject(error);
});
default property:
(ns uniorg-test.core
(:require
["unified" :refer [unified]]
["uniorg-parse" :as uniorg-parse]
["uniorg-rehype" :as uniorg-rehype]
["uniorg-extract-keywords" :as extract-keywords]
["rehype-react" :as rehype-react]
["react" :refer [createElement]]))
(def processor (-> (unified)
(.use uniorg-parse)
(.use extract-keywords)
(.use uniorg-rehype)
(.use (.-default rehype-react) #js {:createElement createElement})))
(.then (.process processor "* hello org-mode") #(.log js/console %))))["rehype-react$default" :as rehype-react]Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/me/project/node_modules/refractor/index.js from /Users/me/project/app.js not supported. Instead change the require of index.js in /Users/me/project/app.js to a dynamic import() which is available in all CommonJS modules.This was after bumping refractor from
3.3.1 to 4.2.2 . The app.js is built as target :node-library. Is this a known issue with a known fix? I see they converted the refractor code to ESM between those versions, so it now requires import x from y, but app.js contains require("x"):node-library generates commonjs code and that is not allowed to require ESM code. so it fails with that error.:target :esm to generate ESM output which can consume those libs just fineSyntax error compiling at (shadow/build/cljs_hacks.cljc:101:27). No such var: ana/munge-goog-module-libWhat could be the culprit here? Even trying with 2.16.4 I get the same error.
:target npm-module build. I tried different flavors of manual install, but nothing working. Any tips?
{:source-paths ["src"]
:dependencies
[[binaryage/devtools "1.0.5"]]
:builds
{:code
{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [gbo.mycljs]}}}
(ns gbo.mycljs (:require [devtools.core :as devtools]) (defn installCljsDevtools [] (devtools/install!))app.js
var clj = require("shadow-cljs/gbo.mycljs");
clj.installCljsDevtools();
I tried calling the devtools/install! from the html in a different script tag, but was unable to call it as a second namespace, exposed in the global html context.
The resulting js is run through (an older) webpack build, could that be the issue?
My dev server has to run on node 12.6.
But i compile shadow-cljs with latest node, and other functions seem to run ok.:optimizations :none
:builds
{:code
{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [gbo.mycljs]
:compiler-options {:optimizations :whitespace}}}:devtools config with things like
:watch-dir :watch-path :before-load-async :after-load
:npm-module to integrate cljs. But i am open to other suggestions. (Like is it easier to just use another build target?) I prefer to not disrupt the existing js codebase, just add some functions to it.release output?(fn [row-data] (. row-data -field))And this function something on dev build but returns undefined in the release build. My guess is there is something going on in the optimization (obviously). I am curious why it breaks and how to make sure that it works consistently?
(fn [^js row-data] ...)thheller/shadow-cljs {:mvn/version "2.9.10"}clj does not support server-mode - so does that mean that I can't have the app served by shadow in this configuration?:dev-http or any other webserver you want. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http:dev-http but didn't get anywhere ... I'll RTFM again 🙂:buildinternal/modules/cjs/loader.js:818 throw err; ^ Error: Cannot find module 'readline-sync'is that a known issue?
:as-alias within ns but not within a free-standing (require '[foo.bar :as-alias bar]).cljs.user=> (require '[foo.bar :as-alias x]) nil cljs.user=> ::x/foo :foo.bar/foo
> shadow-cljs info shadow-cljs - config: /home/ae/src/ablution/cljs/ablu.ui/shadow-cljs.edn === Version jar: 2.17.8 cli: 2.17.8 deps: 1.3.2 config-version: 2.17.8
> shadow-cljs watch app shadow-cljs - HTTP server available at shadow-cljs - server version: 2.17.8 running at shadow-cljs - nREPL server started on port 3333 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build failure: ------ ERROR ------------------------------------------------------------------- File: /home/ae/src/ablution/cljs/ablu.ui/src/ae/ablution/ui/core.cljs:11:1 -------------------------------------------------------------------------------- 8 | [ae.ablution.address.interface.spec :as a.spec] 9 | [ae.ablution.ui.views :as views])) 10 | 11 | (require '[foo.bar :as-alias bar]) -------^------------------------------------------------------------------------ null Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: [foo.bar :as-alias bar] at line 11 ae/ablution/ui/core.cljs -------------------------------------------------------------------------------- 12 | 13 | (defn ^:export init 14 | [] 15 | (router/start!) --------------------------------------------------------------------------------
require there. that needs to be part of the ns :requirerequire otherwise only works in the REPL(ns foo.bar (:require [other.foo :as x] [other.bar :as-alias y])) and donerequire ouside ns that ultimately doesn't end up workingdefclass ! I had been struggling with js/Reflect.construct gobj/extend js/Object.create js/Object.assign (.call Class this props) and nothing seemed to go the way I wanted. At first defclass also seemed to not work but figured it out just fine eventually!PrismLight (as described under "Light Build": https://github.com/react-syntax-highlighter/react-syntax-highlighter#light-build), which is meant to only pull in Prism.js itself plus languages that are explicitly specified.
Yet, both Prism.js and Highlight.js, together with all the supported languages are included in my shadow-cljs build output. What can I do to avoid this?target/index.js is ALL["react-syntax-highlighter"] = require("react-syntax-highlighter");)node_modules/react-syntax-highlighter(:require ["react-syntax-highlighter/dist/cjs/prism-light.js"]) or so:targetshadow-cljs.edn only, or would I create a cljs file for each separate language?(:require ["react-syntax-highlighter/dist/cjs/prism-async.js"]) or so:modules statically.:browser target or so. this is non-trivial and will require digging fairly deep into the internals of shadow-cljs though 😛:simple optimizations I get
java.time.OffsetDateTime = java.time.goog$module$goog$object.get(module$node_modules$$js_joda$core$dist$js_joda, "OffsetDateTime"); java.time.OffsetTime = java.time.goog$module$goog$object.get(module$node_modules$$js_joda$core$dist$js_joda, "OffsetTime");
module$node_modules$$js_joda$core$dist$js_joda lacks both OffsetDateTime and OffsetTime. Currently running on 5.2.0 for @js-joda/core , and they should be there from what I can tell. All other modules are existingrm -rf node_modules && npm i solved the problemdeploy install is the end of the world. (They are leiningen projects.)lein projects, so I can do lein install and have either refreshed in a few seconds.
The bad news is, I still have to reboot the shadow watch and server to pick up the changed jar. Unless I am missing something.
And I do not know if you can take advantage of lein install, or if shadow has the equivalent. This, however, looks encouraging: https://shadow-cljs.github.io/docs/UsersGuide.html#publish-lein And there may well be a simpler shadow command the cognoscenti can provide.lein new app, and get on with my coding with my fingers crossed.
Does "just use lein" mean:
• create a minimalist project.clj as documented in https://shadow-cljs.github.io/docs/UsersGuide.html#publish-lein
• then lein deps will Do the Right Thing? Including maintaining, pom.xml, I see?
• or is it just for lein deploy clojars?
• will checkouts work automagically as long as I run lein deps after a change to the contents of checkouts?
Thx!lein as you normally do. so you put your :dependencies and :source-paths in project.clj. then add the checkouts you want to that project. then you also add the thheller/shadow-cljs dependency to that project.clj.shadow-cljs.edn you set :lein true or :lein {:profile "+cljs"} (if you use a leinigen profile):as-alias support yet. 1.11.4 is not it.lazy-component ?:advanced works that very rarely works:external will move all JS deps into one single file.worker.js:67 Uncaught Error: Namespace "goog.dispose" already declared.. Does anyone know why this is?
shadow-cljs config:
:worker {:init-fn my.app.worker/load!
:depends-on #{:shared}
:web-worker true}}
my.app.worker:
(ns my.app.worker) (js/console.log "worker/read!") (defn load! [] (js/console.log "worker/load!"))https://my.app:
(defn init []
(let [worker (js/Worker. "/js/worker.js")]
(.addEventListener worker "message" notify-worker-message)))2.16.12. Updated it to the latest and everything worked like a charm 🙂npx shadow-cljs server but I'm running into an error:
shadow-cljs - starting via "clojure" Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. Full report at: /var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-15894664129410946386.edn
{:clojure.main/message
"Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n",
:clojure.main/triage
{:clojure.error/class java.io.FileNotFoundException,
:clojure.error/line 40,
:clojure.error/cause
"Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
:clojure.error/symbol clojure.main/main,
:clojure.error/source "main.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.io.FileNotFoundException,
:message
"Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
:at [clojure.lang.RT load "RT.java" 462]}],
:trace
[[clojure.lang.RT load "RT.java" 462]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6908 invoke "core.clj" 6161]
[clojure.core$load invokeStatic "core.clj" 6160]
[clojure.core$load doInvoke "core.clj" 6144]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5933]
[clojure.core$load_one invoke "core.clj" 5928]
[clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
[clojure.core$load_lib invokeStatic "core.clj" 5974]
[clojure.core$load_lib doInvoke "core.clj" 5953]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 6016]
[clojure.core$load_libs doInvoke "core.clj" 6000]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 6038]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause
"Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath."}}
I'm using version 2.17.8 for both JS and Clojure.
My deps.edn:
{:paths ["src/main", "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.0"}
com.fulcrologic/fulcro {:mvn/version "3.5.15"}
com.taoensso/timbre {:mvn/version "5.2.1"}}
:aliases {:dev {:extra-paths ["src/dev"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.11.4"}
binaryage/devtools {:mvn/version "1.0.5"}
cider/cider-nrepl {:mvn/version "0.28.3"}
thheller/shadow-cljs {:mvn/version "2.17.8"}}}}}
My shadow-cljs.edn:
{:deps {:aliases [:dev]}
:dev-http {8000 "classpath:public"}
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:modules {:main {:init-fn quizlet.client/init
:entries [quizlet.client]}}
:devtools {:after-load quizlet.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload
com.fulcrologic.fulcro.inspect.dom-picker-preload
quizlet.development-preload]}}}}.cpcache folder~/.m2/repository/thheller/shadow-cljsWARNING: Specified aliases are undeclared: [:-A]:deps you are telling shadow-cljs to run tools.deps clojure command. that should be fine but may break if thats not the standard thingclojure -A:dev -M -m shadow.cljs.devtools.cli serverdeps.ednclojure?clojure command for you?clojure and clj give the same outputclj -version?deps.ednExecution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2). -version (No such file or directory) Full report at: /var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-9249228989860048614.edn
clj -version$ clj -version Clojure CLI version 1.10.3.855
clj -Sdescribe?cljclj tool itselfclj -Sdescribe
{:version "1.10.1.561"
:config-files ["/usr/local/Cellar/clojure/1.10.1.561/deps.edn" "/Users/eoogbe/.clojure/deps.edn" "deps.edn" ]
:config-user "/Users/eoogbe/.clojure/deps.edn"
:config-project "deps.edn"
:install-dir "/usr/local/Cellar/clojure/1.10.1.561"
:config-dir "/Users/eoogbe/.clojure"
:cache-dir ".cpcache"
:force false
:repro false
:resolve-aliases ""
:classpath-aliases ""
:jvm-aliases ""
:main-aliases ""
:all-aliases ""}brew upgrade clojure/tools/clojure doesn't work. I'm going to try to reinstall with brew. Hopefully it doesn't clobber it(ns presentation.cognito.auth (:require ["amazon-cognito-identity-js" :refer (CognitoUserPool)]))but whenever i try to use
CognitoUserPool it says its an undeclared var(ns presentation.cognito.auth (:require ["amazon-cognito-identity-js$default" :as CognitoUserPool]))but that didnt work either
(ns presentation.cognito.auth (:require ["amazon-cognito-identity-js$default" :refer (CognitoUserPool)]))
:as since CognitoUserPool is not the default export:shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(ns presentation.cognito.auth\n (:require [\"amazon-cognito-identity-js$default\" :refer (CognitoUserPool) ]))", :ns presentation.cognito.auth, :repl true}, :include-init false, :call-id 7, :from 10}}
StackOverflowError
shadow.build.npm/find-resource (npm.clj:726)
when i try to evaluate the namespace(->> (shadow.cljs.devtools.api/repl-runtimes :browser)
(last)
:proc-id
(hash-map :proc-id)
(shadow.cljs.devtools.api/repl :browser))
This successfully connects to a repl and I can execute arbitrary code (i.e. (+ 1 1)) but I still can’t access any contextrepl-runtimes)client-id is the runtime-id (small numeric number). Was able to get it working with:
(->> (shadow.cljs.devtools.api/repl-runtimes :browser)
(last)
:client-id
(hash-map :runtime-id)
(shadow.cljs.devtools.api/repl :browser)))
With this and inspect shadow-cljs is unstoppable!:client-id and :runtime-id:deps {:aliases [:dev]} to my shadow conf. Running clj -M:dev has no error
Execution error (ClassCastException) at clojure.tools.cli/tokenize-args (cli.cljc:34). class clojure.lang.ArraySeq cannot be cast to class java.lang.CharSequence (clojure.lang.ArraySeq is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')
{:paths ["src/clj" "src/cljc" "src/cljs" "resources"]
:deps
{buddy/buddy-auth {:mvn/version "3.0.323"}
buddy/buddy-core {:mvn/version "1.10.413"}
buddy/buddy-hashers {:mvn/version "1.8.158"}
buddy/buddy-sign {:mvn/version "3.4.333"}
ch.qos.logback/logback-classic {:mvn/version "1.2.10"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
clojure.java-time/clojure.java-time {:mvn/version "0.3.3"}
com.cognitect/transit-clj {:mvn/version "1.0.329"}
com.cognitect/transit-cljs {:mvn/version "0.8.269"}
conman/conman {:mvn/version "0.9.3"}
cprop/cprop {:mvn/version "0.1.19"}
day8.re-frame/http-fx {:mvn/version "0.2.4"}
expound/expound {:mvn/version "0.9.0"}
funcool/struct {:mvn/version "1.4.0"}
haslett/haslett {:mvn/version "0.1.7"}
json-html/json-html {:mvn/version "0.4.7"}
luminus-http-kit/luminus-http-kit {:mvn/version "0.1.9"}
luminus-migrations/luminus-migrations {:mvn/version "0.7.1"}
luminus-transit/luminus-transit {:mvn/version "0.1.5"}
luminus/ring-ttl-session {:mvn/version "0.3.3"}
markdown-clj/markdown-clj {:mvn/version "1.10.8"}
metosin/muuntaja {:mvn/version "0.6.8"}
metosin/reitit {:mvn/version "0.5.15"}
metosin/ring-http-response {:mvn/version "0.9.3"}
mount/mount {:mvn/version "0.1.16"}
nrepl/nrepl {:mvn/version "0.9.0"}
org.babashka/sci {:mvn/version "0.3.3"}
org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
org.clojure/core.async {:mvn/version "1.5.648"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
org.postgresql/postgresql {:mvn/version "42.3.2"}
org.webjars.npm/bulma {:mvn/version "0.9.3"}
org.webjars.npm/material-icons {:mvn/version "1.0.0"}
org.webjars/webjars-locator {:mvn/version "0.42"}
re-frame/re-frame {:mvn/version "1.2.0"}
reagent/reagent {:mvn/version "1.1.0"}
ring-webjars/ring-webjars {:mvn/version "0.2.0"}
ring/ring-core {:mvn/version "1.9.5"}
ring/ring-defaults {:mvn/version "0.3.3"}
selmer/selmer {:mvn/version "1.12.50"}
thheller/shadow-cljs {:mvn/version "2.17.8"}}
:aliases
{:dev
{:jvm-opts ["-Dconf=dev-config.edn"]
:extra-paths ["env/dev/clj" "env/dev/cljs" "env/dev/resources" "test/cljs"]
:extra-deps {binaryage/devtools {:mvn/version "1.0.5"}
cider/piggieback {:mvn/version "0.5.3"}
org.clojure/tools.namespace {:mvn/version "1.2.0"}
prone/prone {:mvn/version "2021-04-23"}
re-frisk-remote/re-frisk-remote {:mvn/version "1.5.2"}
ring/ring-devel {:mvn/version "1.9.5"}
ring/ring-mock {:mvn/version "0.4.0"}}
:main-opts ["-m" "user"]}
:test
{:jvm-opts ["-Dconf=test-config.edn"]
:extra-paths ["test"]
:extra-deps {pjstadig/humane-test-output {:mvn/version "0.11.0"}}}
;; Linter
:eastwood
{:main-opts ["-m" "eastwood.lint"
;; Any Eastwood options can be passed here as edn:
{}]
:extra-deps {jonase/eastwood {:mvn/version "1.2.3"}}}}}:dev alias having :main-opts:main-opts , removed and is working fine, but I cannot load the clojure user namespace anymore. do you have any idea how to specify it into deps or shadow-dev?-main function doesn't run if you mean thatclj -M:dev and run shadow-cljs in embedded mode from that https://shadow-cljs.github.io/docs/UsersGuide.html#embeddedrelease build, I’m getting an error that it cannot connect to ws://<domain>:9630. I’m tried deleting the build directory and re-releasing without running the watch command but I’m still getting ws/REPL/UI code. Is this a known issue? The only references I have to any shadow modules in my codebase are shadow.loader to load static files, those calls have not changed
Full error:
websocket.cljs:12 Mixed Content: The page at 'https://<domain>/pixi' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://<domain>:9630/api/remote-relay?server-token=c17d72ac-00fb-482a-8eb5-3ac7c88e9fba'. This request has been blocked; this endpoint must be available over WSS.:9630? are you maybe loading an outdated file?:9630 is for the development websocket(js/Worker. ...) is webworker. that is fine and not related.shadow.cljs.devtools namespaces in your code somewhere? or in your build config?DOMException: The operation is insecure. The above error occurred when loading "shadow.cljs.devtools.client.browser.js".
release app:npm-module build?(shadow/repl :the-build-id {:runtime-id that-id-number})(shadow/repl-runtimes :the-build-id)if (!doc) {
throw new Error("browser bootstrap used in incorrect target");
}:target :chrome-extension I guess:target :esm is better:esm gives me "cannot import module" or something and :chrome-extension gives me a "Cannot find manifest.edn" stacktrace in the console.:chrome-extension in a thread here.[:modules] Configuring build. [:modules] Build failure: FileNotFoundException: manifest.edn (No such file or directory) java.io.FileInputStream.open0 (FileInputStream.java:-2) java.io.FileInputStream.open (FileInputStream.java:219) java.io.FileInputStream.<init> (FileInputStream.java:157) (io.clj:229) (io.clj:229) (io.clj:69) (io.clj:165) (io.clj:165) (io.clj:69) (io.clj:102) (io.clj:86) clojure.core/apply (core.clj:669) clojure.core/slurp (core.clj:7009) clojure.core/slurp (core.clj:7009) shadow.build.targets.chrome-extension/configure (chrome_extension.clj:59) shadow.build.targets.chrome-extension/configure (chrome_extension.clj:48) shadow.build.targets.chrome-extension/process (chrome_extension.clj:310) shadow.build.targets.chrome-extension/process (chrome_extension.clj:305) clojure.lang.Var.invoke (Var.java:384) shadow.build/process-stage/fn--14625 (build.clj:161) shadow.build/process-stage (build.clj:158) shadow.build/process-stage (build.clj:150) shadow.build/configure (build.clj:389) shadow.build/configure (build.clj:274) shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:205) shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:156) shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:571) shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:565) shadow.cljs.devtools.server.util/server-thread/fn--15932/fn--15933/fn--15941 (util.clj:269) shadow.cljs.devtools.server.util/server-thread/fn--15932/fn--15933 (util.clj:268) shadow.cljs.devtools.server.util/server-thread/fn--15932 (util.clj:241) java.lang.Thread.run (Thread.java:829)
{:deps true
:dev-http {7778 ["classpath:public"]}
:builds
{:modules
{:js-options {;; don't bundle any npm libs
:js-provider :import}
:compiler-options {:infer-externs :auto}
:target :chrome-extension
:output-dir "resources/public/js"
:modules
{:nrepl_extension {:init-fn nrepl-extension.core/init}
}
:build-hooks [(shadow.cljs.build-report/hook
{:output-to "report.html"})
]}}}:esm config and just changed :targetmanifest.edn it is looking for:compiler-options {:infer-externs :auto} has been the default for quite some time now. you never need to set it.:target :esm is absolutely the way to go now and is fully supported. just may need to set "type":"module" in some places apparentlyDec 27, 2017 so not accurate anymore:chrome-extension did to sometimes create standalone files should not be needed anymorecontent-scripts still seem to be a bit more limited, although might just work too"background": { "service_worker": "bg.js", "type": "module" },(gensym) from clojure a whole lot. which uses an increasing integer to make the symbols unique. so some# becomes some_1234 or so:compiler-options {:parallel-build false} in your build config to turn off multithread during compilationjvm-opts to ["--engine.WarnInterpreterOnly=false"] in my shadow-cljs.edn
shadow-cljs - config: /Users/esciaf/Projects/full-stack/shadow-cljs.edn [To redirect Truffle log output to a file use one of the following options: * '--log.file=<path>' if the option is passed using a guest language launcher. * '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher. * Configure logging using the polyglot embedding API.] [engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation. The guest application code will therefore be executed in interpreted mode only. Execution only in interpreted mode will strongly impact the guest application performance. For more information on using GraalVM see . To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
shadow-cljs watch blogg
and my shadow-cljs.edn looks like this:
{:source-paths ["src/cljs"]
:nrepl {:port 9888}
:dependencies [[cider/cider-nrepl "0.21.0"]
[cljs-ajax "0.8.0"]
[reagent "1.0.0-alpha2"]
[re-frame "1.3.0-rc3"]
[binaryage/devtools "1.0.4"]]
:builds {:blogg {:target :browser
:compiler-options {:output-feature-set :es6}
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:init-fn blogg.core/init}}
:devtools {:http-root "resources/public"
:http-port 4888}}}}["--engine.WarnInterpreterOnly=false"] should be `["-Dpolyglot.engine.WarnInterpreterOnly
=false"]`-D sets propertiesextra-paths for shadow-cljs.edn's :build field. (I wish to separate some paths for Node.js back and browser front)ERROR Warning: blahblahblah for example
in Pressable
in Button (created by example.code/SomeElement)
in RCTView (at View.js:32)
in View (created by example.code/SomeElement)
in RCTView (at View.js:32)
...:target?:target in your build config https://shadow-cljs.github.io/docs/UsersGuide.html#target-node :node-script or :node-library?:node-script{...
:builds
{:back-dev {:target :node-script
:main myproject.back.core/back-main
:output-dir "build/back"
:output-to "build/back/main.js"}
...}}
Then I run the jack-in command which runs npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :back-dev
Then I'm asked to choose a "Project type" (all :builds entries are present). I select shadow-cljs.
Then I'm asked to "select builds to start". I choose only :back-dev
Then I'm asked to "select which build to connect to". I have all builds as options plus node-repl and browser-repl. When I select :back-dev, I get a No available JS runtime. When I select node-repl, I can evaluate my code but the hot reloading as describe in the documentation doesn't work.
I tried all options : inline ^:dev/before-load and ns ^:dev/always or in the config file. with :autoload set to true. I can't see any callbacks executed nor new définitions containing new values.
Do you think that it might be a Calva problem or a shadow configuration problem on my side?
Thanks a lot.node-repl that is a purely standalone REPL. it does not do hot reloading and is not coupled to your build:back-dev that is your project. you just actually need to run it to get a REPLnode build/back/main.js in another terminal or so.cljc file
(ns kol.macros
#?(:cljs
(:require-macros [kol.macros :refer [deftheme]])
(:require ["@codemirror/view" :refer [EditorView]])))
(defmacro deftheme [name theme]
#?(:cljs
`(def ~name
(.theme EditorView (clj->js ~theme)))
:clj nil))
(comment
(macroexpand
'(deftheme darko {:.cm-content {:caret-color "cursor"}}))
and is expanded like this
(def darko (.theme kol.macros/EditorView (kol.macros/clj->js {:.cm-content {:caret-color "cursor"}})))
but instead of resolving EditorView as kol.macros/EditorView I need to point to the npm library#?(:clj
(defmacro deftheme [name theme]
`(def ~name
(.theme ~'EditorView (clj->js ~theme))))(def darko (theme {:.cm-content {:caret-color "cursor"}}))kol.macros ns that does the above basically. ie. create a helper function that calls the npm depcreate-theme , thanks!:node-test build (which has :autorun true) when watching it? What I would like to do is run only a subset of the tests on rebuild which would be possible by passing a --test option to the default main. Alternative solutions welcome, too, of course 🙏:node-test doesn't support connecting a REPL so I would have to have an equivalent :node-library build for that purpose, right? If so, what's the recommended way of running tests from the REPL then? Just invoke shadow.test.node/main like the :node-test runner does?npx shadow-cljs node-replcljs.user=> (require 'cljs.test) nil cljs.user=> (require 'test.js-interop-test) nil > (cljs.test/run-tests 'test.js-interop-test) Testing test.js-interop-test Ran 2 tests containing 9 assertions. 0 failures, 0 errors. nil cljs.user=>
shadow.test.node/main and found shadow.test/run-test-vars which does the trick but weirdly the REPL process terminates after invoking itshadow.test.node. shadow.test is fine but the shadow.test.node is for the test runner which will exit after running:js-options {:js-provider :external} options?:modules you can use just fine:node-test doesn't support connecting a REPL so I would have to have an equivalent :node-library build for that purpose, right? If so, what's the recommended way of running tests from the REPL then? Just invoke shadow.test.node/main like the :node-test runner does?touch node_modules/that-package/package.json will trigger a reload of that-package. well at least a recompile, hot reload is not really supported given how commonjs works.cljs files. Is this on purpose or to be considered a bug?example.cljc file in the ClojureScript REPL bypasses the cache?(shadow/node-repl) in the Cursive CLJ REPLshadow-cljs watch :code, get server + nrepl port, connect to it (in cursive, ,via port), run (shadow/repl :code) I get No available JS runtime. Any not sure how to procede.
Here is my shadow-cljs.end
{:source-paths ["src"]
:dependencies
[[binaryage/devtools "1.0.5"]]
:builds
{:code
{:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [gbo.mycljs]}}}:npm-module can in theory have a REPL but it depends on how and where you are including the code. if another tools processes it too much it won't work. eg. webpack can work but also can break horribly 😛:runtime :browser or :runtime :node in the build configif (process.env.NODE_ENV === "development") { require("shadow-cljs/shadow.cljs.devtools.client.browser") } or sosrc/main path to a project I'm working on. ie. keep the regular dependency and then just override it with local sources. then just poke at it from the REPL.src/main path could work 🙂.
My problem is with react-native builds, somehow I see no stacktrace at all (only the munged function name). I was thinking if I could debug it and at least know what's wrong(try (my-code) (catch :default e) (println (-stack e)), and indeed the filename and row are missing(devtools.api/watch target {:autobuild false}) and (devtools.api/watch-compile! target)? At the moment I’m using the build history coming from the server instance ref (`(get @(:state-ref (:build-history @devtools.server.runtime/instance-ref)) target)`) but if it’s possible to get it via a channel that would be nicer. I tried to use the :channels :output channel coming from the worker state ref but subscribing to that seemed to cause some issues:compiling is so I can see if the build succeeded or failed programmaticallyuser.clj or so? or is that one started just via shadow-cljs server or shadow-cljs watch ..?devtools.server/start! and then api/watch :target-name(sys-bus/sub (:system-bus @shadow.cljs.devtools.server.runtime/instance-ref) :shadow.cljs.model/worker-broadcast your-channel)sys-bus being shadow.cljs.devtools.server.system-busyour-channel being a core.async channel you create and read from. or close when done:shadow.cljs.model/worker-broadcast listens to all build workers[:shadow.cljs.model/worker-output build-id] instead would just be the output for the specified build(ns dev
(:require
[shadow.cljs.devtools.api :as shadow]))
(defn setup
{:shadow/requires-server true}
[]
;; Start your other watchers here, using libraries like juxt dirwatch
(shadow/watch :front))
Then just run
yarn shadow-cljs run dev/setupInstead of shadow-cljs watch.
package.json solution using
• https://www.npmjs.com/package/copy-and-watch
• https://www.npmjs.com/package/concurrently["copy-to-clipboard" :refer [copy]] but I get the following error:
Uncaught TypeError: module$node_modules$copy_to_clipboard$index.copy is not a function
at eval (effects.cljs:66:5)
at re_frame$fx$do_fx_after (fx.cljc:59:23)
at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:70:6)
at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:108:24)
at Object.re_frame$interceptor$execute [as execute] (interceptor.cljc:201:8)
at Object.re_frame$events$handle [as handle] (events.cljc:65:14)
at Object.eval [as re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1] (router.cljc:179:10)
at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198:44)
at eval (router.cljc:146:64)
at Object.eval [as re_frame$router$IEventQueue$_fsm_trigger$arity$3]
I've also tried ["copy-to-clipboard" :as copy] which seems more like what is shown in the example. But it doesn't seem to work and returns no errors.:as does the trick.foo.css require but also a foo.css.js file exists. those should work fine.js files don't exist you only option is going with webpack yesnpx shadow-cljs watch appand webpack watching with
npx webpack watchVery cool! :thumbsup: One thing I did try to probe the limitations is to comment out and re-add a js-library, which rebuilds the target js-file and in turn causes webpack to rebuild the “lib-file”. I get the impression hot reloading doesn’t work in that case? Or is there some magic that can be applied to fix even that scenario?
(ns website.my-component)
(defn <my-component>
[]
[:div "Hello world!"])
(ns website.core
(:require ["react" :as react]
[shadow.lazy :as lazy]
[reagent.core]
[reagent.dom]))
(def *<my-component>
(lazy/loadable website.my-component/<my-component>))
(defn <app-root>
[]
[:> react/Suspense {:fallback (reagent.core/as-element [:div "Loading..."])}
[:>
(if (lazy/ready? *<my-component>)
(reagent.core/reactify-component (fn [& _] [@*<my-component>]))
(react/lazy
#(do (prn "loading step 1")
(-> (lazy/load *<my-component>)
(.then (fn [_<elem>]
(prn "loading step 2")
#js {:default (reagent.core/as-element
(fn [& _]
(prn "loading step 3")
[@*<my-component>]))}))))))]])
(defn init-app!
[]
(reagent.dom/render [<app-root>] (.getElementById js/document "app")))
Firefox prints both "loading step n" statements, whereas Chromium only prints "loading step 1". No errors are logged to the console in either case. Any idea what's wrong?s/def?def* 😉React.lazy I mean?react/lazy just like in https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs#L16 if that's what you mean:default (reagent.core/as-element this also seems wrongdefing the react/lazy call and see if that resolves it(ns website.my-component)
(defn <my-component>
[]
[:div "Hello world!"])
(ns website.core
(:require ["react" :as react]
[shadow.lazy :as lazy]
[reagent.core]
[reagent.dom]))
(def *<my-component>
(lazy/loadable website.my-component/<my-component>))
(def lazy-component
(react/lazy
#(do (prn "loading step 1")
(-> (lazy/load *<my-component>)
(.then (fn [_]
(prn "loading step 2")
#js {:default (reagent.core/reactify-component
(fn [& _]
(prn "loading step 3")
[:div "hello"]))}))))))
(defn <app-root>
[]
[:> react/Suspense {:fallback (reagent.core/as-element [:div "Loading..."])}
[:> lazy-component]])
(defn init-app!
[]
(reagent.dom/render [<app-root>] (.getElementById js/document "app")))(lazy/ready? *<my-component>)?[:> lazy-component] nothing elsereact/lazy on every renderreact/lazy to a def I forgot to get rid of itreact/lazy is to call it on every renderprn when debugging stuff(js/console.log ...) instead. async printing is icky if you expect output to show up in the REPL[:div "hello"] instead of the actual lazy component?error: Error: Unable to resolve module from /Users/matthew/Drive/dev/mobile2/target/app/index.js: could not be found within the project or in these directories:
node_modules
> 1 | var $CLJS = global;
| ^
2 | var shadow$start = new Date().getTime();
3 | var shadow$provide = global.shadow$provide = {};
4 | var goog = global.goog = {};metro bundler.shadow-cljs and all build files:dev-http server that can't happen since it sets the proper cache headersSHADOW_ENV.evalLoad do?$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };(defonce landing-bg (js/require (config/asset-path "landing-bg.jpg")))with
(defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg"))Then the
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
will be gone.
In my code, config/asset-path is a macro. The output of (config/asset-path "landing-bg.jpg") is exactly “../../resources/assets/landing-bg.jpg”.$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); }; line compared to the case of a vanilla (defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg")) .js/require must be a single simple string. macros are not supported there.(defonce landing-bg (js/require (config/asset-path "landing-bg.jpg")))gets converted to
(defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg"))It’s just this piece is missing
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
(defasset landing-bg "landing-bg.jpg") is a macro you could write instead that just emits the (defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg")) for you(defonce landing-bg (js/require (my-macro "landing-bg.jpg")))
js/require with a string argument. nothing elsejs/require with a macro argument (this is before expansion)$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
is not possible in the current cljs/shadow compiler.js/require with a string argumentjs/require call with a string argumentcurl -O docs/UsersGuide.html is the fileclojure script) be installed?deps.edn ?throw er; // Unhandled 'error' event
^
Error: spawn clojure ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn clojure',
path: 'clojure',
spawnargs: [ '-M', '-m', 'shadow.cljs.devtools.cli', '--npm', 'server' ]
}
Node.js v17.8.0:deps in shadow-cljs.edn that tells shadow-cljs to use the clojure tool and deps.edn yesdeps.edn, but ok, no worries, thank you![2022-04-07 22:51:42.126 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(clojure.core/refer-clojure)", :ns app.wallet, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns app.wallet, :form (clojure.core/refer-clojure), :source "(clojure.core/refer-clojure)", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:502)
shadow.cljs.repl/process-read-result (repl.clj:476)
shadow.cljs.repl/process-input (repl.clj:661)
shadow.cljs.repl/process-input (repl.clj:639)
shadow.cljs.devtools.server.worker.impl/fn--14599 (impl.clj:698)
shadow.cljs.devtools.server.worker.impl/fn--14599 (impl.clj:688)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--14273/fn--14274/fn--14282 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--14273/fn--14274 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--14273 (util.clj:241)
java.lang.Thread.run (Thread.java:829)
Caused by:
ExceptionInfo ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form) {:rename-macros nil, :renames {}, :use-macros nil, :excludes #{}, :name app.wallet, :op :ns*, :env {:fn-scope [], :locals {}, :js-globals {console {:op :js-var, :name console, :ns js}, location {:op :js-var, :name location, :ns js}, escape {:op :js-var, :name escape, :ns js}, screen {:op :js-var, :name screen, :ns js}, global {:op :js-var, :name global, :ns js}, process {:op :js-var, :name process, :ns js}, require {:op :js-var, :name require, :ns js}, alert {:op :js-var, :name alert, :ns js}, history {:op :js-var, :name history, :ns js}, window {:op :js-var, :name window, :ns js}, module {:op :js-var, :name module, :ns js}, exports {:op :js-var, :name exports, :ns js}, document {:op :js-var, :name document, :ns js}, navigator {:op :js-var, :name navigator, :ns js}, unescape {:op :js-var, :name unescape, :ns js}}, :ns {:rename-macros nil, :renames {}, :meta {:file "app/wallet.cljs", :line 1, :column 5, :end-line 1, :end-column 15}, :ns-aliases {cljs.loader shadow.loader, react shadow.js.shim.module$react, clojure.pprint cljs.pprint, clojure.spec.alpha cljs.spec.alpha}, :use-macros nil, :excludes #{}, :shadow/js-access-properties #{"Text"}, :name app.wallet, :reader-aliases {}, :js-aliases {"react-native" shadow.js.shim.module$react_native}, :imports nil, :requires {cljs.core cljs.core, goog goog, shadow.js.shim.module$react_native shadow.js.shim.module$react_native, rn shadow.js.shim.module$react_native}, :seen #{:require}, :uses nil, :defs {wallet-tab {:protocol-inline nil, :meta {:file "app/wallet.cljs", :line 5, :column 7, :end-line 5, :end-column 17, :arglists (quote ([]))}, :name app.wallet/wallet-tab, :file "app/wallet.cljs", :end-column 17, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :variadic? false, :line 5, :ret-tag cljs.core/IVector, :end-line 5, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}}, :require-macros {cljs.core cljs.core}, :cljs.analyzer/constants {:seen #{:>}, :order [:>]}, :flags {:require #{}}, :js-deps {"react-native" {:as rn}}, :deps [goog cljs.core shadow.js.shim.module$react_native]}, :def-emits-var true, :shadow.build/mode :dev, :column 1, :shadow.build/tweaks false, :line 1, :shadow.build.compiler/repl-context true, :context :expr}, :imports nil, :requires nil, :uses nil, :reload {:use nil, :require nil, :use-macros nil, :require-macros nil}, :require-macros nil, :form (ns* (:refer-clojure)), :reloads {}, :deps []}
shadow.build.compiler/post-analyze (compiler.clj:94)
shadow.build.compiler/post-analyze (compiler.clj:89)
shadow.build.compiler/analyze/fn--12392 (compiler.clj:265)
shadow.build.compiler/analyze (compiler.clj:252)
shadow.build.compiler/analyze (compiler.clj:211)
shadow.cljs.repl/repl-compile/fn--14080/fn--14081 (repl.clj:441)
shadow.cljs.repl/repl-compile/fn--14080 (repl.clj:414)
shadow.cljs.repl/repl-compile (repl.clj:412)
shadow.cljs.repl/repl-compile (repl.clj:409)
shadow.cljs.repl/process-read-result (repl.clj:500)
shadow.cljs.repl/process-read-result (repl.clj:476)(ns app.wallet (:require ["react-native" :as rn])) (defn wallet-tab [] [:> rn/Text "Wallet"]) (comment (js/console.log "dasdf"))
(ns app.event) (def initialize-app ::initialize-app) (def set-active-view ::set-active-view)will also result in the shadow error.
(refer-clojure) throws an error in shadow-cljs and also prints a huge map
{:rename-macros nil, :renames {}, :use-macros nil, :excludes #{}, :name calva.fmt.formatter, :op :ns*, :env {:fn-scope [], :locals {}, :js-globals {console {...
Is this a bug? It's fine evaluating that in a vanilla ClojureScript REPL.refer-clojure is supposed to do 😛(in-ns …) and that switches to the namespace, but doesn't make Clojure core available. Then some while ago I read the in-ns info on this page a bit more carefully: https://clojure.org/guides/repl/navigating_namespaces#_switching_to_an_existing_namespace_with_in_nsrefere-clojure is just a function. in CLJS it technically doesn't even exist since it can't do what it does in CLJ(refer-clojure) isn't needed in ClojureScript REPLs. So then I'll mainly skip that for cljs sessions and am good with that.in-ns before the ns exists. even in cljsrefer-clojure.(if (find-ns 'foo) (in-ns 'foo) (ns foo))?Namespaces that are known to include side-effecting macros can be blocked from caching. What is side-effecting macro and what bad outcome will happen if the namespace containing it is cached?/ts-dir and /cljs-dir. The /ts-dir is a webpack project that produces its js via npm run build. The /cljs-dir has a reference in its package.json dependencies as "my-ts-code": "../ts-dir". I'm re-building the typescript with a simple find src | entr npm run build in a separate terminal window.
As it stands, I seem to have to restart shadow to get it to notice the new bundled JS from /ts-dir.touch node_modules/my-ts-code/package.json to make shadow-cljs recompile it. hot-reload is very unlikely to work in that kind of setup thoughnode_modules instead of symlinking ittouchnpm i (with npm 8.5.0) in /cljs-dir just symlinks /ts-dir -> /cljs-dir/node_modules/my-ts-code and it doesn't look like shadow watching crosses the symlink. I tried manually setting up a copy in /cljs-dir/node_modules/my-ts-code and rsyncing but that seems to yank something important out from under shadow. Shadow notices, but I get a "can't find module" message. (I can do it again to get the exact phrasing ... forgot to copy it).node_modules are not watched at all. only the package.json is checked. so thats why you touch ittouch on the package.json on the far side of the symlinkmodule is there?(require [xxx :default foobar])but looking at the manual again, it now becomes
(require ["xxx$default" :as foobar])
$default is the recommended. :default was a shadow-cljs only addition that was not compatible with regular CLJS. the $default also works in regular CLJS(ns app.style
(:require
["twrnc" :rename {default foo}]
["twrnc$default" :as foo2]))
I tested they are the same, but not sure under what circumstance they will become different.(ns app.style (:require ["twrnc" :as twrnc] ["twrnc$default" :as tw]))Either
twrnc or tw is nil.clojure.string my bundle size my bundle size jumps up 2mb. Is that normal?
( :target :npm-module ,release build, then bundled w webpack 1.15.0 )
And the bundle.js is no longer minified.:advanced optimizations or did you change it to :simple? do you do an actual shadow-cljs release build or just a webpack release build? did you configure webpack to inline source maps? many factors can lead to large builds, need more info to comment further.devtool: 'source-map' in webpack.conf.js. Also tried devtool: 'hidden-source-map'``. I am doing a shadow-cljs release code, then run the webpack release build.
The cljs is compiled/minified. But something is keeping the webpack build from finishishing it’s process I think. Maybe too old a version of weback. But I have been reluctant to upgrade in fear of breaking legacy js code.:output-dir. just make sure you ignore .map filesclojure.string definitely won't be contributing much overall:npm-module build? it shouldn't have any of thsoe?:output-dir "node_modules/shadow-cljs"require("bigcommerce/stencil_utils")require("jquery")(:require
["@bigcommerce/stencil-utils" :as utils]
["jquery" :as jq]
[clojure.string :as string]):npm-module builds shadow-cljs doesn't bundle any npm dependencies at all$default stuff in the require?var clj = require("shadow-cljs/gbo.mycljs");import { clj__GT_js } from 'shadow-cljs/cljs.core';if (process.env.NODE_ENV === "development") { require("shadow-cljs/devtools.preload"); } in your JS might workbase_url?"localhost:8280" or something but when releasing this should be ""{thheller/shadow-cljs$aot {:mvn/version "2.18.0"}}
There is a warning: WARNING: shadow-cljs not installed in project.npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :app npx. so just npm install shadow-cljs. not related to the aot version in any way.npx
Why is it a necessity? The reason I use npx is that I do not need to install shadow.node-repl source maps and other stuffnpx shadow-cljs. The prompted as in the first picture. I then checked the directory _npx, i found the source-map and other dependencies are all installed.mkdir -p test && cd test npm install -D shadow-cljs
node_modules/shadow-cljs dir is part of your project test dir. and the above in somewhere outside the project dirnpx shadow-cljs is all fine, except the shadow-cljs not installed in the project warning.:node-script build to output to the out directory in the project directory. run node out/whatever.js.npx, just as shadow-cljs does not look in ~/.npx when compilingnpx works. but this is not at all what this warning is about. it is about compilation and running outputs. NOT about running shadow-cljs itselfshadow-cljs completelyclj -A:dev -M -m shadow.cljs.devtools.cli watch app is similar to npx shadow-cljs watch app. only server mode is not supported. as described https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html:es5 to :es2018 -- I saw a very small change in the bundle size, I'm not sure why but I was expecting a bit more. Like, in our base bundle, we went from 279kb to 276kb gzip. Perhaps a total of another 5kb gzip across everything else. Not complaining, just curious if this is to be expected.v2.18.0 and to v2.17.0 and also to v2.16.0 in my project
v2.15.0 seems to work ok.
the error message is a bit verbose but I'll just paste it hereExceptionInfo: failed to convert sources
shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1953)
shadow.build.closure/convert-sources-simple* (closure.clj:1940)
shadow.build.closure/convert-sources-simple* (closure.clj:1818)
shadow.build.closure/convert-sources-simple (closure.clj:2112)
shadow.build.closure/convert-sources-simple (closure.clj:2064)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1463)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:463)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.api/compile* (api.clj:296)
shadow.cljs.devtools.api/compile* (api.clj:292)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
Unexpected variable layoutCssVars
Node(NAME layoutCssVars): node_modules/react-data-grid/lib/bundle.js:652:4
layoutCssVars,
Parent(STRING_KEY layoutCssVars): node_modules/react-data-grid/lib/bundle.js:652:4
layoutCssVars,
com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2907)
com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
com.google.javascript.jscomp.NodeTraversal.traverseRoots (NodeTraversal.java:486)
com.google.javascript.jscomp.NodeTraversal.access$400 (NodeTraversal.java:38)
com.google.javascript.jscomp.NodeTraversal$Builder.traverseRoots (NodeTraversal.java:406)
com.google.javascript.jscomp.VarCheck.process (VarCheck.java:154)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/convert-sources-simple*/fn--11356/fn--11357 (closure.clj:1943)
shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1941)
shadow.build.closure/convert-sources-simple* (closure.clj:1940)
shadow.build.closure/convert-sources-simple* (closure.clj:1818)
shadow.build.closure/convert-sources-simple (closure.clj:2112)
shadow.build.closure/convert-sources-simple (closure.clj:2064)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1463)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:463)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.api/compile* (api.clj:296)
shadow.cljs.devtools.api/compile* (api.clj:292)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
IllegalStateException: Unexpected variable layoutCssVars
com.google.javascript.jscomp.VarCheck.handleUndeclaredVariableRef (VarCheck.java:291)
com.google.javascript.jscomp.VarCheck.checkName (VarCheck.java:213)
com.google.javascript.jscomp.VarCheck.visit (VarCheck.java:173)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:856)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:984)
com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:748)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:800)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseRoots (NodeTraversal.java:482)
com.google.javascript.jscomp.NodeTraversal.access$400 (NodeTraversal.java:38)
com.google.javascript.jscomp.NodeTraversal$Builder.traverseRoots (NodeTraversal.java:406)
com.google.javascript.jscomp.VarCheck.process (VarCheck.java:154)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/convert-sources-simple*/fn--11356/fn--11357 (closure.clj:1943)
shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1941)
shadow.build.closure/convert-sources-simple* (closure.clj:1940)
shadow.build.closure/convert-sources-simple* (closure.clj:1818)
shadow.build.closure/convert-sources-simple (closure.clj:2112)
shadow.build.closure/convert-sources-simple (closure.clj:2064)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1463)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:463)
shadow.build/compile (build.clj:453)
shadow.cljs.devtools.api/compile* (api.clj:296)
shadow.cljs.devtools.api/compile* (api.clj:292)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
error Command failed with exit code 1.
info Visit for documentation about this command.
error Command failed with exit code 1.
info Visit for documentation about this command.node_modules/react-data-grid/lib/bundle.js too if that's needed> (324234 ]
Failed to read: clojure.lang.ExceptionInfo: dummy.cljs [line 1, col 11] Unmatched delimiter ]. {:type :reader-exception, :ex-kind :reader-error, :file "dummy.cljs", :line 1, :col 11}
Whenever I mistype something, the REPL becomes unresponsive and I have to quit and restart it to continue.["electron" :refer (app BrowserWindow crashReporter dialog)] and everything in there works fine. But when I import in the renderer like ["electron" :refer (remote)] it always breaks. I tried looking at a bunch of different electron examples because i originally thought I was (and perhaps still am) miss-using the electron library but now I’m starting to wonder if my shadow configuration is messed up.{:source-paths
["src"]
:dev-http {8080 "resources/public/"}
:dependencies
[[reagent "1.1.0"]
[re-frisk "1.5.2"]
[re-frame "1.2.0"]
[thheller/shadow-cljs "2.17.8"]]
:builds {:main {:target :node-script
:output-to "resources/main.js"
:main app.main.core/main}
:renderer {:target :browser
:output-dir "resources/public/js"
:asset-path "js"
:devtools {:watch-dir "resources/public"
:preloads [re-frisk.preload]}
:modules {:renderer {:init-fn app.renderer.core/start!}}}}}deps.cljs with {:npm-deps {"that-package" "version"}} on the classpath of the lib. that'll tell CLJS about the npm dependency and install it:css-dirs setting of figwheel-main for CSS hot reload but we don't have CSS hot reload with shadow-cljs now, probably due to incorrect config.
We're not using the dev http server of shadow-cljs. We're serving our HTML/CSS/JS with the CLJ application. We get the updated css with page refresh but it doesn't hot reload.
Below is our shadow-cljs config(truncated):
{:builds {:app {:target :browser
:output-dir "frontend/public/js"
:asset-path "/js"
:devtools {:watch-dir "frontend/public"}}}}
And here is the directory structure of our codebase(truncated):
frontend/ └── public ├── css │ ├── main.css │ └── main.css.map └── js ├── app.js ├── app.js.map ├── cljs-runtime └── manifest.edn resources/public/ ├── css │ ├── animations.less │ ├── mixins.less │ ├── variables.less │ └── etc... ├── extra ├── fonts ├── img └── js
frontend and resources dirs lives under the app dir on the same level and both of them are in the classpath.
Another process automatically compiles less files under resources/public/css and outputs to frontend/public/css/main.css.
Can you point out what is wrong with my config?link tag is absolute:
<link href="/css/main.css" rel="stylesheet preload" type="text/css" as="style" />
:watch-dir currently only applies when the watch is started. so if you made adjustments while it was running they might not be activerel="stylesheet". preload should be a separate tag? didn't even know you are allowed to combine them?shadow-cljs watch app1 app2 app3 same for all other commandsrelease will not be parallel, watch will be(defn release [& args] (shadow/release! :foo) (shadow/release! :bar) ...)(future (shadow/release ...)) to start it in a threadshadow-cljs config:
{:source-paths ["src"]
:dependencies []
:builds {:code {:target :npm-module
:output-dir "node_modules/shadow-cljs"
:entries [app]}}}
src/app.cljs:
(ns app) (defn ^:export hello [] "Hello World!")
src/App.js:
import { hello } from "shadow-cljs/app";
but i get the following error: Uncaught ReferenceError: process is not defined
the culprit appears to be the compiled cljs_env.js:
var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;any insight into what i might be missing here?
Define plugin to webpack, with process defined with whatever you need it to be, this will at least let it compile
Though I'm very curious as to why it's not already defined and what that means for the evaluation of cljs_env.jscraco to accomplish something like that, but I assume shadow-cljs needs values that are populated in there?
It looks to be defined in cljs.core.async.js:
var process = (function (p__14390){...cljs_env.js file imported or loaded in particular way? I am not sure how it is able to depend on a global reference that is undefined at runtime. I have not personally looked at shadow's source code.
However, I wonder if:
1. This has something to do closure compiler/libs bespoke module loading system interacting weirdly with cra/webpack
2. This has something to do with your setup in particular. Is the example code you've posted actually the minimum reproducible source code - ie, what you've seen this issue come up in?craco next -- I'm certainly at a wall otherwise. But no apologies needed! 🙂 I'm very happy to receive all the help I can get.
I have been suspecting that the interaction with webpack is somehow to blame here..
As far as the code, the only thing I haven't shared is the results of yarn create react-app. I can put together a small minimal reproduction and commit it somewhere if it would be of interest.
To answer your first question, I have been going on https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module. In part they read:
> If you use the default :output-dir of "node_modules/shadow-cljs" you can access the declared namespaces by using require("shadow-cljs/demo.foo") in JS.
I'm not quite doing that, as I have import statements instead. Doing import { hello } from "shadow-cljs/app" leads to the error because the compiled app file has a require('cljs_env.js'):target :npm-module by default assumes a node runtime. so add :runtime :browser to the build config. that should remove that reference to processprocess is still there;; ;; shadow-cljs configuration
{:source-paths ["src"]
:dependencies []
:builds {:code {:target :npm-module
:runtime :browser
:output-dir "node_modules/shadow-cljs"
:entries []}}}
If there is any further insight on what is going on here, I'd really appreciate it 🙃:target :esm is probably a better choice these days regarding interop. https://clojureverse.org/t/generating-es-modules-browser-deno/6116:js-options {:js-provider :import} to the build config:js-provider to no avail. I'll try :target :esm next:js-provider was meant for :target :esm sorry:target :esm works, but only when run as shadow-cljs release . build and watch produce many build errors for webpack. I'll push soon to a branch on the reposrc/generated/cljs-runtime/cljs.core.async.impl.buffers.js Line 2:1: 'goog' is not defined no-undef Line 3:1: 'cljs' is not defined no-undef
target-esm-dev branch:
git clone -b target-esm-dev globalThis and actually do exist:target :esm but I get errors when I try to import it in the react app. I’ve tried including :js-options {:js-provider :import} but the compilation process fails when I do claiming the namespace react is not available when required by reagent/core.cljs. Have any of you encountered a similar error by any chance?TypeError: undefined is not an object (evaluating 'cljs.core.async.interop._LT_p_BANG_')Example code:
(ns simple.example (:require [cljs.core.async :refer [go]] [cljs.core.async.interop :refer [<p!]])) (go (println (<p! (js/Promise.resolve 42))))
:target is this? any compilation errors? any console warnings/errors besides that one?<p! as a function. but it is a macro, so that does not work. dunno why. need more info and reproducible example would helpapp.example is not required anywhere, so it is not part of the buildapp.main and it will be compiled properlyshadow-cljs -> metro -> runtime. in case of the REPL it directly goes shadow-cljs -> runtime since there is no way to tell metro to compile a small piece of codemetro does will be missing so there is no way to tell how these variants of code interactnbb I have to require es6 modules like this: ["passport$default" :as passport] and in shadow-cljs i have to require them like this: ["passport" :as passport] - I am employing https://github.com/chr15m/sitefox/blob/main/src/sitefox/deps.cljc to make my library work under both nbb and shadow-cljs. Is there no way that I can reconcile these with a single require syntax? Is there any chance shadow-cljs would support "passport$default" in the future?:target :esm the $default will just work (as that is also what nbb is using):node-script or :node-library or :npm-module those all output commonjs, where require is just differentnode in module mode too of course when using :esm:target :esm on consumers of the library so i'm at a bit of a loss what to do.:target :node-script can't use the $default syntax and :target :esm has to be used instead if i want that?:esm and change my npm create projects to run the server in esm mode instead. :thinking_face:$default is not related to esm or build target in any way. it is syntax sugar, nothing else. think of foo$default translating to require("foo").default or in the case of ESM and using import it translates directly to import default from "foo"$default - i.e. replace it with whitespace, when used in commonjs mode? or is that just a terrible idea?link tags in your DOM I guess and point it to the CSS file on disk, trigger that action on change somehow:browser build so technically it would be easy to add. there just aren't any options for itconfig-merge argument, but that option only works if you have a file on disk already. If you have nothing, shadow-cljs exits as there is no "root" shadow-cljs.edn file to merge into.npx whatever-build-cmd without any shadow-cljs config and that build command can set the environment variable to point shadow-cljs to ./node_modules/whatever-npm-package/shadow-cljs.edn . But again, definitively hear your arguments against it, I don't want to add any more maintainer burden to youSHADOW_CLJS_CONFIG=../path/to/config.edn npx shadow-cljs release build-id so users install my npm package, then run npx whatever-build-cmd which transparently calls the right shadow-cljs commands:target instead of a whole build toolshadow-cljs.edn as it is and in the build config create the absolute minimum you need to build your tool. could just wrap the :browser target with some defaultsshadow-cljs.edn config is already the bare minimum, you can possibly make the build config smaller by making something figma specificconfig-merge option helps users to add specific parts if they want to (like additional runtime dependencies)^:dev/after-load stuff moving the "config" closer to the actual code(reg-event ::m/init! (fn ...))::ev/handle would implicitly register itself with some global registry?shadow.cljs.devtools.api/release or compile or watch all take a build-id argument(js/Worker. "/...<path-to-web-worker>.js"). Sometimes I changed the assay path and forgot to update this line as well.goog.DEBUG depends on what you do, in theory it can allow to remove some code yesrc-slider, and in their example, they do this (in js):const Slider = require('rc-slider');
const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);(require '["rc-slider" :as rcs]) (rcs/createSliderWithTooltip rcs/Range)
rcs/createSliderWithTooltip is just nil, so I'm clearly reading this wrong.shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$ThemeProvider shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$indexI looked at the related stack traces, and they mention the bootstrap build, so I tried to exclude the
ns I imported from the bootstrap build, but with no effect.2.18.0, and now here's a more complete error message:
(It won't let me copy/paste the exception info as text, so here's an image)sci instead of using the bootstrap build,eval for development purposes you can use https://clojureverse.org/t/status-update-inspect-cljs-eval/6074#cljs_eval-2sci. That way, there's no mysterious build happening anymore, which I imagine will eliminate most of these issues.2.18.0 that I mentioned above?:exclude mentioned in the docs anymore (?)2.18.0.
You said before you didn't know "what I was doing", but I have a basic reagent application. I'm doing a shadow-cljs watch my-build bootstrap and basically if I modify my site.css file, I get a shadow-cljs exception in my console when it reloads my site.css file.
It also doesn't overwrite or update an existing style, but seems to load/create duplicate styles (if I'm looking at elements in a chrome inspector).
What kind of information could I provide that would help to debug this?cljs.core:dev/asset-load hook anywhere in your code?:dev/asset-load anywhere in the code at all.
• I'm sorry but I don't understand the question about the log showing up - at this point, the only error occurring is when I save my CSS file, and shadow-cljs reloads it - that's when these log messages show up, and there are no other errors or warnings before or after. Please help me understand what I'm failing to explain here.
• Where should I put that (devtools-msg ... line?:dev/asset-load hook:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.18.0"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}:dev/asset-load exists, so it definitely isn't in my code, and I've verified this by grepping everything in the project.rc-slider. translation looks correct.shadow-cljs with deno and working repl?shadow-cljs compile returns code that worksshadow-cljs watch is already crashingregister-component indeed calls that function, but some other mechanism is needed to trick RN to rerender all the app
(defn register-component {:dev/after-load true}
[]
(.registerComponent ^js (.-AppRegistry rn)
"myapp"
;; wrap in :>f to make a functional component
#(r/reactify-component (constantly [:f> app]))))forceUpdate method, but seems the result from r/reactify-component does not contain such field.:require form that looks like this:
(ns cljs.user
(:require ["lodash"]
["/common/relay/relay-env"]))
…where my config has :source-paths ["src"] and my file system has src/common/relay/relay-env.js. When I evaluate the above form, shadow-cljs seems to find relay-env.js just fine, but trips up on the first line of relay-env.js:
import ajaxPath from "common/api/ajaxPath";…where
src/common/api/ajaxPath.js is also on my file system. I get the error:
The required JS dependency "common/api/ajaxPath" is not available, it was required by "common/relay/relay-env.js…but it works if I manually change the import statement (note the leading
/)
import ajaxPath from "/common/api/ajaxPath";I’m getting the impression that when shadow-cljs resolves the imports inside of
.js files, it follows the same convention as resolving .js files in ClojureScript :require forms. That’s to say, it requires the leading / if it’s going to look on the local file system, otherwise it checks node_modules.
Is there a way I can get around this without manually changing all my .js import statements? I’m trying to work with a large codebase of existing .js files that all use this relative import style.:target :node-script build in which I try to dynamically load an ESM module with (js/import "module-name-here"), which gives me ReferenceError: import$ is not defined. Is there a work around to this? Is there a way to consume an ESM module dynamically?:node-script and :browser builds?:browser will most likely just work if you just require it normally. dynamic import will not work unless you use :target :esm instead:node-script really. if you plan on using lots of ESM it is best to use ESM yourself:esm target doesn't seem to resolve any of the node native modules though...
The required namespace "child_process" is not available, it was required by "blah-blah".
:js-options {:js-provider :import} in your build configchild_process is now seemingly imported fine, but the very next import of electron fails: The required namespace "electron" is not available, it was required by "blah-blah". I made sure electron is in the dependencies in package.json, cleaned everything up, re-installed with npm i, the result is the same. any hints?(:require [electron ...])? A symbol? should be (:require ["electron" ...]) isntead?(:require ["child_process" :as cp] ["electron"] ...
{:target :esm
:output-dir "resources/js/compiled/main"
:modules {:main {:entries [app.main]}}
:devtools {:repl-pprint true}
:compiler-options {:output-feature-set :es-next}
:js-options {:js-package-dirs ["node_modules"]
:js-provider :import}
:main app.main/main
:dev {:closure-defines
{app.config/DEV true}}}:main app.main/main has no effect in :esm but otherwise looks finenode_modules/electron/package.json?Error: ENOENT: no such file or directory, open '...app/.shadow-cljs/builds/main/dev/out/cljs-runtime/goog.debug.error.js'
require itself, which being an esm module, fails...
App threw an error during load Error [ERR_REQUIRE_ESM]: require() of ES Module ...app/resources/js/compiled/main/main.js from ...app/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js not supported. Instead change the require of ...app/resources/js/compiled/main/main.js in ...app/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js to a dynamic import() which is available in all CommonJS modules.
import work but the trouble is the closure compiler may break it when optimizingjs/import getting renamed to import$ is just the compiler being annoying. you can use (js* "import(\"whatever\)") to not have it do that{:main
{:target :esm
:output-dir "resources/js/compiled/main"
:modules {:main {:entries [relm.main]}}
:devtools {:console-support false
:hud false
:repl-pprint true}
:compiler-options {:output-feature-set :es-next}
:js-options {:entry-keys ["module" "browser" "main"]
:js-package-dirs ["node_modules"]
:js-provider :import}
:dev {:closure-defines
{relm.config/DEV true}}}}[:main] Build completed. (144 files, 2 compiled, 0 warnings, 0.18s)
.cjs script to make it possible to load everything in electron:
global.__relm__dirname = __dirname;
global.Electron = require("electron");
global.WebSocket = require("isomorphic-ws");
import("./compiled/main/main.js");(node:28006) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `Electron --trace-warnings ...` to show where the warning was created)
(node:28006) UnhandledPromiseRejectionWarning: ...app/resources/js/compiled/main/main.js:3
import "./cljs-runtime/shadow.module.main.prepend.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1038:15)
at Module._compile (node:internal/modules/cjs/loader:1072:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:829:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
(node:28006) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 1)
^C...app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINTpackage.json with { "type": "module" } in resources/js, so electron treats everything under that folder as being esm by default.require another package...
(node:27663) UnhandledPromiseRejectionWarning: ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '...app/resources/js/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file://...app/resources/js/compiled/main/cljs-runtime/cljs.nodejs.js:3:23
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
(Use `Electron --trace-warnings ...` to show where the warning was created)
(node:27663) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 2)
^C...app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINTcljs-runtime/cljs.nodejs.js maybe be using esm-style imports under the hood when compiled with :target :esm?macchiato.server ns from the macchiato/core package. Looking at its source, I guess the problem is caused by lines like this one: https://github.com/macchiato-framework/macchiato-core/blob/85c5e3b0b55095565543a3dc876849f71df354d4/src/macchiato/server.cljs#L16node stands for:
(ns macchiato.server
(:require
[cljs.nodejs :as node]
...macchiato library is only meant to be used as a part of a normal node script, and will not work in an esm environment ever?cljs.nodejs is not a shadow-cljs wrapper, but a part of the cljs runtime: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/nodejs.cljsmacchiato from using the node's require I guess...express from npmcljs.nodejs ns at all:target :esm the resulting code insists on using the global WebSocket object. That works in a browser, but is not available by default in node. That's why I have the following bit in the loader file:
global.WebSocket = require("isomorphic-ws");:target :esm defaults to assuming a browser runtime. thus it injects some code for the REPL which uses the websocket so hot-reload and stuff workcommon/api/ajaxPath in node_modules. unless you explicitely configure it not to. there is no matching option for this currently though.The required namespace "goog.debug.Logger.Level" is not available, it was required by "fulcro/logging.cljc"{:deps {:aliases [:dev :cljs]}
:builds {:app {:target :browser
:output-dir "dev-resources/public/js"
:asset-path "/public/js"
:modules {:main {:init-fn com.aareon.dp.monitor.core/run}}}}
:dev-http {3000 ["dev-resources/public" "dev-resources/public/js"]}}:dev-http at all. just remove itdev-resources/public as files via either the ring-resource middleware (probably just public then, assuming dev-resources is part of the classpath) or the ring-file middleware:dev or :release value merged into it correctly? It's needed to make things use proper shadow-cljs values when using clj-run.
Currently, I have this abomination:
(defn- get-config [build-id mode]
(let [init (shadow.build.api/init)
build-config (shadow/get-build-config build-id)
build-state (shadow.build/configure init mode build-config)]
(:shadow.build/config build-state)))sass know where to put the resulting CSS files (I'm really averse to hard-coding the values everywhere but the config)
• Automatically open a browser tab with the URL that matches a :dev-http entry for a specific build{
version : 3,
file: "app.js",
sections: [
{ offset: {line:0, column:0}, url: "url_for_part1.map" }
{ offset: {line:100, column:10}, map:
{
version : 3,
file: "section.js",
sources: ["foo.js", "bar.js"],
names: ["src", "maps", "are", "fun"],
mappings: "AAAA,E;;ABCDE;"
}
}
],
}
While a more traditional “section-less” format, that works with Sentry, looks like:
{
"version" : 3,
"file": "out.js",
"sourceRoot": "",
"sources": ["foo.js", "bar.js"],
"sourcesContent": [null, null],
"names": ["src", "maps", "are", "fun"],
"mappings": "A,AAAB;;ABCDE;"
}
(some info on source-maps formats I found https://sourcemaps.info/spec.html)
I went through the shadow-cljs code (https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L355-L375) but I didn’t find any option to output source-maps in “section-less” format so I tried to convert it in {:shadow.build/stage :flush} build hook.
However, the naive merging sections back to the top-level map didn’t work - it went past initial sentry’s parsing error "Sourcemap was invalid or not parseable" but then it hit errors like "Invalid location in sourcemap: (37101, 117)".
my naive (not working) attempt:
(defn flatten-source-map [path]
(let [source-map (-> (io/file path)
slurp
ch/decode)
sections (get source-map "sections")]
(->> sections
(reduce (fn [acc section]
(-> acc
(update-in ["names"] (fnil into []) (get-in section ["map" "names"]))
(update-in ["mappings"] #(if (not-empty %)
(str % ";" (get-in section ["map" "mappings"]))
(get-in section ["map" "mappings"])))
(update-in ["sources"] (fnil into []) (get-in section ["map" "sources"]))
(update-in ["sourcesContent"] (fnil into []) (get-in section ["map" "sourcesContent"]))))
(dissoc source-map "sections"))
ch/encode
(spit path))))
(defn shadow-cljs-after-build-hook
{:shadow.build/stage :flush}
[build-state]
(let [{:shadow.build/keys [config mode]
:shadow.build.modules/keys [module-order]} build-state
{:keys [output-dir]} config
filename (-> module-order
first
name
(str ".js.map"))
path (str output-dir "/" filename)]
(when (= :release mode)
(println "shadow-cljs-after-build-hook running (flatten-source-map " path ")")
(flatten-source-map path)))
build-state)
I was wondering whether I should try to facilitate some functions from https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/source_map.clj or try to tweak shadow-cljs config but that appears to be a deep hole to dig in, and I feel kinda out of my depth.
I would much appreciate any help/hints on what direction to pursue so shadow-cljs’s source-maps can work on Sentry. Thank you! clojure-spinmappings encode in them line number information. so basically each section acts as an offset for that line information. as such without the offset and just concatenating the mappings does not work. you could rewrite source maps by adjusting those mappings accordingly in theory but I have never attempted to do sosource-map do?"Sourcemap was invalid or not parseable" and then "Invalid location in sourcemap: (37101, 117)") which makes debugging it difficult. I’ve also tried their validation tool https://docs.sentry.io/platforms/javascript/sourcemaps/validating/ but it also just fails with no descriptive stacktrace so my guess is that “sections” format is just not supported by them and I need to convert the source-maps to “section-less” format (because the same codebase’s source-maps used to work there before the transition from lein+figwheel to shadow-cljs build).
Thank you for the hint, I’ll try to improve my flatten-source-map function based on that.:flush hook seemed just like a convenient place to do it but I guess it could be called from different place as wellErrors 1 InvalidSourceMapFormatError Invalid SourceMap format: "." is not in the SourceMap.
source-map npm package wrapped in a bad websitesections?sections format so I assumed that's the cause but of course I might be wrong about it and it could be something else :thinking_face:source-map npm package for the validation. source-map definitely supports sections just fine, so must be something elseautobuild part in shadowcljs.edn file
(shadow.cljs.devtools.api/watch :app {:autobuild false}):devtools {:autobuild false} in your build config and that would be same as aboveshadow-cljs.edn from another directory? I tried passing it to --config-merge but the builds aren't recognized and I get an error like
{:build-id :modules, :known-builds #{}}
ExceptionInfo: no build with id: :modulesshadow-cljs from their own project but will want to pull in https://github.com/babashka/nbb/blob/main/shadow-cljs.edn as their initial configbootstrap build in shadow-cljs since it seems to create problems. I'm trying to integrate with borkdude's sci, which thus far seems relatively straightforward. I'm building a cljs repl using sci inside my application, which requires me to use a :dev/after-load hook to update sci's namespaces when I make an edit to my local cljs code while developing.
The issue that I am having is, if I add a var to one of my normal cljs namespaces, when I tell sci to rebuild its namespace from the cljs one, it doesn't see the new var, unless some other one of my cljs namespaces makes an explicit reference to var. I imagine you don't necessarily know anything about sci, but can you tell me if there is anything unusual with hot code reloading related to creating a new var and having it be visible in a namespace?(shadow.resource/inline "./relative/path/to/file.md")It’s important to note that
inline resolves the file relative to the file holding the namespace that’s calling inline - if that makes sense. Also, the argument to inline must be a string literal. If you need to load file paths dynamically, then you’ll need to create a macro like so:
(defmacro watch-corpus-files
"Emits code that informs shadow-cljs to watch the corpus files for changes"
[]
(let [file-paths (corpus-file-paths)]
`(do :init-ns user at the top level. I'm trying to make my first release build, so in the :main build I reset the REPL ns with :devtools {:repl-init-ns shadow.user, but it's still loading my user namespace for some reason.
I use this same command to trigger the release build: https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/Makefile#L8=
Any idea why it's still starting with user? I have dev tools required in there that I don't want in a release.user namespace. I expect that if :repl-init-ns sets some other ns, user doesn't get loaded. But ofc that's not a valid expectation if repl-init-ns isn't relevant in release builds.
:builds {:main {:target :browser
:output-dir "resources/public/js/main"
:asset-path "/js/main"
:dev {:compiler-options {:external-config {:guardrails {:emit-spec? true :throw? false}}}}
:modules {:main {:init-fn com.example.client/init}}
:js-options {:resolve
"@js-joda/timezone"
{:target :npm
:require "@js-joda/timezone/dist/js-joda-timezone-10-year-range.min.js"}}
:devtools {:repl-init-ns shadow.user
:preloads [com.fulcrologic.fulcro.inspect.preload
com.fulcrologic.fulcro.inspect.dom-picker-preload]
:after-load com.example.client/refresh
:repl-pprint true}}user.clj on the classpath for CLJ projects:source-paths and :dependencies apply to CLJS in exactly the same way as CLJcljs_eval for my app, and I'm trying to add autocompletion to it. Is there a way to get a list of loaded namespaces, either via the standard library (I tried https://cljs.github.io/api/cljs.analyzer.api/all-ns but it doesn't seem to work) or shadow-cljs?cljs-eval. really need access to the compiler env which is on the clojure side.:preloads(add-plugin! ::foo #{} init-fn stop-fn)init-fn gets one parameter being the environment, including the runtime and all the dependencies(defmethod impl/do-relay-msg ::my-auto-complete [worker-state msg] ...) somewhere in your code on the CLJ side:op you choose and the :to:to tells it to direct the messages to the worker, which can then answer via the multi-methodworker-state it gets. in the worker-state there is a :build-state which has :compiler-env:cljs.analyzer/namespaces you'd want to look at for autocompleterequire working from my browser-based repl?(add-plugin! ::plugin #{}
(fn [{:keys [runtime] :as env}]
(api/add-extension runtime ::auto-complete {})
(shared/call runtime
{:op ::complete-me
:to env/worker-client-id
:foo "bar"}
{::complete-result
(fn [msg]
(js/console.log "result from worker" msg))})
env)
(fn [{:keys [runtime]}]
(api/del-extension runtime ::auto-complete)))(defmethod impl/do-relay-msg ::complete-me
[worker-state {:keys [foo] :as msg}]
(impl/relay-msg worker-state msg
{:op :complete-result
:yo []})
worker-state)require working? cljs-eval can require just fine?npx shadow watch :appThe issue is, whenever I run the vscommand
Developer reload window. And after the new vscode window show up, and then if I perform a jack in, it will say
shadow port already takenI suspect this might be related to the shadow server mode. In all, is it possible to tell shadow to quite when vscode quits (to be exact, window reloads) ?
:extra-paths ["src/dev"], and there's an empty (ns user) in there, it builds. Otherwise it gives me an exception.
:shadow-cli {:extra-paths ["src/dev" "resources"]
:extra-deps
{thheller/shadow-cljs {:mvn/version "2.16.12"}
binaryage/devtools {:mvn/version "1.0.0"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]},
$ tree src/dev/ src/dev/ └── user.clj 0 directories, 1 file $ cat src/dev/user.clj (ns user)I don't want
dev on my classpath at all for release, so I shouldn't need it as an :extra-path.user.clj on some other :paths. by just adding src/dev you are effectively overwriting that oneuser.clj I have actually.$ find . -iname "user.clj" ./src/dev/user.clj
find doesn't mean anything since I don't know your full classpath setupclj -A:shadow-cljs(enumeration-seq (.getResources (.getContextClassLoader (Thread/currentThread)) "user.clj"))clj -A:shadow-cli because that's the name of the alias I have. Nope, it doesn't give me errors.(#object[java.net.URL 0x2e01e8ae "file:/home/alex/repos/personal-projects/example/src/dev/user.clj"])
src/dev declared?:extra-paths ["src/dev"], that's when I get the above exception.user.clj, I used clj -A:shadow-cli clj-repl to evaluate it.clj -A:shadow-cljs:main-opts in deps.edncore.async in some way. or some AOT classes you have somewhere:shadow-cli as I have it in my shadow-cljs.edn, yeah?deps.edn. yes, that oneclj. that should be fine as well:main-opts or :jvm-opts configured in your deps.edn?clj or clj -A:dev~/.clojure/deps.edn?clj -Srepro -A:dev to rule that out?{:aliases
{:cider-clj
{:extra-deps {org.clojure/clojure {:mvn/version "1.10.1"}
cider/cider-nrepl {:mvn/version "0.21.1"}}
; fipp {:mvn/version "0.6.23"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"]}
:cljs
{:extra-deps {nrepl/nrepl {:mvn/version "0.7.0"}
cider/piggieback {:mvn/version "0.4.1"}}}
; fipp {:mvn/version "0.6.23"}}}
:nREPL
{:extra-deps {nrepl/nrepl {:mvn/version "0.8.1"}}}
:repl/reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.3.270"}
lambdaisland/deep-diff2 {:mvn/version "2.0.108"}}
:ns-default vlaaad.reveal
;; note Fira Code is a ligature font so it's not supported in Reveal, whjch only uses monospaced
:jvm-opts ["-Dvlaaad.reveal.prefs={:theme,:light,:font-family,\"Fira Code\",:font-size,8}"]
:repl-options {:nrepl-middleware [vlaaad.reveal.nrepl/middleware]}
:exec-fn repl}}}find any .class files from my root and I haven't knowingly used any AOT stuff. Should I try just blowing away my .m2 and pulling everything anew?clj -A:dev -Stree or so.m2 might help in some way<script>s in index.html inside the compiled bundle, and now I can't build my project on Heroku where there's a restriction on memory.
The stack trace doesn't mention shadow-cljs, it even looks like it's been trimmed for some reason because the entry point doesn't make sense.{:clojure.main/message
"Execution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3537).\nJava heap space\n",
:clojure.main/triage
{:clojure.error/class java.lang.OutOfMemoryError,
:clojure.error/line 3537,
:clojure.error/cause "Java heap space",
:clojure.error/symbol java.util.Arrays/copyOf,
:clojure.error/source "Arrays.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.lang.OutOfMemoryError,
:message "Java heap space",
:at [java.util.Arrays copyOf "Arrays.java" 3537]}],
:trace
[[java.util.Arrays copyOf "Arrays.java" 3537]
[java.lang.AbstractStringBuilder ensureCapacityInternal "AbstractStringBuilder.java" 228]
[java.lang.AbstractStringBuilder append "AbstractStringBuilder.java" 682]
[java.lang.StringBuffer append "StringBuffer.java" 393]
[java.io.StringWriter write "StringWriter.java" 122]
[java.io.PrintWriter write "PrintWriter.java" 541]
[java.io.PrintWriter write "PrintWriter.java" 558]
[java.io.PrintWriter print "PrintWriter.java" 685]
[clojure.data.json$write_string invokeStatic "json.clj" 317]
[clojure.data.json$write_string invoke "json.clj" 290]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write_array invokeStatic "json.clj" 348]
[clojure.data.json$write_array invoke "json.clj" 342]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write_object invokeStatic "json.clj" 335]
[clojure.data.json$write_object invoke "json.clj" 319]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write_object invokeStatic "json.clj" 335]
[clojure.data.json$write_object invoke "json.clj" 319]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write_array invokeStatic "json.clj" 348]
[clojure.data.json$write_array invoke "json.clj" 342]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write_object invokeStatic "json.clj" 335]
[clojure.data.json$write_object invoke "json.clj" 319]
[clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
[clojure.data.json$write invokeStatic "json.clj" 475]
[clojure.data.json$write doInvoke "json.clj" 424]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.core$apply invokeStatic "core.clj" 671]],
:cause "Java heap space"}}(spit target (json/write-str sm-index))But given the stacktrace, it's completely unclear where exactly the right place for an improvement would be...
:jvm-opts ["-Xmx2G"] when building:dev/after-load on them, is there any way to control the order of those calls? Or is it just top to bottom? Or some random order?(defn ^:dev/after-load a []) (defn ^:dev/after-load b []) ;; instead (defn ^:dev/after-load reload [] (b) (a))
release build? While it's working as expected in dev build. Not sure if it's cljs compiler itself or something is shadow-cljs. It's not clear why it's different from dev to release builds. I guess normally one should put custom warning names into compiler options.:as-alias , which appear to get loaded in the Clojure runtime (not sure the right word) and so they fail before ClojureScript is ever compiled.dangerously-allow-clojure-override or something?:as-aliaslein new re-frame deneme +cider npm installbut when I try to build it without any changes (npx shadow-cljs watch app) it doesn't compile and gives https://bin.gy/rateersari error Anyone know how to fix this?
~/.m2/repository/com/google/javascript directory~/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220301/closure-compiler-unshaded-v20220301.jar?13062504 or shasum 050e125feb326b6c7638e4c970bdd1ecd64a4b5epodman build ..., got an image, but... the build artifacts aren't there. So RUN npm run buid-ui works just fine but RUN ls target/prod shows no files.
As you can probably guess, the build-ui NPM script relies on shadow-cljs run. Turns out, running shadow-cljs run within a container actually uses a shadow-cljs server instance outside the container, if there's one running..shadow-cljs dir in the container? otherwise it shouln't be able to find or use the outside server?COPY statements and .shadow-cljs is ignored.
I'll have to debug it a bit further before understanding why it works that way. Maybe it's intentional, or maybe there's something wrong with podman build..containerignore, all dot files are ignored by default. But apparently that's not the case, so I gotta fix that.Browserslist: caniuse-lite is outdated. Please run: npxNo clue whether it's something on the shadow-cljs' side at all.
:target build on top of :target :esm or so https://clojureverse.org/t/generating-es-modules-browser-deno/6116:exports config? :thinking_face::target could maybe generate it somehow. haven't looked at next.js since making that repo. no clue what it looks like nowadays:target? 🙏 also I'm targeting Remix not Next.js but both are file-based routing & expect some default exports per page fileSyntax error compiling at (*cider-repl flexiana/scrambler-fe:localhost:8777(clj)*:50:20). Unable to resolve symbol: init in this contextand no Clojure / REPL related Emacs shortcut works, i.e. C-c C-k to compile and load current buffer, or C-c C-z to jump straight into REPL.
$ npm install $ npx shadow-cljs watch appthe SPA works well, but when started up by starting up the REPL from Emacs (C-c M-j), the SPA runs, but reporting the following warning:
shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-clj instance. Is the watch for this build running?
watch running separately you need to "connect" in cider, not "jack-in".(shadow/repl :your-build-id-here)(ns app.util.dev (:require [reagent.core :as r] ["react-deep-force-update" :as deep] ,,,))I checked the js-keys in
deep, but found nothing. How could this happen?(deep)? maybe deep is just a function? or maybe see the usage examples here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages(.-default deep) equal to "react-deep-force-update$default ?react-deep-force-update$default and react-deep-force-update yield the same thingreact-deep-force-update$default gives a nil.(:require ["react-deep-force-update" :as deep]) and then just (deep) somewherenpm install @fontsource/roboto`` and then importing it via import '@fontsource/roboto/300.css';.
What is shadow-cljs equivalent for this?
I have tried (:require ["@fontsource/roboto/300.css"]), but this fails to compile:
[:spa] Build failure:
Failed to inspect file
/p/kunagi-secrets/node_modules/@fontsource/roboto/300.css
Errors encountered while trying to parse file
/p/kunagi-secrets/node_modules/@fontsource/roboto/300.css
{:line 2, :column 0, :message "Character '@' (U+0040) is not a valid identifier start char"}shadow.cljs.devtools.cli-actual/main I mean or should i be using a different entrypoint?main is that I’m seeing a few extranous log lines
May 07, 2022 1:43:39 PM io.undertow.Undertow start INFO: starting server: Undertow - 2.2.4.Final May 07, 2022 1:43:39 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.8.0.Final May 07, 2022 1:43:39 PM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.8.0.Final May 07, 2022 1:43:39 PM org.jboss.threads.Version <clinit> INFO: JBoss Threads version 3.1.0.Final May 07, 2022 1:43:40 PM io.undertow.Undertow start INFO: starting server: Undertow - 2.2.4.Final shadow-cljs - HTTP server available at
shadow.cljs.devtools.api/watch returns when the build finishes. that might be enough?(shadow/watch :the-build) (do-stuff) sequentially should be finejack-in (for clj-only dev) vs starting only shadow.nrepl-port when it boots. Maybe after checking that there’s nothing listening on the port but might also be too much magic….shadow-cljs/nrepl.port file.nrepl-port and start shadow afterwards I manually need to delete it.nrepl-port file. When I kill that process or it dies, the .nrepl-port sticks around, and when I launch nrepl via shadow next time, cider doesn’t consider shadow’s shadow-cljs/nrepl.port file, because the other one takes precedence and I need to manually delete it so I can connect again.def but alter the :arglists meta? I tried the suggested solutions but they all failed to update :arglists (tried with alter-meta!, that didn't change any metadata at all, tried with (declare ^{:arglists '([a b])} my-fun)`, that also didn't work):arglists?defn with an empty body and then rewrite it with set!(ns…) form is wrapped in a (do..) block, compilation fails with odd errors. Here’s a minimal example:
(do (ns cljs.user (:require [cljs.core.async :refer [chan <! go-loop]]))) (def wait-chan (chan 1)) (go-loop [] (<! wait-chan) (recur))…results in this error:
[:app] Build failure: ------ ERROR ------------------------------------------------------------------- File: /Users/neilhansen/Documents/quickstart-browser/src/cljs/user.cljs:9:3 -------------------------------------------------------------------------------- 6 | 7 | (go-loop [] 8 | (<! wait-chan) 9 | (recur)) ---------^---------------------------------------------------------------------- null Can't recur here at line 9 cljs/user.cljs -------------------------------------------------------------------------------- 10 | --------------------------------------------------------------------------------…why am I doing this in the first place? I was working on some custom editor tooling that involved evaluating the whole buffer. I thought I would be clever and wrap the buffer string in a
(do…) block. Ran into this issue, so thought I’d ask about it!shadow.cljs.devtools.server.config-watch doesn't use shadow.cljs.devtools.server.fs-watch but instead busy-loops with (Thread/sleep 1000). Is it just a historical artifact or is there some deliberate decision behind this?(shadow/repl :dev-android) (ns cljs.user)I’m wondering if this can be automated somehow?
(ns cljs.user) you don't really need though?(def some-binding "some stuff") - REPL assumes cljs.user namespace which doesn’t existcljs.user always exists by default?:repl-init-ns in your build config?Connecting to remote nREPL server... Clojure 1.10.3 (shadow/repl :dev-android) To quit, type: :cljs/quit => [:selected :dev-android] (def test-var "something") Execution error (TypeError) at (<cljs repl>:1). undefined is not an object (evaluating 'cljs.user.test_var = "something"') => :repl/exception! (ns cljs.user) => nil (def test-var "something") => #'cljs.user/test-varThat didn’t help. Anyway - that’s not a big deal, just a minor inconvenience, probably related to my setup.
12803 files vs 1684 files explains the time difference? recompile will be faster. the files are included because I guess thats all the transitive deps of the mui-address-complete?--config-merge {:cache-root ".some-other-location"} and .some-other-location does not exist yet, a new shadow-cljs server instance will be started, right?
Is there a better way to make sure that it's a new server instance and not an existing one?
Just encountered an issue where modifying a CLJ file haven't changed the code that shadow-cljs run executes. Took me a while to realize that I had a watch running.shadow-cljs for one--force-spawn thereshadow.cljs.devtools.api in that script, and sounds like running it via just clj would make it more work for me, with manual start of a server instance.shadow-cljs run. But my previous work has changed the release script a bit, and has added a new dependency specifically for that part.
So, not thinking about it, I execute shadow-cljs run and... bad stuff happens. Old behavior, before the changes above. It was rather tedious to debug because I started to think that I had maybe a compiled and outdated class somewhere, or a copy of the script somehow. Took me a bit to realize that shadow-cljs server was running in the background.--force-spawn is just what I need though, as I could use it just for that release script.
Still, makes me think that I myself would probably prefer an explicit flag that did the reverse. I.e. the default behavior for shadow-cljs would be to start a new server instance each time, and some flag would make it reuse some specific instance. But that's just me - I barely use that "connect to existing instance" feature.clj or lein for stuff like this?shadow.cljs.devtools.api/release in that very script or watch in other places of that script.sass there as well, and some other CSS-related things.watch I'd have to use shadow-cljs run and for release I'd have to use clj.
Ehh, I'd rather just pass --force-spawn to the release CLI command.run don't start a server if you use --force-spawn{:shadow/requires-server true} in a couple of places, but not around the release-related code.runsass, and I can't run them all independently via npm run. There's a dependency graph, and right now it's expressed explicitly in the code:
(do-the-first-step) (do-the-second-step) (shadow/watch) (do-some-css-shenanigans) (compile-sass)
shadow-cljs without --force-spawn where there's another instance running somewhere, it will skip starting not just a shadow-cljs server instance specifically, but a whole JVM?org.clojure/clojurescript {:git/url ""
:git/sha "91c597d99b3480c0463b3648016e4f27b0b0b018"}
in my deps, but that crashedCaused by: java.lang.RuntimeException: Unable to find static field: ECMASCRIPT_NEXT_IN in class com.google.javascript.jscomp.CompilerOptions$LanguageMode at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7328) at clojure.lang.Compiler.analyze(Compiler.java:6785) ... 235 more
v20220301 should be ok, didn't test newer ones yetcom.google.javascript/closure-compiler-unshaded {:mvn/version "v20220202"}-Sforce for tools.deps) in shadow-cljs? I didn't see one in the docs. I ask because I'm sometimes compiling my code in a docker container and sometimes locally. I end up getting errors like this when compiling in the container:
> $ yarn shadow-cljs release main
> ...
> shadow-cljs - starting via "clojure"
> Error: Could not find or load main class clojure.main
> Caused by: java.lang.ClassNotFoundException: clojure.main
> error Command failed with exit code 1.
Deleting the .cpcache directory fixes it, but I'm wondering if there is other stuff I should be deleting.shadow-cljs release app is identical to clj <aliases+whatever> -M -m shadow.cljs.devtools.cli release app.cpcache is enoughfast-glob, but am failing to import it properly. Trying this:
(:require ["fast-glob" :as fast-glob :default fg :refer [sync]] ...)I get
module$node_modules$fast_glob$out$index is not defined whichever of those symbols (`fast-glob`, fg, sync) I try to evaluate, and also if I try to call any of them. I do see that this file has been produced:
out/js/cljs-runtime/module$node_modules$fast_glob$out$index.jsI've tried restarting the watcher, and even wiped
.shadow-cljs/ and out/ to no avail.const fg = require('fast-glob');
const entries = await fg(['.editorconfig', '**/index.js'], { dot: true });
// ['.editorconfig', 'services/index.js']
But that's a luxury problem right now. 😃{:deps true
:builds
{:extension {:target :node-library
:js-options {:js-provider :shadow
:keep-native-requires true
:keep-as-require #{"vscode"}}
:compiler-options {:infer-externs :auto}
:output-dir "out/js"
:output-to "out/joyride.js"
:exports {:activate joyride.extension/activate}
:devtools {:before-load-async joyride.extension/before
:after-load joyride.extension/after}}}}:keep-as-require #{"vscode" "fast-glob"}:keep-as-require worked. Thanks! ❤️ shadow even hot-reloaded the config. 🤯mainThreadExtensionService.ts:111 Activating extension 'betterthantomorrow.joyride' failed: Cannot find module 'fast-glob' Require stack: - /Users/pez/.vscode/extensions/betterthantomorrow.joyride-0.0.9-52-get-started-content-6099ecbf/out/joyride.js - /Users/pez/.vscode/extensions/betterthantomorrow.joyride-0.0.9-52-get-started-content-6099ecbf/extension.js - /Applications/Visual Studio - /Applications/Visual Studio - /Applications/Visual Studio . $onExtensionActivationError @ mainThreadExtensionService.ts:111Is there a way I can make shadow bundle it into the release build?
fdir instead of fast-glob. That one doesn't need to be included in the :keep-as-require set.fast-glob.["semantic-ui-react$Confirm" :as Confirm]It does not support:
[semantic-ui-react$Confirm :as Confirm]
[:workspaces] Build completed. (1105 files, 0 compiled, 0 warnings, 14.66s)
This one does not: https://github.com/danieroux/semantic-ui-wrapper/tree/shadow-cljs-build-issues
[:workspaces] Build failure:
Multiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"] still waiting for #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}
{:aborted [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"], :pending #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"] still waiting for #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}npx shadow-cljs server
[2022-05-11 14:22:58.929 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym cider.nrepl/cider-middleware}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
I didn't think cider was built in. But there it is. I'll put my shadow-cljs config in the thread.
My ~/.clojure/deps.edn is empty. There isn't a config in ~/.cljs or ~/.nrepl.
What else could I be missing?{:builds
{:app {:asset-path "/js"
:modules {:main {:init-fn app.core/main}}
:output-dir "public/js"
:target :browser}
:cards {:asset-path "/js"
:modules {:main {:init-fn app.cards/main}}
:compiler-options {:devcards true}
:output-dir "public/js"
:target :browser}
:test {:ns-regexp "app.cards"
:output-to "out/test.js"
:target :node-test}
:e2e {:ns-regexp "e2e.*"
:output-to "out/e2e.js"
:target :node-test}}
:dependencies [[reagent "0.8.1"]
[devcards "0.2.6"]
[cljs-http "0.1.46"]
; [cider/cider-nrepl "0.28.3"]
]
:dev-http {3000 "public"}
:nrepl {:port 3333}
:source-paths ["src"]}[2022-05-11 14:22:58.929 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym cider.nrepl/cider-middleware}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
clojure.lang.Compiler.load (Compiler.java:7648)
clojure.lang.RT.loadResourceScript (RT.java:381)
clojure.lang.RT.loadResourceScript (RT.java:372)
clojure.lang.RT.load (RT.java:459)
clojure.lang.RT.load (RT.java:424)
clojure.core/load/fn--6839 (core.clj:6126)
clojure.core/load (core.clj:6125)
clojure.core/load (core.clj:6109)
clojure.core/load-one (core.clj:5908)
clojure.core/load-one (core.clj:5903)
clojure.core/load-lib/fn--6780 (core.clj:5948)
clojure.core/load-lib (core.clj:5947)
Caused by:
IllegalAccessError with-session-classloader does not exist
clojure.core/refer (core.clj:4249)
clojure.core/refer (core.clj:4217)
clojure.core/apply (core.clj:667)
clojure.core/load-lib (core.clj:5966)
clojure.core/load-lib (core.clj:5928)
clojure.core/apply (core.clj:667)
clojure.core/load-libs (core.clj:5985)
clojure.core/load-libs (core.clj:5969)
clojure.core/apply (core.clj:667)
clojure.core/require (core.clj:6007)
clojure.core/require (core.clj:6007)
cider.nrepl/eval7083/loading--6721--auto----7084 (nrepl.clj:1)
[2022-05-11 14:22:59.291 - WARNING] TCP Port 3000 in use.
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.10.22 running at
shadow-cljs - nREPL server started on port 3333npm installed it a few days ago.npx shadow-cljs to run?npx create-cljs-app to create the project:chunks in the build config like so https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L500-L505js/require as in here https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/rn.cljs#L29shadow-cljs for creating chrome extension and came across this https://github.com/thheller/shadow-cljs/issues/279. It seems to have been inactive since 2020. Has there been any new update since then?:target :esm is the better fit https://clojureverse.org/t/generating-es-modules-browser-deno/6116lein cljsbuild once does in the linked repo)? I can just use lein cljsbuild once for deployment, but it feels weird to depend on two build tools like that. Maybe there's a simple solution?
2. Google Apps Script provides some names that are only available when running in Google Apps Script (not node). An example would be js/SpreadsheetApp (https://github.com/kovasap/autojournal-on-gas/blob/cbfa522932d3b60d3a915dd8e6ff7505935ee26b/src/autojournal/sheets.cljs#L6). When I try to run with these names uncommented in my shadow-cljs node environment I (rightly) get an error. What I would like to do is to have some kind of "if" branch in my code that uses e.g. js/SpreadsheetApp when running in google apps script, but a mock or fake that I define when running in node. Any tips for how to accomplish this? In other languages I feel like compiler macros would be the solution.:target :node-script assumes to be running in node, so that might explain errors. which errors would that be though? you didn't say.#!/usr/bin/env node
(function(){
var shadow$provide = {};
var SHADOW_IMPORT_PATH = __dirname + '/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/kovas/cljs_clamp/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime"; }
global.$CLJS = global;
global.shadow$provide = {};
try {require('source-map-support').install();} catch (e) {console.warn('no "source-map-support" (run "npm install source-map-support --save-dev" to get it)');}
global.CLOSURE_NO_DEPS = true;
apps script complains when I try to run it because __dirname and global are not defined in it's environmentlein cljsbuild once, my file does not have those names referenced:target :browser build where all the code is in one self-contained file?shadow-cljs release app might.resolve use exists? js/SpreadsheetApp:target abstraction is to make target specific builds. there could absolutely be a :target :google-apps-script. I just have never used that so I don't know how it needs to be bundledexists? just a better name for the same functionality?shadow-cljs release app does not work due to google apps script seeing a syntax error in the generated js file. perhaps this is because of subtle differences between javascript and google apps scriptlein cljsbuild once command's output is interpreted just fine. i think this has to do with the clojurescript version. I'm using "1.10.439" in my project.clj and saw that using "1.10.773" led to this syntax error'Syntax error: Missing ; before statement. line: 24 file: Code',, let me get a link to the fileshadow-cljs release app --pseudo-names or --debug:compiler-options {:output-feature-set :es5} in your build config. maybe it doesn't like newer syntaxerrors: [
{
message: 'Syntax error: Missing ) after formal parameters. line: 1420 file: Code',
domain: 'global',
reason: 'badRequest'
}
]goog.loadModule(function(exports) {
"use strict";
goog.module("goog.debug.Error");
goog.module.declareLegacyNamespace();
function DebugError(msg = undefined, cause = undefined) { // <- 1420
if (Error.captureStackTrace) {
Error.captureStackTrace(this, DebugError);
} else {
const stack = (new Error()).stack;
if (stack) {
this.stack = stack;
}
}
:es5 option didn't work--pseudo-names didn't work eitherErrorReferenceError: global is not defined when i try to run my code:target :browser gives
12:35:01 PM Error Cannot use default debug loader outside of HTML documents. 12:35:01 PM Error Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true. 12:35:01 PM Error TypeError: Cannot set property 'NodeType' of undefined
global name at least)global comes from the assumption of running in nodevar global = {}; to the top i get another error:
goog.dom.NodeType = {ELEMENT:1, ATTRIBUTE:2, TEXT:3, CDATA_SECTION:4, ENTITY_REFERENCE:5, ENTITY:6, PROCESSING_INSTRUCTION:7, COMMENT:8, DOCUMENT:9, DOCUMENT_TYPE:10, DOCUMENT_FRAGMENT:11, NOTATION:12};TypeError: Cannot set property 'NodeType' of undefined
var goog = goog || {};
goog.global = global;goog.module or goog.provide in the file right?goog.module.get = function(name) {
return goog.module.getInternal_(name);
};goog.module(...) callsgoog.module("goog.debug.Error");(run "npx" "shadow-cljs" "release" "autojournal"):simpleglobal problem without :optimizations :whitespacevar global = {} again?ErrorReferenceError: process is not defined;af(function() {
return dt();
}, process.argv.slice(2));:node-script assumes node. try :browserglobal and process just fine:target for this that handles all the appscript specific stuff. I just don't have time to look into that currently:target :esm instead of browser as well https://clojureverse.org/t/generating-es-modules-browser-deno/6116import, then dev builds might work. otherwise release only againprocess or global referencesglobalThis. which may or may not be present in that v8 variant:esm yet: message: "Syntax error: SyntaxError: Unexpected token 'export' line: 14202 file: ",:entries [your.ns]"var global = {}; var process = {\"argv\": [\"one\", \"two\"]};" to the top of my file(function(){ ... })();:target :apps-script:node-scriptshadow-cljs.edn?shadow.build.targets.google-apps-script ns or so:target :google-apps-script:target your.ns with (ns your.ns)process fn just like in the :node-script implshadow-cljs clj-repl or work on it from your editorshadow-cljs.edn?:source-paths ["src"] so just src/shadow/build/targets/google_apps_script.clj or whatever name you wantnode/flush-optimized{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7117181d18011402181d0710313c1012331e1e1a5c21031e"}, :content ("[email protected]")}:target :npm-module#?(:clj {}
:cljs {foo/bar my.project.foo/bar})
but this does not work in shadow. It looks like `
(cljs.analyzer/load-data-readers)is not getting called as it does when invoking
cljs.build.api/build:compiler-options {:data-readers true} in the build config;; taken from cljs.closure since its private there ... (defn load-data-reader-file [mappings ^java.net.URL url]in shadow.build.classpath . the load-.. fn has moved to cljs.analyzer and is still private. although e.g.
(cljs.analyzer/load-data-readers)is public, with memoized and unmemoized versions
Execution error (AWTError) at sun.awt.X11GraphicsEnvironment/initDisplay (X11GraphicsEnvironment.java:-2). Can't connect to X11 window server using '172.18.32.204when running
npx shadow-cljs browser-repl . I am inside a VM without X-server. Anyone has an idea?Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:476). com.google.javascript.jscomp.JSModuleUnfortunately haven't been able to reproduce this issue in a simple project. Using
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.51"}
thheller/shadow-cljs {:mvn/version "2.19.0"}
I'll include the full stacktrace in this thread.clj -A:your-aliases -Stree or soorg.clojure/clojurescript 1.11.51 . com.google.javascript/closure-compiler-unshaded v20220502 :newer-versionThis?
clj -A:your-aliases and then (require ')( "com/google/javascript/jscomp/JSModule.class")nil:deps true or :deps {:aliases ...} in your shadow-cljs.edn?( "shadow/build/closure.clj")#object[java.net.URL 0x7af707e0 "jar:file:/home/foobar/.m2/repository/thheller/shadow-cljs/2.19.0/shadow-cljs-2.19.0.jar!/shadow/build/closure.clj"
-Stree to have revealed that the old shadow is being used but maybe there is something else funky going on.( "com/google/javascript/jscomp/JSChunk.class")( "shadow/build/closure__init.class")#object[java.net.URL 0x7da10b5b "jar:file:/home/foobar/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/JSChunk.class"]and
nilrespectively
(require 'shadow.build.closure) in the REPLnpm install @syncfusion/ej2-react-layout in the project dir?@syncfusion/ej2-react-layouts. so you are missing an s?Failed to inspect file
/home/foo/qux/node_modules/highlight.js/lib/languages/isbl.js
it was required from
/home/foo/qux/node_modules/highlight.js/lib/index.js
Errors encountered while trying to parse file
/home/foo/qux/node_modules/highlight.js/lib/languages/isbl.js
{:line 1, :column 1, :message "The file could not be parsed as JavaScript."}
I have two projects A and B. A experiences the issue above. I have tried to trim away as much superfluous code as possible.
B is created from scratch to match A as closely as possible. Notably
• both projects have the exact same -Stree output.
• Both have the exact same package.json and produced package-lock.json
I have seen though that A produces one extra dir though. .shadow-cljs/builds/foo/dev/shadow-js . B does not have this directory.
What could cause A to produce this?2.19.0
(ns frontend.highlight
(:require ["highlight.js" :as hljs]))
(js/goog.exportSymbol "hljs" hljs)
(js/goog.exportSymbol "DevcardsSyntaxHighlighter" hljs)
;;;
{:ns-aliases {devcards-syntax-highlighter frontend.highlight}/home/sam/Code/pitch-app/platform/node_modules/highlight.js/lib/languages/isbl.js look like?shadow-js missing. that is only created for :js-provider :shadow (eg. :target :browser) builds that use actual npm dependencies. other targets such as :npm-module or the :node-* variants won't produce thisFailed to inspect file
/home/dan/code/story-builder/node_modules/highlight.js/lib/languages/gml.js
it was required from
/home/dan/code/story-builder/node_modules/highlight.js/lib/index.js
Errors encountered while trying to parse file
/home/dan/code/story-builder/node_modules/highlight.js/lib/languages/gml.js
{:line 1, :column 1, :message "The file could not be parsed as JavaScript."} @:target? any specific :compiler-options? you sure you have the matching shadow-cljs, cljs, closure-compiler versions?Closure compilation failed with 1 errors --- node_modules/highlight_DOT_js/lib/languages/python.js:11 Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.
:output-feature-set :es8:karma so not needed to set it)There are two workarounds for this issue that I have found: Break the string concatenation up into multiple statements Increase JVM stack size, e.g. -Xss8M
:jvm-opts ["-Xss8M"] in shadow-cljs.edn (if you are not using deps.edn or project.clj, otherwise needs to be set there)re-frame-10x right? or do you use highlight.js in any other context?:js-options {:package-overrides {"highlight.js" {"./lib/languages/isbl.js" false}}} would also work to just manually disable that oneshadow-cljs browser-repl which starts just a cljs-replshadow-cljs clj-repl (or my editor in this case)shadow-cljs clj-repl while the browser repl is runningbuild hook: my.util/hook failed to load and will not be usedshadow-cljs clj-repl then (require 'my.util). that apparently fails?shadow.user=> (shadow/release-snapshot :app {})
Syntax error compiling at (REPL:1:1).
No such var: shadow/release-snapshot
release-snapshot but didn’t see anything. Thanks again for all your hard work on shadow - such a great tool!.shadow-cljs/classpath.edn maybe?:require it, but the namespace just returns an empty js obj (ie #js {}), which predictably results in no actual functions to call. The https://drbh.github.io/wasm-flate/ mention the use of wasm bindgen to create the JS files needed, but it seems like that is also unnecessary when using the npm version`?14 | (defn app-view [] ------------^------------------------------------------------------------------- Receiver reference in function app.core.app_view changes meaning when namespace is collapsed. Consider annotating @nocollapse; however, other properties on the receiver may still be collapsed. --------------------------------------------------------------------------------
app defined in externs somehow?(defn f [] (this-as this))
this ("receiver reference") while f belongs to app.core - it thinks that the value of this is expected to be an instance of app.corethis would be undefined here?this-as on namespaced "vars"this would be undefined here?
Not if you use .bind. :)@nocollapse though)((.bind f #js {}))^:export before vars in order for their names to remain after compilation?
I am assuming yes but just want to confirm
Btw thanks a lot for shadow-cljs every time i use it my mind gets blown and my appetite for more grows
gratitudeAt the moment i am doing
.../vue-project/cljs/ npm run module which is "shadow-cljs release code;"for the config
{:target :npm-module
:output-dir "../node_modules/cljs"
:entries [cljs-helper.util]}
After that i do
cd .. .../vue-project/ npm run serve (which runs Vue cli "vue-cli-service serve")Its quite annoying to have to manually to the 're-release' if i make changes in cljs Is there a chance for me to run watch along side vue "vue-cli-service serve" ? What i tried: I basically added to vue-project/package.json new script "cljs": "cd cljs-helper && npm run watch-helper", and when i run it in terminal alongside another terminal with "vue-cli-service serve" i get this in the browser:
app.js:846 Uncaught ReferenceError: process is not defined
at eval (cljs_env.js?e979:2:1)
at Object../node_modules/cljs/cljs_env.js (chunk-vendors.js:467:1)
at __webpack_require__ (app.js:843:33)
at fn (app.js:1077:21)
at eval (cljs_helper.util.js?a539:1:1)
at Object../node_modules/cljs/cljs_helper.util.js (chunk-vendors.js:477:1)
at __webpack_require__ (app.js:843:33)
at fn (app.js:1077:21)
at eval (Schedule.vue?5f81:283:1)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Schedule.vue?vue&type=script&lang=js& (app.js:530:1)
1. is there anything that can be done to run this?
2. http://2.am i missing something in order to have these things work together?
3. Is it even possible?../node_modules/cljs/cljs_env.js fileprocess. might be something in your code?../node_modules/cljs/cljs_helper.util.jsjs/process?process in my code
this is basically the whole namespace
(ns cljs-helper.util
(:require [cljs.pprint :as p]
[cljs.reader :as r]))
(defn pprint [edn]
(try
(prn "pprinting edn...")
(with-out-str (p/pprint (r/read-string edn)))
(catch :default e
(prn "Invalid EDN error pprint-ing" edn))))
#_ (pprint (str {:a {:b {:c {:d {:e 5 :ff {:f 6}}}}}}))
(defn ^:export pprintEdnString [ednString]
(pprint ednString))
(prn "AAA")
(defn add-matches [fixtures id matches]
(prn "fixtures: " fixtures)
(prn "fixture-id: " id)
(prn "list-of-matches: " matches)
(try
(prn "adding-matches-to-fixture")
(let [edn (r/read-string fixtures)]
(assoc-in edn [id :matches] (set matches)))
(catch :default e
(prn "Invalid args in add-matches" fixtures id matches))))
(defn ^:export addMatches [fixtures fixture-id list-of-matches]
(pprint (str (add-matches fixtures fixture-id list-of-matches))))
../node_modules/cljs foldergrep -rl "process" . ./package-lock.json ./.shadow-cljs/jar-manifest/clojurescript-1.11.51.jar.014c7fc361a498bc927c698e92b5b44761937348.manifest ./.shadow-cljs/jar-manifest/transit-js-0.8.874.jar.f8b4f570ca4d41649190efecac27a5932cc11429.manifest ./.shadow-cljs/jar-manifest/google-closure-library-0.0-20211011-0726fdeb.jar.e7c400433b3c1fadb574d4cc5a65cddccff5500f.manifest ./.shadow-cljs/jar-manifest/shadow-cljs-2.19.0-aot.jar.76fd0a8d13332a12d7ac3ea86931188b3dd03e59.manifest ./.shadow-cljs/jar-manifest/google-closure-library-third-party-0.0-20211011-0726fdeb.jar.7f1939dd0c9908d9314dd0ca4f4b89fd0ca783b8.manifest ./.shadow-cljs/builds/code/dev/ana/devtools/util.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/devtools/munging.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/devtools/hints.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/devtools/formatters/printing.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/devtools/formatters/core.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/shadow/cljs/devtools/client/shared.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/shadow/remote/runtime/shared.cljc.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/pprint.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/core/async/impl/dispatch.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/core/async.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/stacktrace.cljc.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/core.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/ana/cljs/tools/reader.cljs.cache.transit.json ./.shadow-cljs/builds/code/dev/goog-js/goog.events.event.js ./.shadow-cljs/builds/code/dev/goog-js/goog.uri.uri.js ./.shadow-cljs/builds/code/dev/goog-js/goog.uri.utils.js ./.shadow-cljs/builds/code/dev/goog-js/goog.base.js ./.shadow-cljs/builds/code/dev/goog-js/goog.html.trustedresourceurl.js ./.shadow-cljs/builds/code/dev/goog-js/goog.math.long.js ./.shadow-cljs/builds/code/dev/goog-js/goog.i18n.bidi.js ./.shadow-cljs/builds/code/dev/goog-js/goog.html.safehtml.js ./.shadow-cljs/builds/code/release/ana/cljs/pprint.cljs.cache.transit.json ./.shadow-cljs/builds/code/release/ana/cljs/core.cljs.cache.transit.json ./.shadow-cljs/builds/code/release/ana/cljs/tools/reader.cljs.cache.transit.json ./.shadow-cljs/builds/code/release/ana/reagent/core.cljs.cache.transit.json ./.shadow-cljs/builds/code/release/closure.variable.map ./node_modules/url/node_modules/punycode/punycode.js ./node_modules/shadow-cljs/cli/dist.js ./node_modules/shadow-cljs/cli/runner.js ./node_modules/safe-buffer/README.md ./node_modules/ws/lib/permessage-deflate.js ./node_modules/ws/lib/websocket.js ./node_modules/ws/lib/websocket-server.js ./node_modules/ws/lib/stream.js ./node_modules/ws/README.md ./node_modules/prop-types/checkPropTypes.js ./node_modules/prop-types/index.js ./node_modules/prop-types/factoryWithTypeCheckers.js ./node_modules/prop-types/prop-types.js ./node_modules/react/jsx-runtime.js ./node_modules/react/cjs/react-jsx-runtime.development.js ./node_modules/react/cjs/react.development.js ./node_modules/react/cjs/react-jsx-dev-runtime.development.js ./node_modules/react/index.js ./node_modules/react/umd/react.development.js ./node_modules/react/jsx-dev-runtime.js ./node_modules/timers-browserify/CHANGELOG.md ./node_modules/assert/test.js ./node_modules/assert/node_modules/util/test/node/log.js ./node_modules/assert/node_modules/util/test/node/debug.js ./node_modules/assert/node_modules/util/util.js ./node_modules/shadow-cljs-jar/bin/shadow-cljs.jar ./node_modules/constants-browserify/test.js ./node_modules/node-libs-browser/index.js ./node_modules/node-libs-browser/package.json ./node_modules/node-libs-browser/README.md ./node_modules/safer-buffer/Readme.md ./node_modules/safer-buffer/Porting-Buffer.md ./node_modules/safer-buffer/safer.js ./node_modules/pbkdf2/lib/async.js ./node_modules/pbkdf2/lib/default-encoding.js ./node_modules/setimmediate/setImmediate.js ./node_modules/punycode/punycode.js ./node_modules/source-map-support/source-map-support.js ./node_modules/source-map-support/README.md ./node_modules/source-map-support/browser-source-map-support.js ./node_modules/scheduler/tracing.js ./node_modules/scheduler/cjs/scheduler-unstable_mock.development.js ./node_modules/scheduler/cjs/scheduler-tracing.development.js ./node_modules/scheduler/cjs/scheduler.development.js ./node_modules/scheduler/index.js ./node_modules/scheduler/unstable_mock.js ./node_modules/scheduler/tracing-profiling.js ./node_modules/sha.js/test/vectors.js ./node_modules/sha.js/bin.js ./node_modules/process-nextick-args/index.js ./node_modules/process-nextick-args/package.json ./node_modules/process-nextick-args/readme.md ./node_modules/process/index.js ./node_modules/process/package.json ./node_modules/process/README.md ./node_modules/process/test.js ./node_modules/process/browser.js ./node_modules/stream-http/lib/response.js ./node_modules/stream-http/lib/request.js ./node_modules/stream-http/README.md ./node_modules/stream-http/test/server/index.js ./node_modules/stream-http/test/browser/abort.js ./node_modules/readline-sync/lib/readline-sync.js ./node_modules/readline-sync/lib/encrypt.js ./node_modules/readline-sync/README.md ./node_modules/react-dom/cjs/react-dom-unstable-fizz.node.development.js ./node_modules/react-dom/cjs/react-dom-test-utils.development.js ./node_modules/react-dom/cjs/react-dom.development.js ./node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.development.js ./node_modules/react-dom/cjs/react-dom-server.node.development.js ./node_modules/react-dom/cjs/react-dom-server.browser.development.js ./node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.development.js ./node_modules/react-dom/index.js ./node_modules/react-dom/unstable-native-dependencies.js ./node_modules/react-dom/test-utils.js ./node_modules/react-dom/umd/react-dom.development.js ./node_modules/react-dom/umd/react-dom-server.browser.development.js ./node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js ./node_modules/react-dom/unstable-fizz.browser.js ./node_modules/react-dom/server.browser.js ./node_modules/react-dom/unstable-fizz.node.js ./node_modules/react-dom/profiling.js ./node_modules/react-dom/server.node.js ./node_modules/pako/lib/zlib/trees.js ./node_modules/pako/lib/zlib/inftrees.js ./node_modules/pako/lib/zlib/inflate.js ./node_modules/pako/lib/utils/strings.js ./node_modules/pako/lib/inflate.js ./node_modules/pako/dist/pako_inflate.js ./node_modules/pako/dist/pako.js ./node_modules/pako/dist/pako_deflate.js ./node_modules/buffer/test/write.js ./node_modules/buffer/test/from-string.js ./node_modules/buffer/test/is-buffer.js ./node_modules/buffer/test/to-string.js ./node_modules/buffer/test/methods.js ./node_modules/buffer/test/write_infinity.js ./node_modules/buffer/test/base64.js ./node_modules/buffer/test/constructor.js ./node_modules/buffer/test/basic.js ./node_modules/buffer/test/slice.js ./node_modules/buffer/test/compare.js ./node_modules/buffer/test/static.js ./node_modules/buffer/bin/download-node-tests.js ./node_modules/buffer/bin/test.js ./node_modules/react-is/cjs/react-is.development.js ./node_modules/react-is/index.js ./node_modules/builtin-status-codes/browser.js ./node_modules/crypto-browserify/test/index.js ./node_modules/crypto-browserify/example/bundle.js ./node_modules/readable-stream/writable.js ./node_modules/readable-stream/package.json ./node_modules/readable-stream/lib/_stream_readable.js ./node_modules/readable-stream/lib/internal/streams/destroy.js ./node_modules/readable-stream/lib/_stream_transform.js ./node_modules/readable-stream/lib/_stream_duplex.js ./node_modules/readable-stream/lib/_stream_writable.js ./node_modules/readable-stream/node_modules/safe-buffer/README.md ./node_modules/readable-stream/GOVERNANCE.md ./node_modules/readable-stream/readable.js ./node_modules/source-map/lib/source-node.js ./node_modules/source-map/CHANGELOG.md ./node_modules/source-map/dist/source-map.debug.js ./node_modules/source-map/dist/source-map.js ./node_modules/source-map/dist/source-map.min.js.map ./node_modules/miller-rabin/bin/miller-rabin ./node_modules/path-browserify/index.js ./node_modules/path-browserify/test/test-path.js ./node_modules/util/util.js ./node_modules/which/bin/which ./node_modules/which/which.js ./node_modules/randombytes/browser.js ./node_modules/isexe/index.js ./node_modules/isexe/test/basic.js ./node_modules/isexe/windows.js ./node_modules/isexe/mode.js ./node_modules/browserify-zlib/yarn.lock ./node_modules/browserify-zlib/karma.conf.js ./node_modules/browserify-zlib/lib/index.js ./node_modules/browserify-zlib/lib/binding.js ./node_modules/browserify-zlib/src/index.js ./node_modules/browserify-zlib/src/binding.js ./node_modules/create-react-class/factory.js ./node_modules/create-react-class/create-react-class.js ./node_modules/loose-envify/cli.js ./node_modules/loose-envify/index.js ./node_modules/loose-envify/package.json ./node_modules/loose-envify/README.md ./node_modules/loose-envify/replace.js ./node_modules/loose-envify/loose-envify.js ./node_modules/browserify-sign/node_modules/readable-stream/experimentalWarning.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/async_iterator.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js ./node_modules/browserify-sign/node_modules/readable-stream/GOVERNANCE.md ./node_modules/browserify-sign/node_modules/readable-stream/readable.js ./node_modules/events/tests/special-event-names.js ./node_modules/events/tests/events-once.js ./node_modules/events/tests/check-listener-leaks.js ./node_modules/hash-base/node_modules/readable-stream/experimentalWarning.js ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/async_iterator.js ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js ./node_modules/hash-base/node_modules/readable-stream/GOVERNANCE.md ./node_modules/hash-base/node_modules/readable-stream/readable.js ./node_modules/randomfill/browser.js
node_modules/cljs/*.js folder. not everythingnode_modules/cljs$ grep -rl "process"
devtools.formatters.printing.js cljs.core.js cljs.pprint.js cljs.core.async.impl.dispatch.js.map devtools.util.js devtools.hints.js devtools.hints.js.map cljs.stacktrace.js cljs.tools.reader.js.map cljs-runtime/cljs.core.js cljs-runtime/goog.i18n.bidi.js.map cljs-runtime/goog.html.safehtml.js.map cljs-runtime/goog.html.trustedresourceurl.js.map cljs-runtime/goog.uri.utils.js.map cljs-runtime/goog.base.js cljs-runtime/goog.uri.uri.js.map cljs-runtime/cljs.core.js.map cljs-runtime/goog.base.js.map cljs-runtime/goog.math.long.js.map cljs.core.async.js devtools.munging.js.map devtools.formatters.core.js shadow.cljs.devtools.client.shared.js.map cljs.core.async.impl.dispatch.js devtools.formatters.core.js.map devtools.util.js.map devtools.formatters.printing.js.map cljs.pprint.js.map devtools.munging.js shadow.remote.runtime.shared.js.map cljs.core.async.js.map cljs.stacktrace.js.map cljs.core.js.map shadow.cljs.devtools.client.shared.js shadow.remote.runtime.shared.js cljs_env.js cljs.tools.reader.js
process.process\. I guess?grep -rl "process\." cljs.core.js cljs-runtime/cljs.core.js cljs-runtime/goog.i18n.bidi.js.map cljs-runtime/goog.uri.utils.js.map cljs_env.js
cljs_env.js?1 var $CLJS = {};
2 var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;
3 var CLOSURE_DEFINES = CLJS_GLOBAL.CLOSURE_DEFINES = $CLJS.CLOSURE_DEFINES = ....process is actually defined first// webpack needs to be explicitly required
const webpack = require('webpack')
module.exports = {
css: {
sourceMap: true
},
productionSourceMap: false,
publicPath: '/',
configureWebpack: {
plugins: [
// fix "process is not defined" error:
// (do "npm install process" before running the build)
new webpack.ProvidePlugin({
process: 'process/browser',
}),
]
}
};
i ran
npm install process
npm run serve >
npm run cljs AKA "cljs": "cd cljs-helper && npm run watch-helper", AKA "watch-helper": "shadow-cljs watch code;",first and then
npm run serve AKA "serve": "vue-cli-service serve",[solved] :thumbsup: @thheller thanks a lot!!!
:npm-module requires ^:export since it can't know what you are going to use otherwise:target :esm which lets you control this via build config instead https://clojureverse.org/t/generating-es-modules-browser-deno/6116At the moment i am doing
.../vue-project/cljs/ npm run module which is "shadow-cljs release code;"for the config
{:target :npm-module
:output-dir "../node_modules/cljs"
:entries [cljs-helper.util]}
After that i do
cd .. .../vue-project/ npm run serve (which runs Vue cli "vue-cli-service serve")Its quite annoying to have to manually to the 're-release' if i make changes in cljs Is there a chance for me to run watch along side vue "vue-cli-service serve" ? What i tried: I basically added to vue-project/package.json new script "cljs": "cd cljs-helper && npm run watch-helper", and when i run it in terminal alongside another terminal with "vue-cli-service serve" i get this in the browser:
app.js:846 Uncaught ReferenceError: process is not defined
at eval (cljs_env.js?e979:2:1)
at Object../node_modules/cljs/cljs_env.js (chunk-vendors.js:467:1)
at __webpack_require__ (app.js:843:33)
at fn (app.js:1077:21)
at eval (cljs_helper.util.js?a539:1:1)
at Object../node_modules/cljs/cljs_helper.util.js (chunk-vendors.js:477:1)
at __webpack_require__ (app.js:843:33)
at fn (app.js:1077:21)
at eval (Schedule.vue?5f81:283:1)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Schedule.vue?vue&type=script&lang=js& (app.js:530:1)
1. is there anything that can be done to run this?
2. http://2.am i missing something in order to have these things work together?
3. Is it even possible?npm run cljs AKA "cljs": "cd cljs-helper && npm run watch-helper", AKA "watch-helper": "shadow-cljs watch code;",first and then
npm run serve AKA "serve": "vue-cli-service serve",[solved] :thumbsup: @thheller thanks a lot!!!
:main-opts ["-m" "shadow.cljs.devtools.cli" "server"] with the tools-deps image seems to be the waylocalhost:8000/login/callback?blah=blahdeblahlocalhost:8000. I assume you have the CLJS routing setup to handle the rest?:dev-http server or some other http server?.js file:dev-http it has the Cache-Control: private, no-cache headerwindow["$CLJS"] = require("./npm-module/cljs_env");
require("./npm-module/shadow.cljs.devtools.client.browser");window["$CLJS"] = require("./npm-module/cljs_env"); this you shouldn't do. it won't work in a release build in case you use it for anythingCaused by: java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'
I looked for it on Google but didn't get anything interesting. Does someone has a clue ? Thanks a lot.clj -X:deps tree | lesscom.google.guava/guava {:mvn/version "31.1-jre"}npx shadow-cljs watch :lib/dev :test
👆 this allows me to connect to a repl that allows me to play around in namespaces in both builds
Though, my builds are of node-library targets and I’m using Calva to automate the repl-jack-in process
https://github.com/sansarip/owlbear/blob/main/shadow-cljs.edn:source-paths e.g. ["dev" "src/cljc" "src/cljs"]
and then you should be able to just specify a build with either :node-library or :node-script as the target. Doesn’t really matter, because you don’t care about the output file.
Then, npx shadow-cljs watch :<your build name> which will start an nrepl you’ll be able to remotely connect to.
Once your cljs files have finished compiling, you’ll also [probably need] to run node -e "require('<path to your output file>')" which will give your repl a Node environment to execute in:node-script, I have to specify the :main key, which points to a single script. Thus, for every script, I have to have a build target separately.nbb might be more suitable here.npx shadow-cljs node-repl just gives you a node REPL. not tied to any build, you can load any namespace you want in there?expo install react-native-vision-camera command, and I've verified that the library was both added to the package.json and yarn.lock, and that there is a directory corresponding to that library within node_modules. I can't seem to require this library at all from cljs land though. I get null pointer errors during app startup when I try to add the dependency to the ns :require clause.
When I also try to require it from the repl like this (require '["react-native-vision-camera" :as vision]), the vision object is nil always. I have also tried to install another dependency, "react-native-gifted-chat", in the same way to verify it wasn't something wrong with that particular dependency, and that also doesn't seem to work.
I can require dependencies that were already in package.json after generating the app scaffold like "react" and "react-native" however, so I can load things in node_modules; it just doesn't seem like shadow has access to js/expo dependencies I have added after the fact. There must be something I'm missing about the dependency install process, and that there's more to do besides expo install react-native-vision-camera or yarn add react-native-vision-camera from the shell, but I can't seem to pinpoint what I've done wrong or what I'm missing from the guides.
Does anyone have any hints on how to add an external js/react-native/expo dependency to a shadow app targeting react-native so that it can be accessed from cljs code?error The resource `/tmp/zonotope/eas-build-local-nodejs/5e63e06b-13cb-49a3-a597-aa44d97d5090/build/android/app/index.js` was not found.`
app/ directory was in my .gitignore, and eas doesn't transfer any files in .gitignore. i'll bet there's a build hook i can add in to eas to generate the app directory with shadow instead of copying it, but i'll figure that out later since this works for now.------------------------------------------------------------------------------ WARNING: shadow-cljs not installed in project. See ------------------------------------------------------------------------------any way to get rid of this warning?
npm install shadow-cljs?ws or for browser build node-libs-browsernode_modules or pnpm?require("./path-to-output/shadow.cljs.devtools.client.browser") in the JS somewhere2.15.2 (worked fine) to 2.19.0 and facing a macroexpanding error. It warns of not having the right dependency versions for clojure, clojurescript, and the compiler (i've updated those to the required versions). My build fails and this is the main error that pops up. Any thoughts on what's going on or how to fix?
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
:target :npm-moduleshadow-cljs browser-repl without webpack or storybook:npm-module.
3. I apologize, but I am unsure what your suggestion means with "better just use ... without webpack or storybook", could you clarify?
binaryage/cljs-devtools (or similar) custom formatting working within the storybook page/console?
I tried reading around the shadow docs, and I don't know the difference between binaryage's cljs-devtools / devtools libs nor if the references to them matter for the shadow -> webpack -> storybook flow. I imagine it'd be a similar task to above, where I'd have to require the right module?:npm-module builds don't have a clear entry point. so there is no place for shadow-cljs to enforce loading of certain namespacesrequire("./path-to-cljs-output/devtools.preload.js")require("./path-to-cljs-output/shadow.cljs.devtools.client.browser.js")binaryage/cljs-devtools https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-manually? And this is to get custom formatting working, right?NOT installing CLJS DevTools 1.0.6 under advanced build. See .
But I'm running shadow-cljs watch :stories, with these shadow configs:
:stories {:compiler-options {:optimizations :simple}
:devtools {:console-support true
:enabled true
:preloads [binaryage/cljs-devtools]}
:entries [amperity.storybook.core]
:output-dir "out"
:target :npm-module}require(".../shadow.cljs.devtools.client.console") instead:loader-mode :eval (the default):devtools {:loader-mode :script} in the build config:compiler-options {:source-map-inline true} and :devtools {:loader-mode :script}(ns-tools/refresh :after 'mount-components-reset), I got error message.. didn’t find namespace.. at clj part (I use pedestal, and something looks like “locked(?)” ).
;; this somehow breaks reloading ;; the usual :reloading message tells me that is namespace is being reloaded ;; but when the new instance is launched it is still using the old one ;; i cannot figure out why ;; (ns-tools/refresh :after 'repl/start)
rm -rf ~/.m2/repository/juxt after this command.. :man-shrugging: I don’t understand fully. Sorry for this spam, if you would like I will delete this thread.:release {:compiler-options {:optimizations :advanced}
:js-options {:minimize-require true}}
I can't help but think... I'm doing something majorly wrong. I'm using Fulcro and MUI, so I was imagining something pretty big, but 4MB seems like an 'it's my fault' size. CHEERS!npx shadow-cljs run shadow.cljs.build-report [build-id] report.html:release options. they are the default already. setting them again does nothing.npm run watch, but if my node modules is deleted… It is always asking me for react, I need to run separately npm install react
Anybody has an idea why if I have react in the package json it is still asking for it?node_modules you need to run npm install to install all the packages listed in package.json.{:dev/always true}), but also to instruct the compiler to do so after all other namespaces - without needing a solution like you mentioned here https://clojureverse.org/t/problem-using-malli-clojurescript-instrumentation-and-shadow-cljs/8612/2
of explicitly including every namespace that you want to compile before the entry one (or preload).
The dream setup would be adding one piece of metadata to the entry namespace (for a webapp) and then getting repl friendly instrumentation. Not sure if this is possible, so wanted your opinion on the matter. Thanks.() this scans all namespaces and collects any functions that have :malli/schema metadata
2. In your leaf namespace like my.app.utils you have a function like:
(defn minus-small-int
{:malli/schema [:=> [:cat :int] small-int]
:malli/scope #{:input :output}}
[x] (dec x))
3. I'm dev'ing this function and changing the schema and the implementation
The workflow I want is to just edit the leaf namespace and have the () call get macro-expanded and compiled + eval'd again with this new schema.
I'm also open to other suggestions about how to achieve this - maybe an editor command to submit that macro call? then your workflow is: save file. invoke editor command. ?(defn ^:dev/after-load malli-instrument [] (js/cljs-eval "(malli.dev/start!)"))
() after every hot-reloadlein shadow compile app we're seeing a whole bunch of errors like:
[:app] Compiling ... Closure compilation failed with 20 errors --- node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js:95 constructor is missing a call to super() --- node_modules/jsdom/lib/jsdom/living/generated/Attr.js:96 constructor is missing a call to super() --- node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js:94 constructor is missing a call to super()Googling I see this one question/answer in 2019 (https://clojurians-log.clojureverse.org/shadow-cljs/2021-08-13) to a similar
constructor is missing a call to super() error, but I'm not sure where to go from here. Any advice welcome!:target?package-lock.json , run npm install --no-optional and then lein shadow compile app we see:
[:app] Compiling ... The required JS dependency "jsdom" is not available, it was required by "node_modules/fabric/dist/fabric.js". Dependency Trace: mobot_web/app.cljs mobot_web/core.cljs mobot_web/admin/views/core.cljs mobot_web/admin/views/test_plan_runner.cljs mobot_web/admin/views/components/assessment_region_editor.cljs node_modules/fabric/dist/fabric.js Searched for npm packages in: /home/emile/dev/mobot-doc-change/mobot-web/node_modules See:
:js-options in your build config
:resolve {"jsdom" false
"jsdom/lib/jsdom/living/generated/utils" false
"jsdom/lib/jsdom/utils" false}2.19.1 which fixes your issue. so you could bump and remove the :resolve fix, or just keep it. end result is the same.2.19.1 is js-await. Maybe that is useful for someone else, wrote about it here https://clojureverse.org/t/promise-handling-in-cljs-using-js-await/8998(get-in build [:compiler-env :cljs.analyzer/namespaces]) is nil. Is this sort of data located somewhere else for release builds? If not, is there a recommended approach for providing such data to a release build?
edit: actually the :compiler-env key is not present at all 😞:compiler-env is also present always? otherwise pretty much everything would fail 😛(pprint (sort (keys build))) :thinking_face::configure and :compile-prepare:cljs.analyzer/namepaces will indeed be missing or empty?:compile-prepare with data from the previous compile?app that loads the files and renders the routeapp know which routes are availble from a macro?:compiler-env is present, and rely on an outdated version for nowindex.html loading app loading manifest loading split loading component situation 😅:dependencies and rely on it being dead-code-eliminated when it's not loaded in a production build? Or is there a better place to specify it as a dependency?:dependencies does not affect the build in any way:dev-httpjstack dump or something when it happens. should be possible to identify what is causing it (if it is shadow)shadow-cljs watch app then cider-connect-cljs then node app.js . Then I try to evaluate a form in app.cljs and I get "No available JS runtime". I'm not getting any shadow-cljs message in the node process.no source by id: [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]
{:id [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]
shadow.build.data/get-source-by-id (data.clj:172)
shadow.build.data/get-source-by-id (data.clj:169)
shadow.build.compiler/remove-dead-js-deps/remove-fn--15466/fn--15467 (compiler.clj:1225)
clojure.core/complement/fn--5737 (core.clj:1455)
clojure.core/filter/fn--5962 (core.clj:2834)
yo I don't get why I get this errorremove-dead-js-deps? so dunno why that would show up there?(shadow/compile :app) in a CLJ REPL?npx shadow-cljs watch frontendand not sure how to troubleshoot. App compiles and runs.
------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: cljs/analyzer.cljc:4403:12 -------------------------------------------------------------------------------- 4400 | [] 4401 | (try 4402 | @(ns-resolve 'clojure.tools.reader '*alias-map*) 4403 | (catch Throwable t ------------------^------------------------------------------------------------- Use of undeclared Var cljs.analyzer/Throwable -------------------------------------------------------------------------------- 4404 | nil))) 4405 | 4406 | #?(:clj 4407 | (defn forms-seq* -------------------------------------------------------------------------------- ------ WARNING #2 - :undeclared-var -------------------------------------------- Resource: cljs/analyzer.cljc:4402:7 -------------------------------------------------------------------------------- 4399 | "Returns clojure.tools.reader/*alias-map* for bridging" 4400 | [] 4401 | (try 4402 | @(ns-resolve 'clojure.tools.reader '*alias-map*) -------------^------------------------------------------------------------------ Use of undeclared Var cljs.analyzer/ns-resolve -------------------------------------------------------------------------------- 4403 | (catch Throwable t 4404 | nil))) 4405 | 4406 | #?(:clj --------------------------------------------------------------------------------
;; shadow-cljs configuration
{:source-paths
["src/cljs"]
:dependencies
[[reagent "1.1.1"]
[cljs-ajax "0.8.4"]
[re-frame "0.10.6"]
[metosin/reitit "0.5.11"]]
:builds
{:frontend {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:release {:compiler-options {:optimizations :simple}}
:modules {:main {:init-fn spcmig.core/run}}}}}
cljs.analyzer? seems like it shouldn't but I don't know[reitit.coercion.spec :as rss] does require cljs.analyzer, that's why I reported the issue a few minutes ago 🙂2.18.0. that'll have the older clojurescript version as well, so the warnings will be gone until the next release^js before variables?2.16.12 to the latest one 2.19.1 and, leaving everything else the same, running into this:
Syntax error compiling at (shadow/build/js_support.clj:1:1). namespace 'shadow.build.closure' not found
(ns ductile.bootstrap.shadow-cljs
(:require [integrant.core :as ig]
[shadow.cljs.devtools.api :as shadow]
[shadow.cljs.devtools.server :as server]))
(defmethod ig/init-key :ductile.bootstrap/shadow-cljs [_ {:keys [config] :as context}]
(when (seq context)
(server/start!)
(let [{:keys [builds watch-opts]} (get config :shadow-cljs)]
(doseq [build builds]
(shadow/watch build watch-opts))))
context){org.clojure/clojurescript 1.11.51} with the existing shadow versionclj -X:deps list :aliases "[:dev,:cljs]"
• thheller/shadow-cljs 2.19.1
• org.clojure/clojurescript 1.11.51
• com.google.javascript/closure-compiler-unshaded v20220502
Still getting
Syntax error compiling at (shadow/build/js_support.clj:1:1). namespace 'shadow.build.closure' not found
. com.google.javascript/closure-compiler-unshaded v20220502 but here it seems you changed deps.edn to an older version :thinking_face: https://github.com/thheller/shadow-cljs/commit/3af216620ad31320b1b6e6b6d053a161e535a9b7
what am i doing wrong?clj -X:deps list isclj -A:dev:cljs(require 'shadow.build.closure)clj -A:dev:cljs ✘ 130
Clojure 1.11.0
user=> (require 'shadow.build.closure)
nil
user=> (user/go)
2022-06-06 18:22:42.970 INFO ductile.nrepl - {:nrepl/stopping "Stopping nREPL server", :port 64874, :line 31}
2022-06-06 18:22:43.002 INFO ductile.nrepl - {:started "nREPL server started on port 64959 on host localhost - ", :uptime 39794, :line 21}
Syntax error compiling at (shadow/build/js_support.clj:1:1).
namespace 'shadow.build.closure' not founduser=> (require 'shadow.build.closure) nil user=> (require 'shadow.build.js-support) Syntax error compiling at (shadow/build/js_support.clj:1:1). namespace 'shadow.build.closure' not found user=>
shadow.build.js-support , this is the first failure:
shadow.build.closure=> (def warning-types
(reduce
(fn [warnings [registered-name group]]
(let [kw (-> registered-name
(str/replace #"[A-Z]" #(str "-" (str/lower-case %)))
keyword)]
(assoc warnings kw group)))
{}
(DiagnosticGroups/getRegisteredGroups)))
Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups(require ')( "com/google/javascript/jscomp/Compiler.class")clojure -A:dev:cljs Clojure 1.11.0 user=> (require ') nil user=> ( "com/google/javascript/jscomp/Compiler.class") #object[java.net.URL 0x10187078 "jar:file:/Users/mk/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/Compiler.class"]
*euser=> *e
#error {
:cause "namespace 'shadow.build.closure' not found"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "Syntax error compiling at (shadow/build/js_support.clj:1:1)."
:data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "shadow/build/js_support.clj"}
:at [clojure.core$throw_if invokeStatic "core.clj" 5892]}
{:type java.lang.Exception
:message "namespace 'shadow.build.closure' not found"
:at [clojure.core$apply invokeStatic "core.clj" 669]}]
:trace
[[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 6016]
[clojure.core$load_libs doInvoke "core.clj" 6000]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 6038]
[clojure.core$require doInvoke "core.clj" 6038]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[shadow.build.js_support$eval46986$loading__6789__auto____46987 invoke "js_support.clj" 1]
[shadow.build.js_support$eval46986 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval46986 invoke "js_support.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7194]
[clojure.lang.Compiler eval "Compiler.java" 7183]
[clojure.lang.Compiler load "Compiler.java" 7653]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6908 invoke "core.clj" 6161]
[clojure.core$load invokeStatic "core.clj" 6160]
[clojure.core$load doInvoke "core.clj" 6144]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5933]
[clojure.core$load_one invoke "core.clj" 5928]
[clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
[clojure.core$load_lib invokeStatic "core.clj" 5974]
[clojure.core$load_lib doInvoke "core.clj" 5953]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 6016]
[clojure.core$load_libs doInvoke "core.clj" 6000]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 6038]
[clojure.core$require doInvoke "core.clj" 6038]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[user$eval46982 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval46982 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7194]
[clojure.lang.Compiler eval "Compiler.java" 7149]
[clojure.core$eval invokeStatic "core.clj" 3215]
[clojure.core$eval invoke "core.clj" 3211]
[clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
[clojure.main$repl$fn__9215 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl_opt invokeStatic "main.clj" 522]
[clojure.main$main invokeStatic "main.clj" 667]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}( "shadow/build/closure.clj")?( "shadow/build/js_support.clj")user=> ( "shadow/build/closure.clj") #object[java.net.URL 0x3316d545 "jar:file:/Users/mk/.m2/repository/thheller/shadow-cljs/2.19.1/shadow-cljs-2.19.1.jar!/shadow/build/closure.clj"]
user=> (DiagnosticGroups/getRegisteredGroups)
Execution error (NoClassDefFoundError) at user/eval46996 (REPL:1).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
user=> *e
#error {
:cause "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:via
[{:type java.lang.NoClassDefFoundError
:message "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
:at [user$eval46996 invokeStatic "NO_SOURCE_FILE" 1]}]
:trace
[[user$eval46996 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval46996 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7194]
[clojure.lang.Compiler eval "Compiler.java" 7149]
[clojure.core$eval invokeStatic "core.clj" 3215]
[clojure.core$eval invoke "core.clj" 3211]
[clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
[clojure.main$repl$fn__9215 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl_opt invokeStatic "main.clj" 522]
[clojure.main$main invokeStatic "main.clj" 667]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}( "com/google/javascript/jscomp/DiagnosticGroups.class")user=> ( "com/google/javascript/jscomp/DiagnosticGroups.class") #object[java.net.URL 0x197af6a7 "jar:file:/Users/mk/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/DiagnosticGroups.class"]
.m2 downloads and have them download againclojure -A:cljs
Clojure 1.11.0
user=>
user=> (import 'com.google.javascript.jscomp.DiagnosticGroups)
com.google.javascript.jscomp.DiagnosticGroups
user=>
user=> (DiagnosticGroups/getRegisteredGroups)
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.RhinoErrorReporter/<clinit> (RhinoErrorReporter.java:169).
'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'
user=> *e
#error {
:cause "'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'"
:via
[{:type java.lang.NoSuchMethodError
:message "'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'"
:at [com.google.javascript.jscomp.RhinoErrorReporter <clinit> "RhinoErrorReporter.java" 169]}]
:trace
[[com.google.javascript.jscomp.RhinoErrorReporter <clinit> "RhinoErrorReporter.java" 169]
[com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 228]
[user$eval138 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval138 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7194]
[clojure.lang.Compiler eval "Compiler.java" 7149]
[clojure.core$eval invokeStatic "core.clj" 3215]
[clojure.core$eval invoke "core.clj" 3211]
[clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
[clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
[clojure.main$repl$fn__9215 invoke "main.clj" 458]
[clojure.main$repl invokeStatic "main.clj" 458]
[clojure.main$repl_opt invokeStatic "main.clj" 522]
[clojure.main$main invokeStatic "main.clj" 667]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}com.google.guava/guava 30.1-jre
com.datomic/datomic-pro 1.0.6269 if I’m reading this rightclj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.19.1"}}}' -Stree
org.clojure/clojure 1.11.1
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
thheller/shadow-cljs 2.19.1
. org.clojure/data.json 2.4.0
. org.clojure/tools.cli 1.0.206
. org.clojure/tools.reader 1.3.6
. nrepl/nrepl 0.9.0
. cider/piggieback 0.5.3
. com.cognitect/transit-clj 1.0.329
. com.cognitect/transit-java 1.0.362
. com.fasterxml.jackson.core/jackson-core 2.8.7
. org.msgpack/msgpack 0.6.12
. com.googlecode.json-simple/json-simple 1.1.1
. org.javassist/javassist 3.18.1-GA
. javax.xml.bind/jaxb-api 2.3.0
. com.cognitect/transit-cljs 0.8.269
. com.cognitect/transit-js 0.8.874
. org.clojure/core.async 1.5.648
. org.clojure/tools.analyzer.jvm 1.2.2
. org.clojure/tools.analyzer 1.1.0
. org.clojure/core.memoize 1.0.253
. org.clojure/core.cache 1.0.225
. org.clojure/data.priority-map 1.1.0
. org.ow2.asm/asm 9.2
. org.clojure/tools.reader 1.3.6
. org.clojure/clojurescript 1.11.51
. org.clojure/tools.reader 1.3.6
. com.cognitect/transit-java 1.0.362
. com.google.javascript/closure-compiler-unshaded v20220502
. org.clojure/google-closure-library 0.0-20211011-0726fdeb
. org.clojure/google-closure-library-third-party 0.0-20211011-0726fdeb
. org.clojure/google-closure-library-third-party 0.0-20211011-0726fdeb
. thheller/shadow-util 0.7.0
. hiccup/hiccup 1.0.5
. thheller/shadow-client 1.3.3
X org.clojure/core.async 0.3.443 :older-version
. hiccup/hiccup 1.0.5
. thheller/shadow-undertow 0.2.1
X org.clojure/core.async 1.3.610 :older-version
. io.undertow/undertow-core 2.2.4.Final
. org.jboss.logging/jboss-logging 3.4.1.Final
. org.jboss.xnio/xnio-api 3.8.0.Final
. org.wildfly.common/wildfly-common 1.5.2.Final
. org.wildfly.client/wildfly-client-config 1.0.1.Final
X org.jboss.logging/jboss-logging 3.3.1.Final :older-version
X org.wildfly.common/wildfly-common 1.2.0.Final :older-version
. org.jboss.xnio/xnio-nio 3.8.0.Final
. org.jboss.xnio/xnio-api 3.8.0.Final
X org.jboss.threads/jboss-threads 2.3.3.Final :older-version
. org.jboss.threads/jboss-threads 3.1.0.Final
. org.jboss.logging/jboss-logging 3.4.1.Final
. thheller/shadow-cljsjs 0.0.22
. hiccup/hiccup 1.0.5
. ring/ring-core 1.9.5
. ring/ring-codec 1.1.3
. commons-codec/commons-codec 1.15
. commons-io/commons-io 2.10.0
. commons-fileupload/commons-fileupload 1.4
X commons-io/commons-io 2.2 :older-version
. crypto-random/crypto-random 1.2.1
. commons-codec/commons-codec 1.15
. crypto-equality/crypto-equality 1.0.0
. io.methvin/directory-watcher 0.15.1
. net.java.dev.jna/jna 5.7.0
. org.slf4j/slf4j-api 1.7.30
. expound/expound 0.9.0
. fipp/fipp 0.6.26
. org.clojure/core.rrb-vector 0.1.2
. com.bhauman/cljs-test-display 0.1.1clj -Sdeps '{:deps {com.google.javascript/closure-compiler-unshaded {:mvn/version "v20200920"}}}' -Streecom.google.guava/guava 25.1-jre dunno if thats still the version is actually wants though31.0.1-jre( "com/google/common/collect/ImmutableMap.class")guava 31.0-jre, I made a mistake when I tried this earlier~\.lein\.profiles.clj Can I point shadow-cljs to read repos from here or any way I can specify repos for shadow-cljs?:deps true
• and :paths in deps.edn is set to ["src"]
I need to compile both "src" and "test" files with shadow, but it doesn't let me set explicit additional path in shadow-cljs build (I have :test build in shadow-cljs.edn).
How do I compile things that are not in global :source-paths?
I don't want to add "test" to global :paths in deps.edn (then I'd have to deal with removing tests from the .jar, yada-yada). I do have an alias though in deps.edn with :extra-paths, but how do I make shadow to use it (instead or in addition to the global paths)?:aliases https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn:npm-deps in deps.cljs files. you can skip the installation by setting :npm-deps {:install false} in shadow-cljs.ednshadow-cljs clj-repl you can call (shadow.cljs.devtools.server.npm-deps/get-deps-from-classpath). that should tell you where it comes from:target :karma. They are running fine locally, but for whatever reason npx shadow-cljs compile :test failing on GitHub Actions.
Here's some log output:
##[group]Run npx shadow-cljs compile :test
shell: /usr/bin/bash -e {0}
env:
JAVA_HOME: /opt/hostedtoolcache/Java_Adopt_jdk/18.0.1-10/x64
CLOJURE_INSTALL_DIR: /opt/hostedtoolcache/ClojureToolsDeps/latest.0.0-3-6/x64/lib/clojure
##[endgroup]
shadow-cljs - config: /home/runner/work/iroh-front-end/iroh-front-end/shadow-cljs.edn
shadow-cljs - starting via "clojure"
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
Unknown option: "-m"
Unknown option: "--npm"
USAGE:
clj -m cognitect.test-runner <options>
-d, --dir DIRNAME Name of the directory containing tests. Defaults to "test".
-n, --namespace SYMBOL Symbol indicating a specific namespace to test.
-r, --namespace-regex REGEX Regex for namespaces to test.
-v, --var SYMBOL Symbol indicating the fully qualified name of a specific test.
-i, --include KEYWORD Run only tests that have this metadata keyword.
-e, --exclude KEYWORD Exclude tests with this metadata keyword.
-H, --test-help Display this help message
Clojure version is the same (via DeLaGuardo/); shadow-cljs version is the same (`2.19.1`) - both in deps.edn and in package.json. jdk version is the same; node version is the same. Why is it failing?:test has something like :main-opts ["cognitect.test-runner"] so can't use that with shadow-cljs and needs its own alias yes:modules have any impact at allrelease builds? can't say how much more that side costs on the closure compiler side. wouldn't expect too much here either though:modules but all the :entries it would otherwise have. and then one with regular multiple :modules?--verbose where the actual time is spent?Build Complete message? I mean if it ends up including thousands more files this is expected?--verbose were:
[:app] Build completed. (1098 files, 1 compiled, 0 warnings, 2.80s)and
[:app] Build completed. (1410 files, 1 compiled, 0 warnings, 22.36s)
[:app] Compiling ... -> Resolving Module: :main <- Resolving Module: :main (1386 ms) -> build target: :browser stage: :compile-prepare <- build target: :browser stage: :compile-prepare (0 ms) -> Compile CLJS: my-app/views/site_home.cljs <- Compile CLJS: my-app/views/site_home.cljs (743 ms) -> Cache write: my-app/views/site_home.cljs <- Cache write: my-app/views/site_home.cljs (92 ms) -> build target: :browser stage: :compile-finish -> build target: :browser stage: :flush -> Flush: my-app/views/site_home.cljs -> Flushing unoptimized modules -> Flush: shadow/module/main/append.js <- Flush: shadow/module/main/append.js (0 ms) <- Flush: my-app/views/site_home.cljs (12 ms) <- Flushing unoptimized modules (330 ms) <- build target: :browser stage: :flush (350 ms) <- build hook: [0 shadow.cljs.build-report/hook] stage: :flush (0 ms) [:app] Build completed. (1098 files, 1 compiled, 0 warnings, 2.75s)
waveform-playlist and in one of its files it has this:
import stateClasses from "./track/states";Shadow-cljs complains:
FileNotFoundException: /home/p-himik/dev/git/ensemble/src/waveform-playlist/track/states (Is a directory)This is, there's both a
track/states directory and a track/states.js file.
When using IDEA to navigate to the source of the "./track/states" import, it correctly goes to states.js.shadow-cljs watch seems to affect other commands run in separate terminals.
I run my unit tests by first running shadow-cljs -A:test compile unit-tests, which has a target of :node-test and produces a unit-tests.js file that can then be executed via node. This all works fine unless I happen to be running shadow-cljs watch app in another terminal at the same time. In this case, the compile step still produces a unit-tests.js file, but it is missing a bunch of the imports and executing it runs 0 tests.
Any ideas on this?shadow-cljs command will re-use a running shadow-cljs instance if running. I recommend keeping you classpath the same all the time to avoid issues such as this. I assume you are adding extra-paths in the test aliases. there is no downside in always having them. you can run with --force-spawn to always get a new instance/waveform-playlist/track/loader/LoaderFactory.js on classpath with (abridged)
import BlobLoader from "./BlobLoader"; import IdentityLoader from "./IdentityLoader.js"; import XHRLoader from "./XHRLoader";And I have
/waveform-playlist/track/loader/IdentityLoader.js on classpath with
import Loader from "./Loader";
export default class IdentityLoader extends Loader {
load() {
return Promise.resolve(this.src);
}
}
But in the browser, I get:
ReferenceError: IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader is not defined
at eval (LoaderFactory.js:5:19)
at eval (<anonymous>)
at goog.globalEval (main.js:472:11)
at env.evalLoad (main.js:1534:12)
at main.js:2705:12
And the loaded LoaderFactory.js now looks like this:
import BlobLoader from "/waveform-playlist/track/loader/BlobLoader.js"; import IdentityLoader from "/waveform-playlist/track/loader/IdentityLoader.js"; import XHRLoader from "/waveform-playlist/track/loader/XHRLoader.js";What should I do here?
IdentityLoader become IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader. No clue how that's supposed to work.IdentityLoader in the file named by that munged name$waveform_playlist$track$loader$IdentityLoader basically /waveform_playlist/track/loader/IdentityLoadertarget/dev/cljs-runtime/module$waveform_playlist$track$loader$LoaderFactory.js and in it I have console.log("IL", IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader);
as the very first line./waveform_playlist/track/loader/IdentityLoader this filetarget/dev/cljs-runtime/module$waveform_playlist$track$loader$IdentityLoader.jstarget/dev/cljs-runtime/module$waveform_playlist$track$loader$IdentityLoader.js I have:
class IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader extends $jscompDefaultExport$$module$waveform_playlist$track$loader$Loader {
load() {
return Promise.resolve(this.src);
}
}
/** @const */
var module$waveform_playlist$track$loader$IdentityLoader = {};
/** @const */
module$waveform_playlist$track$loader$IdentityLoader.default = IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader;
$CLJS.module$waveform_playlist$track$loader$IdentityLoader=module$waveform_playlist$track$loader$IdentityLoader;
//# sourceMappingURL=module$waveform_playlist$track$loader$IdentityLoader.js.mapclass which is supposed to create this variable globallyeval:devtools {:loader-mode :script}?$CLJS.module$waveform_playlist$track$loader$IdentityLoader.default where that class is supposed to be used.{:loader-mode :script} made a dev page reload insanely slow. I'd rather search for a different solution.$CLJS.[...] instead of the name of a class, right?eval needed?
Why can't the initial code loading just load a single giant file without any eval statements and any further code reloads append new <script> tags?goog.module. :Dimport or exportexports = {Playlist}; it doesn't work because Suspicious re-assignment of "exports" variable. Did you actually intend to export something?
And if I have exports.Playlist = Playlist; or module.exports = {Playlist};, it doesn't work because
ExceptionInfo: failed to convert sources [...] Caused by: NullPointerException: NAME h 11:8 [length: 1] [source_file: waveform-playlist/Playlist.js] [original_name: h]And
h there is just import {h, diff, patch} from "virtual-dom";.import? that makes it ESM and breaks everything:asset-path in your build config. defaults to "/js":devtools {:devtools-url ""}:devtools {:use-document-host false} also works/foo/<asset-path>/<module>. I have the :asset-path set to "/js" which should solve this. Is there any other reason this may be cropping up?:asset-path is in the right place but still not workingshadow.lazy/loadableshadow.lazy/load/js and then gets redirect server side or something?js/phrasing. it'll be there in a string/js/phrasing somehow the :asset-path isn't appliedresolve qualified symbol inside my macros - it's constantly nil. (All modules are cljc). Unqualified symbols are resolve properly.
Although namespace of that symbol is mentioned in require section of namespace from which I call macros.(ns cxa.core
(:require [cx.backend.web :as cx]
[cxa.todomvc]
[cxa.counters]))
(defonce root (atom nil))
(cx/def<> app #{example}
[:div
[:div
[cx/for [[key title] [[:counters "counters"]
[:todomvc "todomvc"]]]
[:label
[:input {:name "example"
:type "radio"
:value key
:on/change #(cx/!! (fn [{:keys [key]}]
{:example key}))}]
title]]]
[cx/case example
:counters [cxa.counters/app]
:todomvc [cxa.todomvc/app]
"nothing selected"]])
(defn rebind [old]
(when old (doto old (cx/detach) (cx/dispose)))
(doto (cx/create app)
(cx/attach (.-body js/document) nil)))
(defn main []
(swap! root rebind))
I couldn't resolve particularly cxa.counters/app and cxa.todomvc/app inside cx/def<> macro. Everything works correct only if move all stuff to single namespace.resolve? I mean what does your macro look like?resolve i mean literally (clojure.core/resolve sym) call.
My macro is a compiler of hiccup-like trees doing same stuff as svelte.
I keep a bit of compile-time information about generated components for some checks to ensure they correctly used.cljs watch.shadow-cljs - config: /mnt/dataf/projects/stuff/shadow-cljs.edn
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.16.7 running at
shadow-cljs - nREPL server started on port 42155
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (142 files, 0 compiled, 0 warnings, 2.12s)
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
File: /mnt/dataf/projects/stuff/src/cxa/core.cljc:9:1
--------------------------------------------------------------------------------
6 |
7 | (defonce root (atom nil))
8 |
9 | (cx/def<> app #{example}
-------^------------------------------------------------------------------------
An error occurred while generating code for the form.
ExceptionInfo: failed compiling constant: watch does no tree-shaking whatsoever. not even attempts to.(reify ..) call and expect that to produce JSclojure.core/resolve only knows how to resolve CLJ varscljs.analyzer/resolve-varcljs watch lifetime)?
> cljs.analyzer/resolve-var
I use this one too for translate cljs symbols into qualified ones and using them resurrect a comp-time info generated by my macro.watch it stays available yes(def ~name-of-something ...)(var-meta name-of-something assoc :slots the-hiccup-data)[:cljs.analyzer/namespaces that.ns :defs name-of-something :meta]shadow-cljs.edn (e.g., nrepl: false) with a command line argument to shadow.cljs.devtools.cli?--config-merge for overriding build config stuff but not global options like nrepl2.19.1 , shadow-cljs emits warning about a few things which are running at macro time. For example, this:
;; source code at ------ WARNING #1 - :undeclared-var -------------------------------------------- Resource: cljs/analyzer.cljc:4403:12 -------------------------------------------------------------------------------- 4400 | [] 4401 | (try 4402 | @(ns-resolve 'clojure.tools.reader '*alias-map*) 4403 | (catch Throwable t ------------------^------------------------------------------------------------- Use of undeclared Var cljs.analyzer/Throwable -------------------------------------------------------------------------------- 4404 | nil))) 4405 | 4406 | #?(:clj 4407 | (defn forms-seq* --------------------------------------------------------------------------------
2.19.1. The macro-expension doesn't recognize the edn alias :
------ ERROR -------------------------------------------------------------------
File: [redacted]/config.cljc:5:1
--------------------------------------------------------------------------------
2 | (:require [ :as mio]
3 | #?(:clj [clojure.edn :as edn])))
4 |
5 | (mio/inline-resource "endpoints.edn" edn/read-string)
-------^------------------------------------------------------------------------
Encountered error when macroexpanding .
Error in phase :compile-syntax-check
RuntimeException: No such namespace: edn
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7401)
clojure.lang.Compiler.resolve (Compiler.java:7375)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
clojure.lang.Compiler.analyze (Compiler.java:6785)
clojure.lang.Compiler.analyze (Compiler.java:6762)
clojure.lang.Compiler.eval (Compiler.java:7198)
clojure.lang.Compiler.eval (Compiler.java:7149)
clojure.core/eval (core.clj:3215)
clojure.core/eval (core.clj:3211)
(io.cljc:51)
(io.cljc:42)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
cljs.analyzer/macroexpand-1*/fn--3702 (analyzer.cljc:4014)
mio/inline-resource is defined at https://github.com/green-coder/mate/blob/7107664b5e95521e8755e13b0f9cf19227408e24/src/mate/io.cljc#L51clojure.edn/read-string.eval which is extra tricky 😛*ns* is not the one that has the edn alias*ns* somewhere and see(tap> *ns*) or so2 | (:require [ :as mio]
3 | #?(:clj [clojure.edn :as edn])))
4 |
5 | (mio/inline-resource "endpoints.edn" edn/read-string)
-------^------------------------------------------------------------------------
Encountered error when macroexpanding .
Error in phase :compile-syntax-check
RuntimeException: No such namespace: edn
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7401)
clojure.lang.Compiler.resolve (Compiler.java:7375)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
clojure.lang.Compiler.analyze (Compiler.java:6785)
clojure.lang.Compiler.analyze (Compiler.java:6762)
clojure.lang.Compiler.eval (Compiler.java:7198)
clojure.lang.Compiler.eval (Compiler.java:7149)
clojure.core/eval (core.clj:3215)
clojure.core/eval (core.clj:3211)
(io.cljc:51)
(io.cljc:42)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
cljs.analyzer/macroexpand-1*/fn--3702 (analyzer.cljc:4014)
cljs.analyzer/macroexpand-1* (analyzer.cljc:4012)
cljs.analyzer/macroexpand-1* (analyzer.cljc:3999)
cljs.analyzer/macroexpand-1 (analyzer.cljc:4063)
cljs.analyzer/macroexpand-1 (analyzer.cljc:4059)
cljs.analyzer/analyze-seq (analyzer.cljc:4096)
cljs.analyzer/analyze-seq (analyzer.cljc:4076)
cljs.analyzer/analyze-form (analyzer.cljc:4285)
cljs.analyzer/analyze-form (analyzer.cljc:4282)
cljs.analyzer/analyze* (analyzer.cljc:4338)
cljs.analyzer/analyze* (analyzer.cljc:4330)
shadow.build.compiler/analyze/fn--15107 (compiler.clj:264)
shadow.build.compiler/analyze (compiler.clj:252)
shadow.build.compiler/analyze (compiler.clj:211)
shadow.build.compiler/analyze (compiler.clj:213)
shadow.build.compiler/analyze (compiler.clj:211)
shadow.build.compiler/default-analyze-cljs (compiler.clj:408)
shadow.build.compiler/default-analyze-cljs (compiler.clj:397)
clojure.core/partial/fn--5908 (core.clj:2642)
shadow.build.compiler/do-analyze-cljs-string (compiler.clj:318)
shadow.build.compiler/do-analyze-cljs-string (compiler.clj:278)
shadow.build.compiler/analyze-cljs-string/fn--15201 (compiler.clj:511)
shadow.build.compiler/analyze-cljs-string (compiler.clj:510)
shadow.build.compiler/analyze-cljs-string (compiler.clj:508)
shadow.build.compiler/do-compile-cljs-resource/fn--15229 (compiler.clj:626)
shadow.build.compiler/do-compile-cljs-resource (compiler.clj:607)
shadow.build.compiler/do-compile-cljs-resource (compiler.clj:565)
shadow.build.compiler/maybe-compile-cljs/fn--15332 (compiler.clj:958)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:957)
shadow.build.compiler/maybe-compile-cljs (compiler.clj:933)
shadow.build.compiler/par-compile-one (compiler.clj:1066)
shadow.build.compiler/par-compile-one (compiler.clj:1021)
shadow.build.compiler/par-compile-cljs-sources/fn--15368/iter--15390--15394/fn--15395/fn--15396/fn--15397 (compiler.clj:1139)
clojure.core/apply (core.clj:667)
clojure.core/with-bindings* (core.clj:1990)
clojure.core/with-bindings* (core.clj:1990)
clojure.core/apply (core.clj:671)
clojure.core/bound-fn*/fn--5818 (core.clj:2020)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
java.lang.Thread.run (Thread.java:833)RuntimeException: No such namespace: edn
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7401)
clojure.lang.Compiler.resolve (Compiler.java:7375)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
clojure.lang.Compiler.analyze (Compiler.java:6785)
clojure.lang.Compiler.analyze (Compiler.java:6762)
clojure.lang.Compiler.eval (Compiler.java:7198)
clojure.lang.Compiler.eval (Compiler.java:7149)
clojure.core/eval (core.clj:3215)
clojure.core/eval (core.clj:3211)
(io.cljc:51)(tap> *ns*) gives me the namespace where the macro is called, but I don't know how to differentiate between the clj and the cljs onesresolveIn , I don't know if it is the same as *ns* https://github.com/clojure/clojure/blob/35bd89f05f8dc4aec47001ca10fe9163abc02ea6/src/jvm/clojure/lang/Compiler.java#L7535-L7537SHADOW import error /home/tianshu/workspace/race-poker/racepoker-transactor/.shadow-cljs/builds/worker/dev/out/cljs-runtime/shadow.module.main.append.js
async function() {
await new Promise(resolve => setTimeout(resolve, 1000);
}
async function delayOneSecond() {
return await new Promise(resolve => setTimeout(resolve, 1000);
}
or via arrow notation which is more idiomatic now, automatically returns if it’s just 1 statement, and has the benefit that it can’t be called as a JS constructor (i.e. it has no this binding):
const delayOneSecond = async () => await new Promise(resolve => setTimeout(resolve, 1000))Interestingly enough in JS because of the way promises chain you don’t need to explicitly
await a promise if it’s the return value of the async function - they are automatically unwrapped, so the following code is equivalent:
const delayOneSecond = async() => new Promise(resolve => setTimeout(resolve, 1000))
(defn wait-forever [] (js/setTimeout wait-forever 1000)) and then calling (wait-forever) once somewhere(.on worker "error" (fn [e] ...)) or so(.on worker "error" (fn [e] ...))?:repl/exception . But nowhere I can see the error, unless I wrap it with a try/catch:repl/exception should always be coming together with the actual error. emacs maybe hiding that part somewhereshadow-cljs browser-repl and evaling whatever to find the actual problemshadow-cljs.edn when using only that. they always go in package.json and are managed by npm or yarn.../dist/cljs_env.js:748
return evalCheck('let r;try{r\x3d", "}catch{};r'););
^
SyntaxError: Unexpected token ')'
> 1 | var $CLJS = require("./cljs_env");
| ^
2 | var $jscomp = $CLJS.$jscomp;
3 | var COMPILED = false;
4 | require("./cljs.core.js");
at Runtime.createScriptFromCode (../../node_modules/.pnpm/:target :npm-module on jest, I get this:target :node-librarynode
Welcome to Node.js v14.19.3.
Type ".help" for more information.
> const { typeSchemas, validate, explain } = require('./dist/mn.flow.ibanxs_data.js')
undefined
> validate(typeSchemas.Country, { id: "BR", name: "Brazil" })
true
> validate(typeSchemas.Country, { id: "BR", name: 123 })
falsetransformIgnorePatterns option on jest's config to ignore compiled cljs files:target :npm-module on jest, I get thistransformIgnorePatterns option on jest's config to ignore compiled cljs files:npm-modules in the same js file, I get this
Namespace "goog.debug.Error" already declared.
107 | if (!COMPILED) {
108 | if (goog.isProvided_(name)) {
> 109 | throw new Error('Namespace "' + name + '" already declared.');
| ^
110 | }
111 | delete goog.implicitNamespaces_[name];
112 | }:npm-module. you mean actual builds or separate namespaces?shadow-cljs.edn:advanced optimized build (which is what you should aim for)shadow-cljs.edn is a bad idea?deps.edn you can just use :local/root or git urlsclj to compile or it still works running shadow-cljs?:dependencies and :source-paths from shadow-cljs.edn to deps.edn (with :deps and :paths there) and add the thheller/shadow-cljs dependency which is automatically included in shadow-cljs.edn but not in deps.ednshadow-cljs CLI tool continues with the same functionality and nothing else changesclj instead of the shadow-cljs command then yes, server mode is limitedshadow-cljs commandshadow-cljs start when :deps trueshadow-cljs server. ie. start but keep running in foreground rather than backgroundshadow-cljs - config: .../shadow-cljs.edn shadow-cljs - starting via "clojure" Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
shadow-cljs start:deps {:aliases [:foo :bar]} accordinglyimport * as React from "react"; with import React from "react";import * as X from "npm"; syntax when requiring CLJS or npm code. It is fine to use when requiring other JS files.
I output an es module into a file foo.js and require it like:
(ns my.ns (:require ["/foo" :as foo])) . From the text quoted above shouldn’t this be fine?packages/your-js-stuff:js-options {:js-package-dirs ["packages" "node_modules"]}(:require ["your-js-stuff" ...]) like any other npm packagepackages/your-js-stuff dir ideally also has a proper package.jsonbuild all your js code ? Could this be:
1. define an entrypoint
2. run it through esbuild?jspdf with shadow-cljs?
I’m seeing this build failure after npm installing it. Seems that the closure compiler isn’t a fan of jsPDF’s minifier?
[:app] Build failure: Closure compilation failed with 1 errors --- node_modules/jsPDF/dist/jspdf.es.min.js:10686 Block-scoped variable Vt declared more than once. First occurrence: node_modules/jsPDF/dist/jspdf.es.min.js:9530:13
"jspdf/dist/jspdf.es.js" instead of just jspdf[BABEL] Note: The code generator has deoptimised the styling of /Users/yedi/Documents/workspace/mobot/mobot-web/node_modules/jspdf/dist/jspdf.es.js as it exceeds the max of 500KB. [:app] Build failure: Closure compilation failed with 1 errors --- node_modules/jspdf/dist/jspdf.es.js:3834 Block-scoped variable ga declared more than once. First occurrence: node_modules/jspdf/dist/jspdf.es.js:3834:4095
[:app] Compiling ...
[2022-06-14 14:33:09.670 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/jspdf/dist/jspdf.umd.js", :requires [{:line 15743, :column 14} {:line 15777, :column 14} {:line 25168, :column 14}]}
[:app] Build failure:
The required JS dependency "worker_threads" is not available, it was required by "node_modules/jspdf/dist/jspdf.umd.js".:js-options {:resolve {"worker_threads" false}} in your build configga issue
[2022-06-14 15:36:04.439 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/jspdf/dist/jspdf.umd.js", :requires [{:line 15743, :column 14} {:line 15777, :column 14} {:line 25168, :column 14}]}
[:app] Build failure:
Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.umd.js:23062
Block-scoped variable ga declared more than once. First occurrence: node_modules/jspdf/dist/jspdf.umd.js:21353:15// src/stack.jsx
import * as React from "react";
import Button from "@mui/material/Button";
function stack_default() {
return /* @__PURE__ */ React.createElement(Button, {
variant: "contained"
}, "Hello World");
}
export {
stack_default as stack
};
and render it using reagent:
(ns
(:require
[reagent.core :as r]
[reagent.dom :as rdom]
["components" :as c]))
(let [elem (.getElementById js/document "app")]
(rdom/render [:f> c/stack] elem))
it compiles fine but blows up with a lot of errors, notably:
• Warning: Invalid hook call. Hooks can only be called inside of the body of a function component.
• Uncaught TypeError: dispatcher is null
• The above error occurred in the <ForwardRef> component:
anybody seem something similar to this?(ns
(:require
[reagent.core :as r]
[reagent.dom :as rdom]
["@mui/material" :as mui]))
(let [elem (.getElementById js/document "app")]
(rdom/render [:> mui/Button {:variant "contained"} "Hello World"] elem)):entry-keys ["module" "browser" "main"] seems to have fixed it :thumbsup:src/ <- on classpath packages/foo <- a npm package packages/foo/dist/index.js <- file I want packages/foo/node_modules <- foo's dependenciesfoo’s package.json has:
{
...
"module": "dist/index.js",
...
}
shadow-cljs.edn:
{:dependencies
[[reagent "1.1.1"]]
:source-paths
["src"]
:dev-http {8080 {:root "public"}},
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:js-options {:js-package-dirs ["packages" "node_modules"]
:entry-keys ["module" "browser" "main"]}
:modules {:main {:entries []}}}}}
seems shadow runs code from foo/node_modules.
what i’m trying to say is:
1. look in packages before node_modules, and
2. try to import as es module first
anybody know how to achieve this?js-package-dirs being searched recursively, so my js module gets react from packages/foo/node_modules while reagent gets it from node_modulespackages/foo is a react components library written in typescript, developed with storybook.node_modules at all though. it should just be the output files of your JS build and a package.jsonpackages/foo. What if the resolver excluded peer and dev dependencies found? Think that would work for this case.packages/foo/out/foo/index.js or somethingpackages/foo/out:js-options {:allow-nested-packages false} but I strongly recommend not setting itnpm install ./packages/foo I believe. which would take care of copying stuff over to the local node_modules. no need to :js-package-dirs thennpm package or whatever the command is and get a .tgz file which you can then installout/foo?out/foo/index.jsdist folder like you hadout/foo. Seems it's not needed. Future proofing?index.js is just the last looked at option:dev alias only in development, and not when building a release build.["@splinetool/react-spline" :as Spline] I get the attached error. Any ideas what causes this?["react-virtualized-auto-sizer$default" :as AutoSizer]import {AutoSizer, List} from 'react-virtualized'; and see translation listing here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages$default, also see my answer here on how to figure this out https://stackoverflow.com/a/72196457/8009006$default returned what I needed I think since it evaluated to a function when logging it, but I gave up on getting it working in reagent[:app] Build failure: The required JS dependency "raven-js" is not available, it was required by "cljsjs/raven.cljs".
yarn add raven-js causes the build not to fail because it's missing the js dep raven.[cljsjs.codemirror]
[cljsjs.codemirror.mode.clojure]
[cljsjs.codemirror.addon.edit.closebrackets]
[cljsjs.codemirror.addon.edit.matchbrackets]
The first would be
(ns cljsjs.codemirror (:require ["codemirror" :as cm])) (js/goog.exportSymbol "CodeMirror" cm)Is the next one then
(ns cljsjs.codemirror.mode.clojure (:require ["codemirror/mode/clojure" :as cm])) ;; what would go here? (js/goog.exportSymbol "CodeMirror" cm)It's not clear to me in the namespace that uses the functionality how things are used there is just one js/CodeMirror so i assume my guess above is wrong and i'm supposed to somehow shove all the functions into that symbol. Maybe through js/goog.object.set ?
(defn foo [] #?(:clj .... shadow watch is going to read the :clj text.:require-macros that namespace it won't actually be loaded or evaluated?(:require [some.thing :as x]) in the :clj branchx/whatever in the :clj branch again that can't be read by the reader if that alias doesn't exist in cljs too:require-macros. only macros?:require-macros will cause the namespace to be evaluated by clojure. and complain about missing dependencies.shadow-cljs to the deps, it's complaining about not being able to find cider/piggieback, (a requirement of our REPL entry point function). shadow-cljs also has a dependency on cider/piggieback, but it's the same version, so I can't see why that would make a difference.:node reader condition doesn't work.#?(:node (println "node") :cljs (println "cljs"))Even with
:node-script target, it still printed "cljs".{:reader-features #{:node}}(defn flush-hook
{:shadow.build/stage :flush}
[build-state & args]
(when (= :release (:shadow.build/mode build-state))
;; My logic
)
build-state)
Lately I see that it is getting called both with my normal build names (:shadow.build/build-id build-state), and with '-release-snapshot' appended to them. Is that new? What is that for?.shadow-cljs) yes. it invalidates itself if something changespackage.json) I've been getting a bizarre build error running shadow-cljs ... watch app—or shadow-cljs ... server then :Connecting (with https://github.com/tpope/vim-fireplace/blob/b6bef833b56632df917bcf33bc50b8a5d1e26139/doc/fireplace.txt#L19) and :CljEvaling (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app)): see below ⬇️
I've tried a https://stackoverflow.com/a/70490790 of https://docs.npmjs.com/cli/v8/commands/npm-ci, up to and including updating my global shadow-cljs to the latest version, and using npx shadow-cljs... and fiddling with the :output-feature-set compiler option... and https://github.com/angular/clutz/issues/490#issuecomment-292236507 😅 ... and still nada.
Seems like people have https://clojurians-log.clojureverse.org/shadow-cljs/2020-06-02 about similar https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-25 before... and it was some kinda problem in/with the closure compiler? :thinking_face:
Fwiw, this is the thing called in the last (i.e. most recent) line of the stacktrace below, afaict: https://github.com/google/closure-compiler/blob/dfa3226ec7b5197b2a1c11b4f0f4a3ee147919f4/src/com/google/javascript/jscomp/parsing/ParserRunner.java#L118
And this is the file where the stack-blowing is happening: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/IRFactory.java
The error:
$ shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d com.billpiel/sayid:0.1.0 -d refactor-nrepl:3.0.0 -d cider/cider-nrepl:0.27.2 watch app
shadow-cljs - config: /home/carnun/Documents/Nette/nette/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.19.3 running at
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
/home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js
it was required from
/home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/index.js
Errors encountered while trying to parse file
/home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js
{:line 1, :column 1, :message "The file could not be parsed as JavaScript."}
RuntimeException: Exception parsing "/home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js"
com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:148)
com.google.javascript.jscomp.JsAst.parse (JsAst.java:156)
com.google.javascript.jscomp.JsAst.getAstRoot (JsAst.java:62)
shadow.build.closure.JsInspector.getFileInfo (JsInspector.java:180)
shadow.build.closure.JsInspector.getFileInfoMap (JsInspector.java:194)
shadow.build.npm/get-file-info*/fn--12316 (npm.clj:452)
shadow.build.npm/get-file-info* (npm.clj:451)
shadow.build.npm/get-file-info* (npm.clj:401)
shadow.build.npm/get-file-info (npm.clj:512)
shadow.build.npm/get-file-info (npm.clj:509)
shadow.build.npm/find-resource-in-package (npm.clj:726)
shadow.build.npm/find-resource-in-package (npm.clj:686)
shadow.build.npm/find-resource (npm.clj:776)
shadow.build.npm/find-resource (npm.clj:739)
shadow.build.resolve/find-npm-resource (resolve.clj:122)
shadow.build.resolve/find-npm-resource (resolve.clj:93)
shadow.build.resolve/eval14445/fn--14448 (resolve.clj:262)
clojure.lang.MultiFn.invoke (MultiFn.java:244)
shadow.build.resolve/find-resource-for-string (resolve.clj:80)
shadow.build.resolve/find-resource-for-string (resolve.clj:69)
shadow.build.resolve/resolve-string-require (resolve.clj:453)
shadow.build.resolve/resolve-string-require (resolve.clj:436)
shadow.build.resolve/resolve-require (resolve.clj:669)
shadow.build.resolve/resolve-require (resolve.clj:662)
shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-require (resolve.clj:662)
shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-require (resolve.clj:662)
shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-require (resolve.clj:662)
shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
shadow.build.resolve/resolve-require (resolve.clj:666)
shadow.build.resolve/resolve-require (resolve.clj:662)
shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
clojure.core/reduce (core.clj:6885)
clojure.core/reduce (core.clj:6868)
shadow.cljs.util/reduce-> (util.clj:45)
shadow.cljs.util/reduce-> (util.clj:44)
shadow.build.resolve/resolve-deps (resolve.clj:49)
shadow.build.resolve/resolve-deps (resolve.clj:33)
Caused by:
StackOverflowError:
com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1743)
com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:2780)
com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:737)
com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1748)
com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:2780)
com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:737)
...
Any pointers would be much appreciated! 😄registerLanguage calls you don't need:js-options {:resolve {"highlight.js" {:target :npm :require "highlight.js/core"}}deps.edn
{:paths ["src" "tests"]
:deps {
;; ...
}
:aliases
{:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.19.3"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}shadow-cljs.edn
{:deps true
:builds
{;; ...
:prod
{:target :npm-module
:output-dir "dist"
;; ...
}}}clj -M:shadow-cljs compile prod works as expectedshadow-cljs compile prod, on the other hand, outputs
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. Full report at: /tmp/clojure-15396811791392763534.edn
thheller/shadow-cljs {:mvn/version "2.19.3"} to :deps solves itshadow-cljs is not calling clj with the right alias:deps true you tell shadow-cljs to use no aliases:deps {:aliases [:shadow-cljs]} instead to activate it:main-opts since that is redundant:npm-deps so the npm packages should be isntalled and used automatically:target :bundle and most cljsjs packages have also been updated to support that.(js/Some.Thing.coolFunction)but does this also extend to objects create via
js/f calls? e.g. in (let [d (js/Date. x)] (.toLocaleDateString d)) would d be correctly inferred to be a js object in the let clause?main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:145 TypeError: f.Sf is not a function
at c.<anonymous> (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:2192:336)
at c.componentDidMount (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:1647:332)
at uj (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:147:464)
at Ej (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:183:21)
at ea.unstable_runWithPriority (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:27:21)
at Ac (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:80:117)
at bd (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:176:83)
at Fg (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:168:106)
at main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:80:407
at ea.unstable_runWithPriority (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:27:21)
so I get the general area and I have tried annotating js/BlabBla where needed, but to no avail.shadow-cljs release app --pseudo-namesTypeError: f.Sf is not a functionjs/....methodName properties to .$methodName$ or so^js/Timeline._Impl (Timeline._Impl.prototype is where the troublesome methods are defined in the JS files) or do I need to use ^js only like is used in the shadow-cljs documentation?^js. nothing else is gained. it doesn't magically gain knowledge of more properties or something^js hint on declarationtl (draw-timeline! new-state) becomes ^js tl (draw-timeline! new-state)(when-let [tl* (and tl @tl)] (when-let [^js tl* (and tl @tl)](defn yo [x] (.whyUNOINFER x))anywhere I don't get any inference warnings. on all my other projects I do
:compiler-options {:data-readers true} turns them back on2.19.4. at the very least you should be getting inference warnings again. and the tags should be respected and actually generate externs.shadow-cljsjs take care of that?shadow-cljsjs does take care of that.shadow-cljsjs?
thheller/shadow-cljsjs {:local/root "../../../shadow-cljsjs"}
thheller/shadow-cljs {:mvn/version "2.11.23" :exclusions [thheller/shadow-cljsjs] }
(Eventually I'll submit a PR but I want to get it working first):paths).cljc means nothing. the question you need to answer in which context the thing is eval'd*out*, which may not be where you are looking):require-macros*out* is bound to.
Thanks I'll check how it's loaded again to.*out* it defaults to wherever shadow-cljs was started. dunno how you are starting it:shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1}
Looking for pointers to debug this 🙂40 | (.. ^js client -tags (tagContact (clj->js {:contactId contact-id
-----------^--------------------------------------------------------------------
Cannot infer target type in expression (. (. client -tags) (tagContact (clj->js {:contactId contact-id, :tagId (:id matching-tag)}))).. looses typehints. I only use -> nowadayscljs.user=> (js/setTimeout boom! 1)
C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623
(let [e (js/Error. message)]
^
Error: boom
at new cljs$core$ExceptionInfo (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623:11)
at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11653:16)
at cljs$core$ex_info (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
cljs.user=> shadow-cljs - #13 ready!shadow-cljs node-repl(defn boom! [] (throw (ex-info "boom" {})))
=> #'cljs.user/boom!
(js/setTimeout boom! 1)
C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623
(let [e (js/Error. message)]
^
Error: boom
at new cljs$core$ExceptionInfo (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623:11)
at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11653:16)
at cljs$core$ex_info (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.:err. eg.
;; ----------------------------------------
;; -- FROM :client
;; ----------------------------------------
{:code "(js/setTimeout boom! 1)",
:id "93653b42-8d31-464a-894d-9083ec171c61",
:op "eval",
:session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}
;; ----------------------------------------
;; -- FROM :target
;; ----------------------------------------
{:err "\n",
:id "93653b42-8d31-464a-894d-9083ec171c61",
:session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}
;; ----------------------------------------
;; -- FROM :target
;; ----------------------------------------
{:err
"C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11623\n (let [e (js/Error. message)]\n ^\n",
:id "93653b42-8d31-464a-894d-9083ec171c61",
:session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}
;; ----------------------------------------
;; -- FROM :target
;; ----------------------------------------
{:err
"Error: boom!\n at new cljs$core$ExceptionInfo (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11623:11)\n at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11650:1)\n at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11653:16)\n at cljs$core$ex_info (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11650:1)\n at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)\n",
:id "93653b42-8d31-464a-894d-9083ec171c61",
:session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}Closure compilation failed with 8 errors --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: a --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: b --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: e --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: h --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: i --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: r --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: t --- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66 Illegal variable reference before declaration: wim unsure if there's something wrong with the way we are attempting to call the package or if there is something wrong in the package itself
["@guaranteed-rate/shared-gr-react-components" :as shared-gr-react-components]
Unknown, waiting for recompile. on the /build/xxx pages for the shadow server since at least release 2.15.2. I just tried upgrading to 2.19.4 today and still see the same page even if I cause the build to recompile by updating a watched file.(shadow.cljs.devtools.server/start!) (shadow.cljs.devtools.api/watch build-id) (shadow.cljs.devtools.api/nrepl-select build-id) (shadow.cljs.devtools.api/repl build-id)
api/nrepl-select and api/repl do the same thing. so calling both seems like a mistake.(fs.readFileSync (str "resources/" filename)) call, but it's looking at the "resources" directory of the project where it's used, as opposed to the "resources" directory in the library itself.io/resource equivalent in cljs land?io/resource equivalent since node doesn't have a classpath. but you control the library and the files that come with it. you can use the special js/__dirname to get the directory of the executing file. so just (path/resolve js/__dirname "foo.txt") would give you the full path in your library which you can then readnode_modules/shadow-cljs package(path/resolve js/__dirname) from the repl in my.namespace I get "/absolute/path/to/my/proj/root". However, when I wrap it in a function:
(defn read-resource [filename] (println (path/resolve js/__dirname)))I get
"/abolute/path/to/my/proj/root/.cljs_node_repl/.cljs_node_repl/my/namespace".js/__dirname yields the wrong folder given how the regular CLJS repls handle file loadingmake tests
make dev
shadow-cljs watch workspaces
It compiled and ran the module (workspaces) successfully at http://localhost:9002
Then I stopped the worker, (worker shutdown) and I tried to compile and run another module
shadow-cljs watch todomvc
I got the same port 9002 for the web app, it started watching build :todomvc and the build completed successfully but
When I tried to access the web URL, I got the previous project running and the red warning message informing me that this is a shadow-cljs - Stale Output! (see image attached)
I tried to refresh the page on the browser, clear the browser cache, remove folder (`.shadow-cljs`) none of these worked as a solution.
Therefore it seems there is a problem with the way things are configured and/or how shadow-cljs loads the generated JS code for the right module.
This is tree structure under the js folder
js
├── test
├── todomvc
│ └── cljs-runtime
└── workspaces
└── cljs-runtime
Each module generates a separate folder for JS, nevertheless with this https://gist.github.com/athanhat/ceaf406565013bd308395a5feea51c92#file-fulcro-shadow-cljs-edn it fails to redirect to the correct web app.
I had also a look at shadow-cljs server, it displays two active http servers at 9001 and 9002, but none of these redirects to the active build todomvc the web page displays the workspaces cards app with the infamous red warning message
Finally as a last resort I removed folder resources/public/js and I executed again shadow-cljs watch todomvc`` . That worked although I got an empty web page for this module (probably I have to run some other server... don't know...)
OK I also had a quick look at your CLJS user guide, it seems that issue is not met anywhere in the manual. Perhaps it will help a lot if you add a section that explains how to avoid problems of this kind. It will also be good to suggest a better configuration, don't know, for fulcro project or projects with several modules in general.shadow-cljs watch ... the browser app only works while the worker is running.resources/public/index.html only loads workspaces. https://github.com/fulcrologic/fulcro/blob/91fe23917d48eb7bfbe480eef2ed02ede3a4389b/resources/public/index.html#L17index.htmlmanually to run a different module in the project ? Is there configuration options for multiple index.html files or a variable for the JS location ?index.html dynamically and know which js to include with backend logic.
In this case, that specific index.html is loaded from the browser. For developer in dev environment doing watch this is probably ok(?)
Also read about release build in the manual.todo.html which has a script tag for the todomvc/main.js file built by the :todomvc buildlocalhost:9002/todo.html you should see whatever output of the todo build issrc/todomvc/fulcro_todomvc/server.clj .
If I am right, I have to start a local clojure REPL (I am using IntelliJ IDE), load the server code and do
(http-server) (web/start @server)But I am getting this error
cannot load server.clj file into the active REPL. It is not in scope for the module used to start the REPL
I guess this has to do with REPL configuration inside IntelliJ IDE, any suggestions to move on ?
BTW: Shouldn't server configured to start automatically with shadow-cljs, is there a way to do this ? Any relevant section in configuration files deps, shadow-cljs etc ?closure-defines for .clj namespaces? I’d like to have a value that is configurable in shadow-cljs.edn that is accessible in macro namespaces at compile time, but I don’t see anything in the documentation:closure-defines in that regard. what do you intend to do?(get-in @cljs.env/*compiler* [:options :external-config :your-key]) which would give you the value of :compiler-options {:external-config {:your-key "foo"}} from the build config/target and prod builds would build to /resources/public. (Of course /target/ needed to be on the class path for dev builds, but I had a :dev alias anyway so no big deal).
This was helpful because in the case of building a docker container on my local machine, it was easy to not end up with dev code in the container ... just don't copy it into the container.
It seems :output-dir in a shadow-cljs.edn build config controls both the build/watch and the release destination.
Is there a way to segregate these?
(It's not the biggest issue; it just means I need to add an rm -rf to my bash docker build script. It's just slightly tedious since it pulls the dev JS out from any watch process I might have left running).:output-dir "target" :release {:output-dir "resources/public"}npx shadow-cljs release app && other stuffout/public once the compilation has finished (while using shadow-cljs watch app)? I am looking for a file that I can watch for a different (Python) integration test watcher?watch? doesn't sound like a good idea to me?manifest.edn is too?"main": "./main.js", "module": "./index.js",but they are not included in the package. it will not work in any bundler and has nothing to do with typescript or shadow-cljs. someone just forgot to put the files in the package when publishing
:module-hash-names true and understand the contents of manifest.edn but where / how can I go about specifying the correct file name in index.html (the script src)?:target :browser
:compiler-options {:externs ["resources/lib/ext/oidc-client-ts.ext.js"]}
:module-hash-names true
:output-dir "resources/public/js"
:asset-path "/js"
:build-hooks [(shadow.html/copy-file
"resources/index.src.html"
"resources/public/index.html")]
:modules {:main {:init-fn co.flair.fleet.core/init}}
I put my static index file in resources/index.src.html and it has the tag <script src="/js/app.js"></script>
but when I run shadow-cljs release app it copies the index file to resources/public/index.html but it doesn’t rewrite the script tag:modules {:main so the src should be /js/main.js(random-uuid), conditional upon requiring meander. Details in thread...$ clj -Sdeps '{:deps {meander/epsilon {:mvn/version "0.0.650"}}}'
Clojure 1.10.3
(require '[meander.epsilon :as m])
Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved.
nil
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
But when using shadow:
shadow-cljs - starting via "clojure" shadow-cljs - server version: 2.19.5 running at shadow-cljs - nREPL server started on port 9000 shadow-cljs - REPL - see (help) To quit, type: :repl/quit shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" shadow.user=> (require '[meander.epsilon :as m]) Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved. nil shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") Execution error (NumberFormatException) at shadow.user$eval36582/<clinit> (REPL:3). Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=> (do #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
cljs.reader/*tag-table* ?npx shadow-cljs clj-repl -A:shadow-cljs
shadow.user=> cljs.reader/*tag-table* Syntax error (ClassNotFoundException) compiling at (REPL:0:0). cljs.readerI'm not sure if it worked..? Looks like it produced a syntax error and a value?
default-data-readers and *data-readers*shadow.user=> *data-readers*
{dbg #'cider.nrepl.middleware.debug/debug-reader, break #'cider.nrepl.middleware.debug/breakpoint-reader, light #'cider.nrepl.middleware.enlighten/light-reader, meander.epsilon/fail #'meand
er.strategy.epsilon/*fail*, meander.epsilon/pass #'meander.strategy.epsilon/*pass*}$ java --version openjdk 11.0.15 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1) OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1, mixed mode, sharing)
*e eval after the error? maybe the stacktrace can provide some clues#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" without the (identity) works?shadow.user=> #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") Execution error (NumberFormatException) at shadow.user$eval36931/<clinit> (REPL:5). Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978 shadow.user=> (prn #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") Execution error (NumberFormatException) at shadow.user$eval36933/<clinit> (REPL:6). Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978 shadow.user=>Yep.
java.lang.ExceptionInInitializerError is always responsible for some very weird errorsclj-repl directly?~/.clojure/deps.edn or wherever that file is? maybe there is something in there contributing to this? no idea what but maybe?{:deps {:aliases [:shadow-cljs]}} in shadow-cljs edn so you don't have the pass the -A:shadow-cljs in case you didn't know that~/.clojure/deps.edn has some aliases, but I'm not activating them here./usr/local/lib/clojure/deps.edn is commented out.+14:16 $ clj -A:repl/cider WARNING: Use of :main-opts with -A is deprecated. Use -M instead. nREPL 0.9.0 Clojure 1.11.1 OpenJDK 64-Bit Server VM 11.0.15+10-Ubuntu-0ubuntu0.21.10.1 Interrupt: Control+C Exit: Control+D or (exit) or (quit) #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978") Execution error (NumberFormatException) at shadow.user$eval40895/<clinit> (REPL:1). Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978 shadow.user=>
identity call works before requiring it. Otherwise I too have no ideas. It's strange that it works with some forms, like do, and, or, but not most others. I guess those working ones don't evaluate it or something.{:builds
{:dev
{:target :node-script
:main shadowtest.core/main
:output-to "build/shadowtest/app.js"
:module-loader true
:modules
{:hotload
{:entries [shadowtest.hotload]}}}
(ns shadowtest.core
(:require
[shadow.loader :as loader]))
(defn do-load!
[n]
(println "Loading module '" n "'.")
(-> (loader/load n)
(.then identity)))
attempting to drive it in the repl:
(do-load! "hotload")emits:
Execution error (Error) at (<cljs repl>:1). shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.
:target :node-script but you want :target :browser I guess?:node-script. neither is it very useful?:npm-module?requiring-resolverequire or resolve:entities? do you mean :entries?((requiring-resolve 'some/thing) :foo :bar) but can't in CLJS{:target :node-script :main some.thing/main}(ns some.thing (:require [whatever.you.need])) (defn main [] ...) dynamically2.19.3
shadow-cljs - starting via "clojure" Missing required argument for "-M ALIASES"Any ideas on how to fix this?
clojure toolshadow-cljs release appnpx shadow-cljs release app the same error?clojure cli tool version do you have?clojure -M -m shadow.cljs.devtools.cli release appclojure -A:alias -M -m shadow.cljs.devtools.cli release appclojure tools1.10.1clojure -M -m shadow.cljs.devtools.cli release appRuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
java.util.Optional.isEmpty()Z
Node(SUPER): goog/iter/es6.js:147:4
super();
Parent(CALL): goog/iter/es6.js:147:4
super();
com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2884)
com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:445)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:465)
com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:39)
com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:401)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:471)
com.google.javascript.jscomp.StaticSuperPropReplacer.replaceAll (StaticSuperPropReplacer.java:63)
com.google.javascript.jscomp.InlineAndCollapseProperties$AggressiveInlineAliases.process (InlineAndCollapseProperties.java:268)
com.google.javascript.jscomp.InlineAndCollapseProperties.performAggressiveInliningAndCollapsing (InlineAndCollapseProperties.java:229)
com.google.javascript.jscomp.InlineAndCollapseProperties.process (InlineAndCollapseProperties.java:203)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:240)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:179)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2574)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:933)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:981)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:930)
com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:872)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/compile-js-modules (closure.clj:1112)
shadow.build.closure/compile-js-modules (closure.clj:1098)
shadow.build.closure/optimize/fn--13728 (closure.clj:1307)
shadow.build.closure/optimize (closure.clj:1293)
shadow.build.closure/optimize (closure.clj:1284)
shadow.build.api/optimize (api.clj:273)
shadow.build.api/optimize (api.clj:267)
shadow.build/optimize (build.clj:525)
shadow.build/optimize (build.clj:517)
shadow.cljs.devtools.api/release* (api.clj:339)
shadow.cljs.devtools.api/release* (api.clj:324)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--18450--auto----19158 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
Caused by:
NoSuchMethodError: java.util.Optional.isEmpty()Z
com.google.javascript.jscomp.StaticSuperPropReplacer.tryReplaceSuper (StaticSuperPropReplacer.java:102)
com.google.javascript.jscomp.StaticSuperPropReplacer.visit (StaticSuperPropReplacer.java:92)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:859)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:898)
com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:763)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:806)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
com.google.javascript.jscomp.NodeTraversal.handleClassMembers (NodeTraversal.java:973)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:815)
com.google.javascript.jscomp.NodeTraversal.handleClass (NodeTraversal.java:948)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:812)
com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:987)
com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:751)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:39)
com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:401)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:471)
com.google.javascript.jscomp.StaticSuperPropReplacer.replaceAll (StaticSuperPropReplacer.java:63)
com.google.javascript.jscomp.InlineAndCollapseProperties$AggressiveInlineAliases.process (InlineAndCollapseProperties.java:268)
com.google.javascript.jscomp.InlineAndCollapseProperties.performAggressiveInliningAndCollapsing (InlineAndCollapseProperties.java:229)
com.google.javascript.jscomp.InlineAndCollapseProperties.process (InlineAndCollapseProperties.java:203)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:240)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:179)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2574)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:933)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:981)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:930)
com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:872)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/compile-js-modules (closure.clj:1112)
shadow.build.closure/compile-js-modules (closure.clj:1098)
shadow.build.closure/optimize/fn--13728 (closure.clj:1307)
shadow.build.closure/optimize (closure.clj:1293)
shadow.build.closure/optimize (closure.clj:1284)
shadow.build.api/optimize (api.clj:273)
shadow.build.api/optimize (api.clj:267)
shadow.build/optimize (build.clj:525)
shadow.build/optimize (build.clj:517)
shadow.cljs.devtools.api/release* (api.clj:339)
shadow.cljs.devtools.api/release* (api.clj:324)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
shadow.cljs.devtools.cli-actual/main/body-fn--18450--auto----19158 (cli_actual.clj:166)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
clojure.core/apply (core.clj:671)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.core/apply (core.clj:662)
shadow.cljs.devtools.cli/-main (cli.clj:75)
shadow.cljs.devtools.cli/-main (cli.clj:67)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core/apply (core.clj:667)
clojure.main/main-opt (main.clj:514)
clojure.main/main-opt (main.clj:510)
clojure.main/main (main.clj:664)
clojure.main/main (main.clj:616)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
npx shadow-cljs watch app after the build completes, I open my browser and see the following in terminal:
2022-06-30 10:46:46,627 [XNIO-1 I/O-3] DEBUG io.undertow.websockets.core.request - Attempting websocket handshake withand then this message on repeat until it times out:
2022-06-30 10:47:11,865 [XNIO-1 I/O-3] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1Any clues? I’ve triple checked my configuration and I’m stuck 😬 thanks for reading
shadow: #<some-number> ready!lein doo about React components from node_modules being not found, so I'm suspecting it's notnpx commands (well, actually 2, but still 😅 ):target :karma that a few people usenpx shadow-cljs compile test npx karma start --single-runIs there a way to achieve similar outcome from within
lein ?..Makefile or npm "scripts" or whatevernpx shadow-cljs compile test && npx karma start --single-runbb.edn to solve it with babashka 😊
Thanks for the pointers!2.19.5, is that known?
Syntax error compiling at (shadow/build/data.clj:360:5). No such var: ana/get-data-readers
2.19.4.[org.clojure/tools.analyzer "1.1.0"] on the clojure side of deps (in project.clj) solves it for me.shadow-cljs watch app --debug and get runtime error in console without lineNumber and filename, is it possible to configure shadow-cljs to see it?:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:compiler-options {:source-map true
:pseudo-names true
:pretty-print true}
}cljs$core$ExceptionInfowatchs.chatAt suggests it expects a string somewherecljs and cljc files compile file, using the :target :browser I have to use the :entries to find the namespaces, but I would like for shadow to find all cljs and cljc files and try to compile all of then, what kind of build setup I can use to make this?:npm-module is best? you can set a :ns-regexp "your.library" or whatever which will end up including all namespaces matching that?[:main] Compiling ...
Execution error (AssertionError) at shadow.build.resolve/maybe-babel-rewrite (resolve.clj:205).
Assert failed: (map? rc)
My instincts tell me it has something to do with webpack. But I’m lost. I remember having the same error once before and the solve being super simple, small, and dumb. But for the life of me I can’t remember what it was. Any help is BIG THANKS! CHEERS!(defn create-worker-body [require-ns afn value tid]
(println :require-ns require-ns)
(let [pre-loads
(str "var CLOSURE_UNCOMPILED_DEFINES = {\"cljs.core._STAR_target_STAR_\":\"webworker\"};"
"var quarkpreload = {};\n"
"quarkpreload.fn = `" afn "`;\n"
"quarkpreload.args = `" value "`;\n"
"quarkpreload.tid = `" tid "`;\n")]
(if (empty? goog/basePath)
(str pre-loads
"importScripts('" (last (scripts-src)) "');\n")
(str pre-loads
"CLOSURE_BASE_PATH = '" goog/basePath "';\n"
"this.CLOSURE_IMPORT_SCRIPT = (function(global) {\n"
" return function(src) {\n"
" global['importScripts'](src);\n"
" return true;\n"
" };\n"
"})(this);\n"
"if(typeof goog == 'undefined') importScripts(CLOSURE_BASE_PATH + 'base.js');\n"
"importScripts(CLOSURE_BASE_PATH + 'deps.js');\n"
"importScripts(CLOSURE_BASE_PATH + '../cljs_deps.js');\n"
"goog.require('process.env');\n"
"goog.require('" require-ns "');\n"))))
In shadow, I get Error: browser bootstrap used in incorrect target because goog.global.document isn't available:
var doc = goog.global.document;
if (!doc) {
throw new Error("browser bootstrap used in incorrect target");
}
Any pointers here?out/webworker.js file that CLJS users can know they can always pass to new Worker(... and know that the given build system will handle setup the way it wants to.:web-worker trueunsupported protocol for sourcemap request blob:....
But this is sweet progress^:export 'ed functions at shadow-cljs.edn?
I have two builds and I want to export a different set of functions in the same nsnew Worker("/js/worker.js")) not as a blob. then source maps will also work(ns your.build.a) and (ns your.build.b) (each with the appropriate requires of course)(js/goog.exportSymbol "whatever.name.you.like" the-cljs/def)^:export does is adding that exportSymbol call basicallybinaryage/cljs-devtools in shadow-cljs (edn config file)?
This sections describes it for e.g. lein based projects: https://github.com/binaryage/cljs-devtools/blob/master/docs/configuration.md#configuration-via-compiler-optionssome custom formatters were not rendered. message with :dont-detect-custom-formatters true
following: https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#why-some-custom-formatters-were-not-rendered
I get the warning, yet formatters seem to work just fine (so wanted to get rid of the warn for the time being — chrome 103.0.5060.53):compiler-options in the build config{..
:builds {:app {:compiler-options {:external-config {:devtools/config {:features-to-install [:formatters :hints]
:dont-detect-custom-formatters true}}}}}}
in the shadow-cljs.ednpprint functionality. It doesn’t work.
I then switched to the calva engine, it now works.
See https://calva.io/pprint/#pprint-is-not-working-for-clojurescript:~:text=Comments-,calva,-client(ns foo) (comment (def *a (result-of-some-http-req))*a will disappear after add some change in other parts of the file. How can I disable this behavior? I verified, js/foo.STARa_ still exist. It’s just the access of foo/*a gives the undeclared var error
(ns foo) (declare *a) (coment (def *a (....))and it works. But I ’d rather move anything about *a to be inside the comment.
(defn a []) (defn b [] (a))
(defn a []) to (defn x []) without changing b(comment (tap> (result-of-some-http-req)))
load-file it will not be reset(comment (def *a (some-stuff)) (def *b (:key *a)) )I do look at it. But it’s the inline result not from repl.
(def x/a (some-stuff) but it’s definitely results in syntax error.bar is also kept.my-module. My example setup is main + my-module that depends on main. My expectation was that modifying a file within my-module would only rebuild the my-module.js file, but compile times were the same both for modifying files on main and my-module.
My question is: Does shadow skip advanced compilation for modules with no changes on the file system?:advanced is whole program optimization. :modules just splits the final output into multiple files. it still needs to compile everything all at once.*warn-on-reflection* to true globally? normally you shouldn't see those?:target :graaljs and getting this error message, while trying to load the cljs into polyglot context:
shadow-cljs - failed to load module$node_modules$react_dom$cjs$react_dom_server_browser_development
shadow-cljs - failed to load module$node_modules$react_dom$server_browser
{:clojure.main/message
"Execution error (PolyglotException) at <js>/:anonymous (ssr.js:47696).\nReferenceError: TextEncoder is not defined\n",
:clojure.main/triage
{:clojure.error/cause "ReferenceError: TextEncoder is not defined",
:clojure.error/symbol <js>/:anonymous,
:clojure.error/source "ssr.js",
:clojure.error/phase :execution},
...
Steps to reproduce:
git clone --branch graaljs-ssr ; cd atemoia; npm install && clj -A:dev -X atemoia.server/dev-mainTextEncoder is present and wants to use it?
I will try to polyfill.
I'm just having fun and learning about graaljsnode executable replacement(.eval "js" "TextEncoder = class { encode() {} }") is enough 🙈WinterGC compliance to graaljs.
It may turn graaljs into a nicer target for shadow-cljs 👀pacakge.json you need to run npm install without specifying a package to install them all. otherwise it only ends up installing whatever package you specifiedpnpm i --shamefully-hoist usually fixes this type of issue. The https://pnpm.io/npmrc:
shamefully-hoist Default: false Type: Boolean By default, pnpm creates a semistrict node_modules, meaning dependencies have access to undeclared dependencies but modules outside of node_modules do not. With this layout, most of the packages in the ecosystem work with no issues. However, if some tooling only works when the hoisted dependencies are in the root of node_modules, you can set this to true to hoist them for you.
(shadow/watch :the-build) (shadow/repl :the-build)
(js/console.log "HELLO") and (.log js/console "HELLO") are equivalent.
Can this also be applied to module imported with shadow?
I have ["slate-react" :refer (ReactEditor Slate Editable withReact)] under my namespace, and:
• (ReactEditor.focus editor) didn't work.
• (.focus ReactEditor editor) works.
Is this the difference I need to notice between normal cljs and shadow?. when using namespace qualified symbols. which also happens to play nice with my other rule of barely ever :refer. so I would to ["slate-react" :as sr] then (sr/ReactEditor.focus)["slate-react$ReactEditor" :as sre] and (sre/focus)(shadow/repl-runtimes :the-build) then (shadow/repl :the-build {:runtime-id 123}) using the :client-id listed in the previous command. (unfortunate renaming incident left in those thats why the names differ)importScripts that pulls down things in the correct way would be fine, but IDK how much other stuff shadow and figwheel are doing throughout the rest of the build to accommodate workers, so I wouldn't want to break the build tool's expectations(spawn {:build-id ..., or module id. Currently, there's really no way to ship libs that provide web worker capabilities without forcing their users to learn advanced build ceremony, which is different for every build toolworker fn in core, and the different build tools could fulfill some contract that makes it work. Few other languages impose this much ceremony to achieve programmatically spawning parallelismshadow/active-builds and then shadow/get-build-config for the active builds. But can I then update those build configs at runtime?:web-worker true, allowing you to connect to them via a worker optionally:depend on the non-worker one:advanced builds. and shadow-cljs is not meant to run in any kind of production environment, so what you are attempting is not a supported use case of shadow-cljs (and neither figwheel I'd say):advanced mode case is pretty easy:none is the hardest for me to wrap my head around(defn ^:export some-worker-fn [maybe args]
(do-whatever))
(defn spawn [target & args]
(let [fn-name (munge target)
worker (js/Worker. (str script-base "?" fn-name))]
(.postMessage worker (pr-str args))))
(spawn `some-worker-fn :foo :bar)
(defn init-browser-side [])
(defn init-worker-side []
(let [target (subs 1 js/location.search)
target-fn (js/goog.getObjectByName target)]
(js/self.addEventListener "message"
(fn [e]
(let [args (reader/read-string (.-data e))]
(apply target-fn args)
)))
))
(defn init []
(if (exists? js/document)
(init-browser-side)
(init-worker-side))):none will probably break in :advanced, so you probably should not be doing itimportScripts shim with tau though. With this I'm trying to lean into the build tool's webworker facilitiesjs/Atomics.waittau.alpha.ex=> (let [res (xget "")
#_=> iss (-> @res js/JSON.parse (js->clj :keywordize-keys true))
#_=> loc (:iss_position iss)]
#_=> (println "International Space Station, Current Location:" loc))
International Space Station, Current Location: {:longitude -175.7632, :latitude -10.2605}
nilyield and there's no async rewriting. It's top level blocking(defn handle-response [event]
(let [xhr (.-target event)]
(if (= (.-readyState xhr) 4)
(if (= (.-status xhr) 200)
(let [res (.-responseText xhr)]
(when res
(yield res)))
(yield (.-statusText xhr))))))
(defn xget [url]
(later [url]
(let [axhr (js/XMLHttpRequest.)]
(.open axhr "GET" url)
(set! (.-onreadystatechange axhr) handle-response)
(.send axhr nil))))
later sends the work to a worker on the pool. yield puts the result in a place. Derefing the later blocks until the message is donewait. I had it working with the service worker hack first, but I forgot how to do it 😆(defn- fetch-event [resolve]
(js/console.log "[ServiceWorker] Fetch")
(js/setTimeout
resolve 1000
(js/Response. "<h1>Hello, world!</h1>"
#js {"headers"
#js {"content-type" "text/html; charset=utf-8"
"Cache-Control" "max-age=31556952,immutable"}})))
(.addEventListener js/self "install" #(js/self.skipWaiting))
(.addEventListener js/self "activate" #(.waitUntil % (js/self.clients.claim)))
(.addEventListener js/self "fetch" #(.respondWith % (js/Promise. fetch-event)))
And that'll work when you hit a page scoped to the service worker from a browser tab. But when I hit it from a worker, it's just returning immediately, with the actual resourcejs/setTimeout call seems wrong?(defn- fetch-event [resolve]
(js/console.log "[ServiceWorker] Fetch")
(js/setTimeout
#(resolve
(js/Response. "<h1>Hello, world!</h1>"
#js {"headers"
#js {"content-type" "text/html; charset=utf-8"
"Cache-Control" "max-age=31556952,immutable"}}))
1000))(defn- fetch-event []
(js/console.log "[ServiceWorker] Fetch")
(-> (js/Promise. #(js/setTimeout % 1000))
(.then #(js/Response.
"<h1>Hello, world!</h1>"
#js {"headers"
#js {"content-type" "text/html; charset=utf-8"
"Cache-Control" "max-age=31556952,immutable"}}))))
(.addEventListener js/self "install" #(js/self.skipWaiting))
(.addEventListener js/self "activate" #(.waitUntil % (js/self.clients.claim)))
(.addEventListener js/self "fetch" #(.respondWith % (fetch-event)))ReferenceError: shadow$bridge is not defined
at eval (shadow.js.shim.module$aws_amplify.js? [sm]:3:11)
at eval (<anonymous>)
at goog.globalEval (live.js:472:11)
at env.evalLoad (live.js:1533:12)
at live.js:1834:12
reportError @ live.js:1425
env.evalLoad @ live.js:1535
(anonymous) @ live.js:1834
Any ideas would be cool. If it’s not possible, that’s cool too. I’d appreciate a heads up on the not possible part, so I don’t waste a bunch of time. CHEERS and CLJS!
Edit: After a little bit of time, I get a connection error. I’ve got a 404 on bundle.js.(sleep 100) but it's a start:js-provider :external. must make sure that the :external-index file is loaded before the CLJS output, it provides the shadow$bridge functionshadow$cljs$devtools$client$websocket$start @ websocket.cljs:12
eval @ shared.cljs:324
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shared.cljs:509
eval @ browser.cljs:337
goog.globalEval @ live.js:472
env.evalLoad @ live.js:1533
(anonymous) @ live.js:1777
I start getting errors after all data has finished loading. It’s refresh to load at this point.
EDIT 1:
I had a nice walk and it came to me… I’ve got to allow websocket traffic on 9630. I’m not sure how to do this, but at this point it’s most def not your problem. Cheers!
EDIT 2: That was crazy easy! I’m super impressed with how well designed this tool is.:devtools-url "" (or whereever shadow-cljs actually runs) if you don't want to proxy 9630 https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-supportnpx shadow-cljs compile react it would take 8-10 seconds. (Relevant shadow-cljs.edn part below).
Suddenly, after a seemingly insignificant change, the compile time dropped to consistently under a second, I started seeing the following warning when running the React app in dev mode:
WARNING in ../Zephyr/zephyr/dist/cljs-runtime/cljs_env.js 1822:9-49 Critical dependency: the request of a dependency is an expression @ ../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23 @ ../Zephyr/zephyr/dist/zephyr.js 3:0-59 @ ./src/components/ZephyrStaticInline.js 7:0-40 33:29-40 @ ./src/App.js 7:0-71 69:133-154 @ ./src/index.js 11:0-24 18:35-38There's nothing remarkable in the code at those points that I could see, and I did not change any dependencies or even any requires. Has anyone seen this warning before or such an order of magnitude drop in compile times? (I'm not sure how the file size changed.) I'd appreciate any pointers you have. The relevant part of the
shadow-cljs.edn file is
:react {:target :esm
:output-dir "dist"
:modules {:zephyr
{:exports {:math zephyr.core/math
:equation zephyr.core/equation
:inline zephyr.core/inline
:align zephyr.core/align
:staticLaTeX zephyr.core/staticLaTeX}}}
:js-options {:js-provider :import}
:compiler-options {:infer-externs :auto
:output-feature-set :es2018
:optimizations :advanced}}
Again this has worked flawlessly for quite a while.
Thanks for your help!../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23 that location in the file?import "./cljs_env.js";
{[key id] entity} as its format instead of {key {id entity}}?(assoc-in db (conj some-ident :some-key) 1), so (assoc-in db [some-ident :some-key] 1) looks many times cleaner to meassoc not assoc-in?some-ident is the ident of an entity and this presents adding a {:some-key 1} to it(update db some-ident assoc :some-key 1)(update-in db some-ident assoc :some-key 1) but i've seen people go a little cross eyed when first encountering that type of thingget-in away" sales pitch 😂(instance? Ident thing)[:foo :bar] type things(db/all-idents-of db :some-type) or (db/all-of db :some-type)(assoc db some-ident some-data) the some-ident is added to a special [:shadow.grove.db/all ident-type] set--pseudo-names and then going over the generating sources. it is fairly easy to identify large chunks and associating them with their respective sources:modules may also help. so :modules {:code {:entries [cljs.core]} :target {:entries [the.namespace] :depends-on #{:core}}target.js will only contain code from the namespaces I'm trying to tweak(defn foo [_ _ body] `(doContrived example: ^ But the backtick generates a lot of code that could be more optimal/smaller. So I'm going through various macros now to manually rewrite it to get rid of the backtick. This is where my question comes from. Yeah, inspecting the generated code already helps, this is how I first learned about this bloat :)
new cljs.core.List([new cljs.core.Symbol("do", ... and so onuser=> '`(do(the JS equivalent of those) Manually writing that as:
user=> '(list* 'do body) (list* (quote do) body)yields smaller code. I notice this by re-running the build report.
cljs.analyzer.api and populate a var, so that I can use the var in another namespace (to resolve metadata about vars in CLJS).
When the macro is used from outside of ClojureScript, it's a no-op.
This approach works well, but has a problem with the analysis cache of CLJS. So when I change a dependency or so and restart the compiler/watch process, it crashes, unless I remove this cache, in shadow's case, the .shadow-cljs directory.
What's the story with macro calls from .cljs namespaces - are these cached somehow?(binding [*out* *err*] (println "Requiring cljs.analyzer.api!"))I see the output on the first invocation of shadow-cljs, but not in the second one.
sci.impl.cljs entirely unconditional and make it do whatever it needs to do for CLJS:dev/always hook https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooksdef, I have this:
#?(:clj (def cljs-ns-publics (resolve 'cljs.analyzer.api/ns-publics)))
sci.impl.env or so, which just has a (def resolve nil) which you'll call whenever you need to resolve something.sci.core as your first require you do a conditional so #?(:cljs [sci.impl.cljs] :cljs [sci.impl.cli])(set! env/resolve cljs.analyzer.api/resolve)(alter-var-root! ...) or sosci.core remove all other conditionals you may otherwise havesci.impl.sci so no graalvm issues should exist?sci.impl.cljs , it's called cljs-ns-publicssci.impl.cljs cljs/clj macro combi in CLJ environment[1] [:app] Build completed. (1684 files, 469 compiled, 5 warnings, 15.44s) [1] [1] ------ WARNING #1 - :redef ----------------------------------------------------- [1] Resource: day8/re_frame_10x/inlined_deps/garden/v1v3v10/garden/color.cljc:390:1 [1] abs already refers to: cljs.core/abs being replaced by: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs [1] -------------------------------------------------------------------------------- [1] [1] ------ WARNING #2 - :redef ----------------------------------------------------- [1] Resource: zprint/range.cljc:81:1 [1] abs already refers to: cljs.core/abs being replaced by: zprint.range/abs [1] -------------------------------------------------------------------------------- [1] [1] ------ WARNING #3 - :redef ----------------------------------------------------- [1] Resource: cljc/java_time/duration.cljc:33:1 [1] abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs [1] -------------------------------------------------------------------------------- [1] [1] ------ WARNING #4 - :redef ----------------------------------------------------- [1] Resource: no/en/core.cljc:131:1 [1] parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long [1] -------------------------------------------------------------------------------- [1] [1] ------ WARNING #5 - :redef ----------------------------------------------------- [1] Resource: no/en/core.cljc:136:1 [1] parse-double already refers to: cljs.core/parse-double being replaced by: no.en.core/parse-doubleI get that they are a real thing and due to the new cljs fns, but I don’t control these files, nor am I changing them. I know I can set
:warnings {:redef false}} on compiler options, but then I don’t get other real redef issues.watch but not on recompile?[1] [:renderer] Configuring build. [1] [:app] Configuring build. [1] [:main] Configuring build. [1] [:main] Compiling ... [1] [:renderer] Compiling ... [1] [:app] Compiling ... [1] [:main] Build completed. (86 files, 85 compiled, 0 warnings, 4.00s) [1] WARNING: abs already refers to: #'clojure.core/abs in namespace: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color, being replaced by: #'day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs [1] WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs [1] [:renderer] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.24s) [1] [:app] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.35s) [1] [:app] Configuring build. [1] [:renderer] Configuring build.
npm install npm start
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bcdad5d0d5ccd9cfd5d0caddfcf1dddffed3d3d791ecced3"}, :content ("[email protected]")}src/main/app.cljs, you get the warning------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- [:app] Compiling ... [:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- [:app] Compiling ... [:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- [:app] Compiling ... [:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- [:app] Compiling ... [:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- [:app] Compiling ... [:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: cljc/java_time/duration.cljs:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs --------------------------------------------------------------------------------
WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs that is coming from:warnings-as-errors true set and a custom analyzer warning that is being emitted during macro expansion time, then code excerpt in the reported warning (as error) will be pointing at macro call site (which is expected given that the warning was thrown), but instead what I want is to point the code excerpt at the location that was provided to ana/warning. Not sure if that's also the default behaviour in cljs compiler itself, but I'm curious if there's something can be done to achieve desired behaviourwith-loc uses in that file. of course if you manually call ana/warning it comes solely from the env arg passed to it, which you can also modify prior to callingenv with desired location to ana/warning, but the thrown warning during macroexpansion still points at the macro call site rather than a form within an expression that I'm interested in
(my-macro ... (inc) ...) ;; should report at `(inc)` location
ex-info on a thrown error is not picked up------ ERROR -------------------------------------------------------------------
File: C:\Users\thheller\code\shadow-cljs\src\main\shadow\cljs\ui\components\inspect.cljs:310:13
--------------------------------------------------------------------------------
307 | (when label
308 | (str " - " label)))]
309 | [:div.truncate
310 | (foo.bar)
-------------------^------------------------------------------------------------
null
Use of undeclared Var shadow.cljs.ui.components.inspect/foo
{:warning :undeclared-var, :line 310, :column 14, :msg "Use of undeclared Var shadow.cljs.ui.components.inspect/foo"}
ExceptionInfo: Use of undeclared Var shadow.cljs.ui.components.inspect/foo
shadow.build.compiler/warning-collector (compiler.clj:493)ana/warning directly so I guess that isn't really comparableenv, but only location data, but that's enough for the warning to be printed correctlywith-loc function I linked above:warnings-as-errors truee?
(throw (ex-info nil (error-data env :macroexpansion (var->sym mac-var)) e))data if its a macroexpansion error and then get the data from the (.getCause e) instead:warnings-as-errors so it is isolated to shadow-cljs. so I guess I could add a marker of sorts:warnings-as-errors truewrangler (Cloudflare worker) up
However, when I start it I get:
[mf:err] Error: Failed to construct 'WebSocket': the constructor is not implemented.
at Object.construct (/home/cokap/git/arudik-website/cloudflare-workers/backblaze-download-token-to-secrets/node_modules/@miniflare/web-sockets/src/plugin.ts:37:19)
at shadow$cljs$devtools$client$websocket$start (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/websocket.cljs:12:16)
at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:324:25)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:509:24)
at ../.cljs/cljs-runtime/shadow.cljs.devtools.client.browser.js (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/browser.cljs:337:3)
Is there a way to avoid compiling the browser dev tools in a module?import "./cljs-runtime/shadow.cljs.devtools.client.browser.js";
SHADOW_ENV.setLoaded("shadow.cljs.devtools.client.browser.js");
If I remove the two lines up it seems to work:devtools {:enabled false} in the build configjs-await macro
I did this
(ns cloudflare.workers
(:require [shadow.cljs.modern :refer (js-await)]))
(defn backblaze-download-token-to-secrets
[controller env ctx]
(js-await [result (js/Promise.resolve #js {"foo" "bar"})]
(js/console.log "environment" env)
#js {:response "response"}))
but I don't see any compiled file...the module contains only
import "./cljs_env.js";
{:target :esm
:output-to "target/cloudflare-workers.js"
:output-dir ".cljs"
:modules {:backblaze-download-token-to-secrets
{:exports {default cloudflare.workers/backblaze-download-token-to-secrets}}}
:compiler-options {:output-feature-set :es-next}
:js-options {:entry-keys ["module" "browser" "main"]}
:devtools {:enabled false}
:release {:compiler-options {:source-map true}}}$ cat .cljs/cljs-runtime/shadow.module.backblaze-download-token-to-secrets. shadow.module.backblaze-download-token-to-secrets.append.js shadow.module.backblaze-download-token-to-secrets.prepend.js
.cljs/cljs-runtime/cloudflare.workers.js will have the source from cloudflare.workers nsscheduled functionexport default would be correct yesexport default {
async scheduled(event, env, ctx) {
},
};
an export list with scheduled in it(def thing
#js {:scheduled
(fn [event env ctx]
...)})(def exports #js {:g f
...})thing being the thing referenced in the build configwatch output as is or do only release builds work?watch - haven't tried release yet[mf:err] TypeError: Cannot read properties of undefined (reading 'module_loaded')
at /home/cokap/git/arudik-website/cloudflare-workers/.cljs/backblaze-download-token-to-secrets.js:92:33
as shadow.cljs.devtools.client.env is undefined:console-support false`:console-support has nothing to do with the module stuffglobalThis hacks the watch/compile builds dorelease might work thoughnpx wrangler dev --local
⛅️ wrangler 2.0.17 (update available 2.0.19)
-------------------------------------------------------
Your worker has access to the following bindings:
- Vars:
- B2_APPLICATION_KEY_ID: "foo"
- B2_APPLICATION_KEY: "bar"
╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
▲ [WARNING] Source maps with "sections" are not supported [sections-in-source-map]
../.cljs/backblaze-download-token-to-secrets.js.map:1:61:
⎔ Starting a local server...
╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[mf:inf] Worker reloaded! (0.54KiB)
[mf:inf] Listening on localhost:43843
[mf:inf] -
[mf:inf] Updated `` object cache!
SCHD /cdn-cgi/mf/scheduled 200 OK (0.75ms)shadow.cljs.devtools.client.env/ globalThis an issue can be solved with an additional bundler?
Working against the release code is a bit slow (7s every run before I can try new code)// shadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets");
Things seem to work - having a REPL is nice maybe I'll just go with that 😄shadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets"); should be find and I'm unsure why it wouldn't bemain.js but I am in the middle of something else nowwrangler dev --localbackblaze-download-token-to-secrets$ wrangler dev --local
:partly_sunny:️ wrangler 2.0.21
--------------------
Your worker has access to the following bindings:
- Vars:
- B2_APPLICATION_KEY_ID: "foo"
- B2_APPLICATION_KEY: "bar"
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
▲ [WARNING] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]
out/cljs-runtime/cljs.core.js:37984:63:
37984 │ return cljs.core.find_ns_obj_STAR_((function (){try{var ctxt = eval(cljs.core.first(segs));
╵ ~~~~
⎔ Starting a local server...
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Debugger listening on
For help, see:
Debugger attached.
[mf:inf] Worker reloaded! (2.40MiB)
[mf:wrn] Worker's uncompressed size exceeds the 1MiB limit! Note that your worker will be compressed during upload so you may still be able to deploy it.
[mf:inf] Listening on localhost:8787 supposed to show something? all I get is a white page?(ns cloudflare.workers
(:require [cloudflare.workers.backblaze :as backblaze]))
(def exports
#js {:fetch (fn [request]
(js/Promise.resolve (js/Response. "Hello World.")))
:scheduled backblaze/upload-download-token-to-secrets})Hello World. on http://localhost:8787/;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[]
:builds
{:workers {:target :esm
:output-dir "backblaze-download-token-to-secrets/out"
:modules {:main
{:preloads [shadow.cljs.devtools.client.env]
:exports {default cloudflare.workers/exports}}}
:compiler-options {:output-feature-set :es-next}
:js-options {:entry-keys ["main" "module"]}
:devtools {:enabled false}
:release {:compiler-options {:source-map true}}}}}:preloads is needed because of a bugmodule_loaded being emitted when it shouldn't be, due to :enabled false)watch and release both work just fine thenesbuild stuff, it was there because I was fiddling with cljs.main as well:preloads then:runtime :node but effectively that also does nothingcurlthat endpoint, some traces are written in the wrangler terminalwatch only for now, thanks for your help, if you want me to try any build to get the REPL working I can also definitely do thatcljs.main too there was no way to get the REPL running and I was only getting watch working with -O advancedbrowser-repl or node-repl I guessbrowser-repl or node-repl I guess
right, that probably would suffice, I'll try to see if it "sees" the wrangler runtime, probably now that will worknode-repl would not need wrangler at allnpx shadow-cljs browser-repl, I get this really long error report:
Failed to read: java.io.IOException: Input/output error cljs.user=> Failed to read: java.io.IOException: Input/output error cljs.user=> Failed to read: java.io.IOException: Input/output error cljs.user=> Failed to read: java.io.IOException: Input/output error … cljs.user=> Failed to read: java.io.IOException: Input/output error cljs.user=> Failed to read: java.io.IOException: Input/output error cljs.user=> Worker shutdown.I'm wondering if there is something wrong with my setup. Or is it possible to disable this output? It is not critical, just annoying that terminal gets spammed with 50+ lines.
Ctrl + C
> which OS is this?
macOS Big Sur 11.6.1
> which shadow-cljs version?
2.19.6
> which java version?
openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)CTRL+D?CTRL+D, though CTRL+D in itself works somewhat strange — I have to press them a few times to exit (no reaction on single pressing)shadow-cljs watch …
In such a case it is not so annoying as I think I’m going to keep the server always on.<meta charset="utf-8"> in the head?const {x} = require('/something'); - you recommended this approach to me some time ago.node_modules files so less reliant on closure compiler rewriting:require some JS here and there and sometimes it reloads sometimes it doesn't haven't really dug into that too deep. It's cool to re-eval a react component from the repl and have only the relevant components reload.
To get used to fast-refresh I even turned off file-save and only used eval from my ide to change components, it's quite instant, whereas file save reload can start adding up when the files get bigger. Although forgetting to save a file when you inevitably refresh your browser/state sucks, so I'd say having both is nice 🙂Failed to inspect file
/Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin
it was required from
/Users/mk/dev/ductile/node_modules/zbar.wasm/dist/load-browser.js
Errors encountered while trying to parse file
/Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin
{:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}
I’ve read https://github.com/thheller/wasm-pack-cljs but failing to understand how to adjust it for this use case. Any pointers would be appreciated. 🙏index.production.js:22 Uncaught Error
at s$jscomp$0 (index.production.js:22:1173)
at eval (index.production.js:22:4096)
at Array.map (<anonymous>)
at t (index.production.js:22:4096)
at W.e$jscomp$2.getAllColumns.a$jscomp$2.key (index.production.js:22:4096)
at Object.eval [as getAllColumns] (index.production.js:22:477)
at eval (index.production.js:22:2390)
at Object.eval [as getHeaderGroups] (index.production.js:22:365)
at Function.compute$ui$components$rtable$Table_STAR_ (rtable.cljs:28:27)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:3935:15)
The stacktrace points to lines in the depths of a minified line in the file /node_modules/@tanstack/react-table/build/umd/index.production.js. The process of debugging is a game of guess and check since it's non-obvious what code is failing there. In that same /node_modules/@tanstack/react-table/build/umd directory, I see an index.development.js, and I'm wondering if I could tell shadow to switch to that in hopes the stacktrace becomes usable during development.:resolve to control what gets included https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve:js-options {:resolve {"@tanstack/react-table" {:target :npm :require "@tanstack/react-table/build/umd/index.development.js"}}}babashka.sci. In order to narrow down the problem, I've got it down to this repro:
npx shadow-cljs browser-repl
# wait for the repl to come up
(require '[sci.core :as sci])
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (require (quote [sci.core :as sci])), :source "(require '[sci.core :as sci])", :tag :shadow.cljs.repl/process-ex}
shadow.cljs.repl/process-read-result (repl.clj:504)
shadow.cljs.repl/process-read-result (repl.clj:478)
shadow.cljs.repl/process-input (repl.clj:641)
shadow.cljs.repl/process-input (repl.clj:619)
shadow.cljs.devtools.server.worker.impl/eval82029/fn--82032 (impl.clj:698)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--81669/fn--81670/fn--81678 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--81669/fn--81670 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--81669 (util.clj:241)
java.lang.Thread.run (Thread.java:829).shadow-cljs and see if this helps. If that does help, then use the latest SCI commit on master.shadow-cljs wipe, that didn't fix it, but I can try with master SCI(require 'cljs.analyzer.api) first before sci?:parallel-build defaults to true and another thread might still be working on itcljs.analyzer.api before sci produces the same error as beforecreate-ns new-var init parse-string eval-string* and eval-form. The NPE happens when trying to compile SCI. Also, it does compile just using the cljs compiler. Could you clarify what I should bisect through?sci.core require. I've removed every use of sci, and it's the require that causes the NPE.feature/shadow-cljs branch if you can spare the time: https://github.com/dpetran/dbfluree.db.dbfunctions.core. npx shadow-cljs build browser right?npx shadow-cljs server so I can mash recompile on demand[:browser] Compiling ... The required JS dependency "process" is not available, it was required by "node_modules/js-sha3/src/sha3.js".
npx shadow-cljs compile browsernpm install shadow-cljs in the project is missingnpx shadow-cljs compile browser.npm install before, but npm install shadow-cljs helpedshadow-cljs wasn't in your package.jsonfeature/shadow-cljs branch? 506fdac506fdac32041863dfc782fee0164bace49ac5399clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.11.60"} org.babashka/sci {:mvn/version "0.3.32" }}}' -M:dev -m cljs.main -re node
cljs.user=> (require '[sci.core])
nilfuture and ported injest's auto-parallelizing =>> thread last macro to it and I'm seeing between 2 to 5 times performance increases over a single thread for heavy work loads, even while serializing the work across all the workers. Got a new update showing the latest https://clojureverse.org/t/in-mesh-one-step-closer-to-threads-on-the-web/9069/2?u=john_newman. You might also like the yield thing.59 | (if (satisfies? obj IWithMeta) -----------------------------^-------------------------------------------------- Cannot infer target type in expression (. IWithMeta -org$clojars$roklenarcic$indexed-db$store$obj$)
(satisfies? IWithMeta obj), with the other order this will always end up as false, so probably not what you intended 😉:devtools {:ignore-warnings true} if you'd still rather want the reload. this can of course result it actual errors during load so it is not recommended.typescript that is used as node_module in shadow-cljs project. Is there a way that I can make shadow-clj pick up the changes that I do on the typescript project after every time I compile the typescript project? Currently it seems like I have to restart the repl every time.touch node_modules/your-package/package.json to invalidate the cache shadow-cljs keeps for node_modulesnormalize.css? How do I link it in my index.html? Is there any kind of preprocessor?home-panel used is the question?Holding Code references in State described in the blog postphosphor-react/icons/IconName :default IconName but no lucknode_modules/phosphor-react folder or online via https://unpkg.com/browse/phosphor-react@1.4.1/ for exampledist/icons? so that would be phosphor-react/dist/icons/...The required JS dependency "phosphor-react/dist/icons/Info" is not available,same error
phosphor-react/dist/icons/Info.esm.js works
thank youimport logo from '../logo.svg';https://stackoverflow.com/a/47487760 I found this thread, mentioning that this can be done with Shadow in React Native. Should we expect this solution to also work with React/JS? Is there any other preferred method for including an image?
(js/require "./../../resources/img.png")
https://clojurians.slack.com/archives/C6N245JGG/p1571922982374700[:img {:src "/path/to/file.png"}] or whatever. no require or anything else to find the image.create-react-app project, import logo from '../logo.svg';, does that not bundle the image into the build?
I don’t have a strong enough mental model of how the image asset gets included, and I’m not sure where to look to build that model. I’m reading https://create-react-app.dev/docs/adding-images-fonts-and-files/ for trying to build my mental model. What I understood was that Images do get directly included into the build. But is that just unique to how create-react-app works (and shadow works differently)?check actually do? ie shadow-cljs check app
There's an example in the docs, but doesn't actually say what it does1.10.879 to 1.11.60 and from ShadowCLJS 2.15.12 to 2.19.6.
Since the upgrade we’re seeing a new runtime issue though: Property '$jscomp' doesn't exist
The project is a React-Native app, using the Hermes JS engine. Unfortunately https://hermesengine.dev/docs/language-features/ so we need to target ES5, but so far we could live with that.
As far as I understand $jscomp points to an issue with polyfills not working correctly. Not sure which one specifically though.
That $jscomp error goes away when targeting ES6, but is replaced with other ES6 issues, in particular Property 'Long' doesn't exist. I was wondering if there’s a way to pull in polyfills explicitly using force-library-injection, but I don’t know which polyfill would bring Long and did not find any in https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/polyfills.txt inside the Closure project.
Any suggestions how to dig deeper into the issue? I’ve already tried cleaning .shadow-cljs .
Thanks 🙌$jscomp for polyfills or other compiler generated code that is correct.Property '$jscomp' doesn't exist when does it say that? did you check the generated source if its actually defined? just search for $jscomp= or $jscomp =? maybe it is defined just not in a way that hermes find it?Long isn't a polyfill? its just a regular closure library class so I'm not sure how this relates?SHADOW_ENV.evalLoad("goog.iter.es6.js"... that wasn’t present before. Inside of it there’s a call to $jscomp.inherits(...) which seems to be the one that triggers the error in metro (confirmed by changing the code, renaming $jscomp to something else which changes the error output)goog.structs.map which in the updated version has two new requires: goog.iter.es6 and goog.collections.iters$jscomp setup because of thatglobal.$jscomp = {} to the generated output as a testgoog.base contains this
var jscomp = goog.global["$jscomp"];
if (!jscomp) {
goog.global["$jscomp"] = jscomp = {};
}
but it’s part of the goog.transpile_()global.$jscomp = goog did the trick.{}$jscomp.inherits(...)goog.inherits is not what $jscomp.inherits normally would begoog does not contain any of the other polyfills you might need$jscomp. uses in the code. it should include some assignments not just usesgoog.iter.es6 -> https://gist.github.com/stigi/2ac4488602b52552998fbaf74f92d28f
As far as I can tell the $jscomp.inherits call is part of the extend from the https://github.com/google/closure-library/blob/99a2e56fd143a71ad16381c12017e53989e84b28/closure/goog/iter/es6.js#L116.:force-library-injection #{"es6/util/inherits"} did the trick.react-native target that did not yet make $jscomp available on the global scope (node target already did so though).react-native target that did not yet make $jscomp available on the global scope (node target already did so though).shadow.user? Ideally shadow/version or something similar?(shadow.cljs.devtools.server.util/find-version) but no "official" API method for that or sonpx shadow-cljs release core --debug and then npx shadow-cljs server I get this cryptic error:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
at alpha.cljs:430:5
at screen.js:10293:4screen.js reference is just the last line of the file:
} ; }).call(this); <- here //# sourceMappingURL=screen.js.mapSo I'm not sure which piece of code is calling spec erroneously in advanced mode
future and =>> macros if anybody wants to play with themshadow-grove soon, as I think grove's render architecture probably makes the most sense when pushing updates from a workerCannot read properties of undefined (reading 'prototype') could just mean that somewhere you handed something a reference which is undefined, which could be due to trying to access (.foo thing) and that foo getting renamed making it (.aB thing) or something, thus accessing an undefined field and failing--debug ? It the trace seems to end in the reify call of spec.alpha's map-spec-implshadow will be undefined in :advanced so shadow.cljs would give you the Cannot read properties of undefined (although not the prototype). just giving an example of how :advanced changes the layout of the code:advanced(set! *warn-on-infer* true) in the namespaces that do interop to always see them:compiler-options {:output-wrapper false} in the build config^:export the fns in the inmesh.re-frame ns to get things working/in.mesh/) but I don't need it for this demo(catch ...) statement for the (try) block.
Yet, it pointed to the line of the (go) statement which wrapped the try/catch block.
Only prints the error when executing npx shadow-cljs release app, not with watch app.
Example code which resulted in the error
> unreachable code
(defn foo []
(go ;; <-- loc which error points to
(let [res (<p! awaited-promise)]
(try
(do-stuff)))))
Fixed
(defn foo []
(go
(let [res (<p! awaited-promise)]
(try
(do-stuff)
(catch ...)))) ;; <-- no errorrelease builds. the unreachable part is probably due to the go macro generating something unreachable in case of try without catch? so core.async would be the place to report it?unreachable code outside of go as well it would be a CLJS issue I guessgo and the catch.go macro does some wild rewriting so its probably just a case thats not coveredshadow-cljs.edn for specifying deps to deps.edn and I'm getting this issue:
[2022-07-22 17:17:08.779 - WARNING] :shadow.build/hook-config-ex - {:hook-idx 0, :hook-sym build-css/start-watch-hook, :build-id :app}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling . at (cheshire/core.clj:170:6). {:clojure.error/phase :compile-syntax-check, :clojure.error/line 170, :clojure.error/column 6, :clojure.error/source "cheshire/core.clj", :clojure.error/symbol .}
clojure.lang.Compiler.analyzeSeq (Compiler.java:7119)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7099)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6122)
clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6440)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7099)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
Caused by:
NoClassDefFoundError com/fasterxml/jackson/core/util/JacksonFeatureSet
java.lang.Class.getDeclaredMethods0 (Class.java:-2)
java.lang.Class.privateGetDeclaredMethods (Class.java:3166)
java.lang.Class.privateGetPublicMethods (Class.java:3191)
java.lang.Class.getMethods (Class.java:1904)
clojure.lang.Reflector.getMethods (Reflector.java:498)
clojure.lang.Compiler$HostExpr$Parser.parse (Compiler.java:996)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
clojure.lang.Compiler.analyze (Compiler.java:6793)
Caused by:
ClassNotFoundException com.fasterxml.jackson.core.util.JacksonFeatureSet
jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
java.lang.ClassLoader.loadClass (ClassLoader.java:522)
java.lang.Class.getDeclaredMethods0 (Class.java:-2)
java.lang.Class.privateGetDeclaredMethods (Class.java:3166)
I don't have cheshire as an explicit dependency. I tried this on shadow-cljs v2.17.2 and v2.17.8. I also tried to add cheshire as an explicit dependency on it's latest version and the same thing happens.
My builds build correctly though.:paths and aliases match what your shadow-cljs.edn setup was before:deps true optiondeps.edn file i just specify deps and paths which are identical. I did this because Cursive cannot index libraries and deps from shadow-cljs.edndeps.edn and this is an error you get for a missing dependencyclj -X:deps tree and looked for the mismatches there. There were :exclusions that had to be added.export default {
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
},
};(def that-thing #js {:port 3000 :fetch (fn fetch [request] ...)}):exports {default your.ns/that-thing} in build config(defn ^:export default ...)
default isn't a valid name for a var.(js/export ...)
(def default "whatever") is perfectly valid thoughexport$?(:require
["@tanstack/react-query-devtools" :refer [ReactQueryDevtools]]
....
(js/console.log "devtools function" (ReactQueryDevtools))(ReactQueryDevtools) this is invalid, you cannot call this as a function"browser": "build/umd/index.production.js", in its package.json, which tells shadow-cljs to include that fileNODE_ENV involved anymore since their build already stripped it:dev {:js-options {:resolve {"@tanstack/react-query-devtools" {:target :npm :require "@tanstack/react-query-devtools/dist/umd/index.development.js"}}} in your build config@4.0.10, that needs to go, all it does it get node_modules/@tanstack/react-query-devtools/dist/umd/index.development.jscd node_modules/@tanstack/react-query-devtools and check whats in it:js-package-dirs in the build config as well?node_modules/@tanstack/react-query-devtools/dist/umd/index.development.js from there?node_modules/@tanstack/react-query-devtools/dist/esm/index.jsÃ: 'A',"Ã": 'A', would be fine:js-options {:entry-keys ["module" "browser" "main"]}. won't change the parser error thoughtouch package.json in the node_modules package to make it reloadCaused by:
IllegalStateException: Expected a property access: OBJECT_PATTERN 120:25 [length: 13] [source_file: node_modules/apache-arrow/io/adapters.js]
STRING_KEY cmd 120:27 [length: 3] [source_file: node_modules/apache-arrow/io/adapters.js] [is_shorthand_property: 1]
NAME cmd$jscomp$1 120:27 [length: 3] [source_file: node_modules/apache-arrow/io/adapters.js] [original_name: cmd]
STRING_KEY size 120:32 [length: 4] [source_file: node_modules/apache-arrow/io/adapters.js] [is_shorthand_property: 1]
NAME size$jscomp$23 120:32 [length: 4] [source_file: node_modules/apache-arrow/io/adapters.js] [original_name: size]
Is this a JS "target" issue e.g. es2015 vs esnext or something? I see there are multiple target packages published in https://www.npmjs.com/package/apache-arrow but I'm unsure which one I'd want...
I have my shadow-cljs build configured with :output-feature-set :es6
Thanks!:compiler-options {:output-feature-set :es-next} should maybe make it go away?:npm-deps approach but it doesn't make a difference. I know I can just add the dependency manually to B but it increases the likelihood I update the npm package in one project but not the other. I was wondering if this is a known issue. Maybe it's a specific to this git approach of declaring an npm dependency.:npm-deps? likely just in the wrong place?src folder in a file called deps.cljssrc folder is actually the classpath root? not something like src/main?npm install my-package given that a required library A, requires some package my-package?deps.cljs files on the classpaths and then runs npm install for the packages found there, unless they are already declared as dependencies in the project B package.jsonshadow-cljs.edn:deps that use :local/root?:deps {:aliases [:whatever :aliases :you :need]} in said shadow-cljs.ednshadow-cljs watch works and I can connect to it. But am having difficulty getting a runtime for it. I have tried https://stackoverflow.com/questions/58060822/how-to-connect-a-clojurescript-node-repl-to-my-node-library-shadow-cljs-project but it then tells me that i need to run it with pulumi then when I run pulumi watch I get the error pulumi watch is not currently supported on darwin/arm64 . Can anyone think of a way around this?shadow-cljs version >= 2.17.8 and it happens on two different projects as well.
➜ domo git:(develop) ✗ npm run shadow:watch:app >From what I understand
re-frame-10x depends on re-highlight which in turn depends on highlight.js. I tried with multiple versions of highlight in my package.json as well but with no success.shadow-cljs.edn to run things :jvm-opts ["-Xss16m"] at the rootdeps.edn seems to have done the trick2.19.2(:require ["/barcode-detector-zbar/BarcodeDetector.js$default" :as barcode-detector-polyfill]) in it, I don’t see changes to the js fileresources to src and now it works:deps with shadow, but resources in on the classpath brought in by the root deps declarationresources are filtered out because many people put their outputs into resources/public and watching the resources folder thus becomes very noisy and expensiveUncaught TypeError: gaa.default.setupPolyfill is not a function in advanced. Externs should be inferred automatically with :compiler-options {:infer-externs :auto}, is that correct?cherry-cljs/cljs.core.jsis a target esm-built .js file with core functions. It has e.g.
js-keys which AFAIK doesn't depend on any other core function, so when only importing that, I'd expect that the tree-shaken build of a JS file, would be rather small.:target :jupyter https://github.com/thheller/shadow-cljs/issues/1039. But am also on slack 👋:esm would also be helpful for me 🙂:esm solves everything :) - Have you tried it @bbss?:npm-module, but that doesn't seem to inject the repl, unacceptable!:compiler-options :externs?:npm-module builds you just need to require the REPL client ns *from* javascript somewhere. so something like if (process.env.NODE_ENV === "development") { require("./path-to-cljs/shadow.cljs.devtools.client.browser"); } or sonpm-module though, since eventually jupyter notebook extensions run in the browser anyway..:npm-module build doesn't have a clearly defined "entry" point:browser and the others do so shadow-cljs can ensure that the devtools client is loaded before thoseReferenceError: shadow$provide is not defined:npm-module doesn't use shadow$provide unless you specifically configure it? or was that :target :browser?if (process.env.NODE_ENV === "development") { require("./lib/shadow.cljs.devtools.client.browser"); }:target :esmshadow-cljs clj-repl and immediately execute some code in it? Right now, I'm having to do: clojure -M:dev:shadow-cljs clj-repl, and then inside the repl I have to type (integrant.repl/go). Can I do it in a single line?
I've been trying to combine clj-eval and clj-repl options, but that doesn't seem to work.clj-repl or do you just leave that running and connect via nrepl or so?(defn start {:shadow/requires-server true} [] (integrant.repl/go)) and shadow-cljs run that.ns/startshadow-cljs.edn
:deps ["cljs"]
and my deps files
:deps {foo ...} :aliases {:cljs {:extra-deps {bar ....}:deps ["cljs"] does not activate any aliases :deps {:aliases [:cljs]} does2.19.8, but I'm getting Exception in thread "main" Syntax error compiling at (shadow/build/data.clj:362:5)... something that seems to be related to clojure.lang.Compiler.analyze. Do I miss an exclusion?{:paths ["src" "resources"]
:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
integrant/integrant {:mvn/version "0.8.0"}
ring/ring-core {:mvn/version "1.9.5"}
ring/ring-jetty-adapter {:mvn/version "1.9.5"}
metosin/reitit {:mvn/version "0.5.17"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
org.slf4j/log4j-over-slf4j {:mvn/version "2.0.0-alpha7"}
org.slf4j/slf4j-jdk14 {:mvn/version "2.0.0-alpha7"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
;; front-end
org.clojure/clojurescript {:mvn/version "1.11.4"}
reagent/reagent {:mvn/version "1.1.1"}
re-frame/re-frame {:mvn/version "1.3.0-rc3"}
cljs-bean/cljs-bean {:mvn/version "1.8.0"}
day8.re-frame/http-fx {:mvn/version "0.2.4"
:exclusions [commons-logging/commons-logging]}
day8.re-frame/test {:mvn/version "0.1.5"}
hickory/hickory {:mvn/version "0.7.1"}
metosin/reitit-frontend {:mvn/version "0.5.17"}
metosin/reitit-schema {:mvn/version "0.5.17"}
re-frame-utils/re-frame-utils {:mvn/version "0.1.0"}
inflections/inflections {:mvn/version "0.13.2"}}
:aliases
{:shadow-cljs
{:extra-paths ["test"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.19.8"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:dev
{:extra-paths ["dev"]
:extra-deps
{integrant/repl {:mvn/version "0.3.2"}}}
:test
{:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}
:build
{:extra-paths ["src"]
:extra-deps {io.github.clojure/tools.build
{:git/tag "v0.8.1" :git/sha "7d40500"}}
:ns-default build}
:cider-cljs {:main-opts
["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}1.11.60shadow.cljs.devtools.api/nrepl-select:app`, it complains :missing-nrepl-middleware. Do I need to add piggieback? I thought you don't have to when using deps.edn with shadow-cljs, no?:cider-cljs alias?:repl-options {:init-ns user into :shadow-cljs alias, now when I run clojure -M:dev:shadow-cljs clj-repl, should I expect it to land me in user ns? Because it doesn't. It still starts in shadow.user:repl {:init-ns user} in shadow-cljs.edn at the top level. but that again would only affect the nrepl server started by shadow-cljs? which I guess you don't actually use?------ WARNING #1 - :redef ----------------------------------------------------- Resource: no/en/core.cljc:137:1 -------------------------------------------------------------------------------- 134 | [s] 135 | (parse-number s #(#?(:clj Integer/parseInt :cljs js/parseInt) %1))) 136 | 137 | (defn parse-long -------^------------------------------------------------------------------------ parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long -------------------------------------------------------------------------------- ...
Failed to inspect file
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin
it was required from
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/load-browser.js
Errors encountered while trying to parse file
/Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin
{:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}:simple I guess?zbar.wasm?:advanced was renaming all of them, so I changed imports.wbg.* to imports["wbg"]["..."] instead:target :esm you can also load it via (:require ["esm:./BarcodeDetectorPolyfill.min.js$default" :as barcode-detector-polyfill])import since it already is a ES moduleesm: just tells shadow-cljs to do a runtime import instead of a build time importdynamic-import also works, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116:target :browser I guess):esm much but there isn't much to work on. it seems to work fine.import() still I think, something regarding that broke)main.js:1425 ReferenceError: shadow_esm_import is not defined with dyanamic import:prepend "function shadow_esm_import(name) { return import(name) }" to your build :modules config:entries<script> tag in the page also works(.-default mod)?(.construct js/Reflect (.-default polyfill-module) #js []) or is there an easier way?(new (.-default polyfill-module))?(-> (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")
(.then (fn [^js mod]
(let [$default (.-default mod)]
(js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
(.setupPolyfill $default)
(doto (new $default)
(js/console.log))))))(js-await [^js mod (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")]
(let [$default (.-default mod)]
(js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
(.setupPolyfill $default)
(doto (new $default)
(js/console.log))))[shadow.cljs.modern :refer (js-await)]:paths ? i have some cljc i need to share between front and back ends. I get a warning when i try
:paths ["../../components" "src"]
:paths is deps.edn and therefore the rules of tools.deps apply. basically you need to use :local/root if you want to get outside the project2.17.4 facepalm:esm build but hitting:
[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/Users/baruchberger/opt/anaconda3/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'
:npm-module watch build I'm hitting:
Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefaultwith
:npm-module release build I'm hitting:
ReferenceError: shadow$provide is not defined
tldr: If you have conda installed: conda install -c conda-forge jupyterlab or pip install jupyterlab If you are using a macOS version that comes with Python 2, run pip3 instead of pip.
apt-get install python maybe?{:target :esm
:output-dir "lib"
:modules {:notebookesm {:exports-var notebook/extension}}
:runtime :browser
:js-options {:js-provider :import}}$ jupyter lab --watch [I 2022-07-28 10:45:12.917 ServerApp] jupyterlab | extension was successfully linked. [I 2022-07-28 10:45:12.927 ServerApp] nbclassic | extension was successfully linked. [I 2022-07-28 10:45:12.930 ServerApp] Writing Jupyter server cookie secret to /home/thheller/.local/share/jupyter/runtime/jupyter_cookie_secret [I 2022-07-28 10:45:13.458 ServerApp] notebook_shim | extension was successfully linked. [I 2022-07-28 10:45:13.600 ServerApp] notebook_shim | extension was successfully loaded. [I 2022-07-28 10:45:13.601 LabApp] JupyterLab extension loaded from /home/thheller/.local/lib/python3.9/site-packages/jupyterlab [I 2022-07-28 10:45:13.601 LabApp] JupyterLab application directory is /home/thheller/.local/share/jupyter/lab [I 2022-07-28 10:45:13.602 LabApp] Starting JupyterLab watch mode... -
[2022-07-28 17:20:57.673 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@jupyterlab/codemirror/lib/mode.js", :requires [{:line 38, :column 20}]}
------ WARNING #1 - -----------------------------------------------------------
Resource: node_modules/h3-js/dist/browser/h3-js.js:674:2
@suppress annotation not allowed here. See
--------------------------------------------------------------------------------
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0xa) at pc=0x00000001042039c4, pid=28319, tid=47875
#
# JRE version: OpenJDK Runtime Environment Homebrew (11.0.12) (build 11.0.12+0)
# Java VM: OpenJDK 64-Bit Server VM Homebrew (11.0.12+0, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# V [libjvm.dylib+0x5279c4] _ZN15PcDescContainer21find_pc_desc_internalEPhbRK12PcDescSearch+0xf4
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/baruchberger/jupyter-compilation-target/hs_err_pid28319.log
Compiled method (c2) 1469217 22524 ! 4 clojure.core.async$mult$fn__9046$state_machine__7801__auto____9059$fn__9064::invoke (5095 bytes)
total in heap [0x00000001158cc590,0x00000001158e4620] = 98448
This site can’t be reachedlink seems fine thoughX Compilation failed. NullPointerException: clojure.string/index-of (string.clj:327) clojure.string/index-of (string.clj:319) shadow.build.targets.esm/replace-goog-global* (esm.clj:334) shadow.build.targets.esm/replace-goog-global* (esm.clj:328) clojure.core/apply (core.clj:669) clojure.core/update-in/up--6922 (core.clj:6220) clojure.core/update-in/up--6922 (core.clj:6219) clojure.core/update-in/up--6922 (core.clj:6219) clojure.core/update-in (core.clj:6221) clojure.core/update-in (core.clj:6207) shadow.build.targets.esm/replace-goog-global (esm.clj:362) shadow.build.targets.esm/replace-goog-global (esm.clj:350) shadow.build.targets.esm/process (esm.clj:473) shadow.build.targets.esm/process (esm.clj:465) clojure.lang.Var.invoke (Var.java:384) shadow.build/process-stage/fn--15861 (build.clj:163) shadow.build/process-stage (build.clj:160) shadow.build/process-stage (build.clj:152) shadow.build/compile (build.clj:511) shadow.build/compile (build.clj:493) shadow.cljs.devtools.server.remote-ext/do-build/fn--20767 (remote_ext.clj:104) clojure.core/binding-conveyor-fn/fn--5823 (core.clj:2047) java.util.concurrent.FutureTask.run (FutureTask.java:264) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628) java.lang.Thread.run (Thread.java:829)
{:deps {:aliases [:dev]}
:nrepl {:port 12000}
:builds {:notebook-esm
{:target :esm
:output-dir "lib"
:modules {:notebookesm {:exports-var notebook/extension}}
:runtime :browser
:js-options {:js-provider :import}}}}link had errorsValueError: "
[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/home/thheller/.local/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'
"files": [
"index.js",
"lib/*.{js,js.map}"
],cljs-runtime dir?watch and REPL working here 😛shadow-cljs: #5 ready!undefined 'extension in index.js'hello world from the REPL{:deps {:aliases [:dev]}
:nrepl {:port 12000}
:builds {:notebook-esm
{:target :esm
:output-dir "lib"
:modules {:notebookesm {:exports {extension notebook/extension}}}
:runtime :browser
:js-options {:js-provider :import}}}}
?viv.es.js and why is it on the classpath?link really necessary always?viv.es.js is confusing{id: 'jupyter-compilation-target.notebook', autoStart: true, optional: Array(1), requires: Array(2), activate: ƒ} 'extension in index.js'activate W {_started: true, _pluginMap: {…}, _serviceMap: Map(60), _delegate: e, commands: e, …} _e {_currentChanged: e, _isDisposed: false, _widgetAdded: e, _widgetUpdated: e, _focusTracker: e, …}λ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)
λ clj -Srepro -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.19.7"}}}' -M -m shadow.cljs.devtools.cli browser-repl
...
Caused by: java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CompilerOptions has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
...
From the Closure Compiler release notes (https://github.com/google/closure-compiler/wiki/Releases#june-1st-2022-v20220601):
> Java 11 or newer is now required to run Closure Compiler.
Just a heads up. Guess there's little to be done about that.clj -Stree what is the equivalent for shadow projects?
[:app] Compiling ...
[2022-07-28 11:42:00.658 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoSuchMethodError com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()Lcom/google/protobuf/Internal$IntList;
com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24)
com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2379)
com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63)
com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15)
com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909)
com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903)
com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)
com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66)
com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15)
com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283)
com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277)
com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)com.google.javascript is the closure-compiler(shadow.cljs.devtools.api/compile! :app) I guessmysql/mysql-connector-java 8.0.19 that depended on com.google.protobuf/protobuf-java 3.6.1 . Upgraded to mysql/mysql-connector-java 8.0.30 , which seems to have done the trick.clj -A:dev:cljs -Stree was really helpful!
I'm starting to appreciate your recommendation to manage all CLJS dependencies exclusively with Shadow CLJS.
For others interested, learn more here: https://github.com/thheller/shadow-cljs/issues/983#issuecomment-1041190965NoSuchMethodError 'com.google.protobuf.Internal$IntList com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()' com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24) com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2391) com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63) com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15) com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909) com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903) com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424) com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66) com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15) com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283) com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277) com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424)and it was caused by an older version of the mysql-connector as well, upgrading to mysql/mysql-connector-java 8.0.30 fixed it I would have never suspected this one
react-native-logs to my react-native shadow-cljs project, so I yarn'd it, created a new namespace and added ["react-native-logs" :refer [logger]] but nothing I did could get logger to appear in the REPL (loading file or namespace) in a way that made sense. I thought maybe it was an ecma issue and tried react-native-logs$default, tried :as instead, but nothing worked. I got AssertionError Assert failed: (rc/valid-resource? rc)errors in the shadow-cljs console :thinking_face:. However it all worked perfectly if I used it from within the :app main namespace, or even required the new namespace from a linked one ❗ Obviously very unlike a Clojure REPL experience. I was wondering if it would be possible to give a hint in this scenarios so others don't suffer the hours it took me 😅AssertionError Assert failed: (rc/valid-resource? rc) and in which context did you get it?[2022-07-29 13:08:26.165 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(cljs.core/load-file \"/Users/dmg46664/projects/samson/src/main/dimigi/network.cljs\")", :ns user, :repl true}, :include-init false, :call-id 5, :from 3}}
AssertionError Assert failed: (rc/valid-resource? rc)
shadow.build.data/add-source (data.clj:220)
shadow.build.data/add-source (data.clj:220)
shadow.cljs.repl/repl-ns (repl.clj:325)
shadow.cljs.repl/repl-ns (repl.clj:319)
shadow.cljs.repl/process-read-result (repl.clj:504)
shadow.cljs.repl/process-read-result (repl.clj:484)
shadow.cljs.repl/process-input (repl.clj:647)
shadow.cljs.repl/process-input (repl.clj:625)
shadow.cljs.repl/repl-load-file* (repl.clj:281)
shadow.cljs.repl/repl-load-file* (repl.clj:259)
shadow.cljs.repl/repl-load-file (repl.clj:317)
shadow.cljs.repl/repl-load-file (repl.clj:315):version "2.19.8" in shadow-cljs edn if you want to be less reliant on npm/yarn stuffshadow-cljs - server version: 2.19.8 running at
2.11.7 I got a little more out of the stacktrace:
"react-native-logs" - failed: simple-symbol? in: [:requires 3] at: [:requires] spec: :shadow.build.resource/require
cider-nrepl as well?Errors encountered while trying to parse file
/home/tianshu/workspace/race-poker/racepoker-dapp/node_modules/lower-case/dist/index.js
{:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}
Got some errors, the JS file is
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lowerCase = exports.localeLowerCase = void 0;
/**
* Source:
*/
var SUPPORTED_LOCALE = {
tr: {
regexp: /\u0130|\u0049|\u0049\u0307/g,
map: {
İ: "\u0069",
I: "\u0131",
İ: "\u0069",
},
},
...
The reason could be shadow-cljs has its own identifier rules?node_modules/my-lower-case and just copied the original package.json file thereprint instead of tap>.shadow.user=> (alter-var-root #'shadow.build.npm/find-resource-in-package
(fn [orig]
(fn [npm package require-from rel-require]
(try
(orig npm package require-from rel-require)
(catch Exception e
(tap> [:what rel-require package require-from])
(throw e))))))
#object[shadow.user$eval25371$fn__25372$fn__25373 0xead9010e "println goesshadow-cljs clj-repl did it start a new instance(throw (ex-info "a more helpful error" {:package package}) e))(throw e)orig . But it shows me a package I used to have it in my project.rel-require here is
.-v2
spl-token, and now there's a package called spl-token-v2. JS is AmazingExceptionInfo: failed to convert sources
shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1993)
shadow.build.closure/convert-sources-simple* (closure.clj:1980)
shadow.build.closure/convert-sources-simple* (closure.clj:1849)
shadow.build.closure/convert-sources-simple (closure.clj:2154)
shadow.build.closure/convert-sources-simple (closure.clj:2104)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1467)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:492)
shadow.build/compile (build.clj:482)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
java.lang.Thread.run (Thread.java:836)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
null
Node(SHEQ): node_modules/noble-ed25519/index.js:292:23
const isXOdd = (x & 1n) === 1n;
Parent(SHNE): node_modules/noble-ed25519/index.js:293:12
if (isLastByteOdd !== isXOdd) {
com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2882)
com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:566)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
shadow.build.closure/convert-sources-simple* (closure.clj:1980)
shadow.build.closure/convert-sources-simple* (closure.clj:1849)
shadow.build.closure/convert-sources-simple (closure.clj:2154)
shadow.build.closure/convert-sources-simple (closure.clj:2104)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1467)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:492)
shadow.build/compile (build.clj:482)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
java.lang.Thread.run (Thread.java:836)
Caused by:
NullPointerException:
com.google.javascript.jscomp.PeepholeFoldConstants.tryStrictEqualityComparison (PeepholeFoldConstants.java:1387)
com.google.javascript.jscomp.PeepholeFoldConstants.evaluateComparison (PeepholeFoldConstants.java:1416)
com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldComparison (PeepholeFoldConstants.java:1160)
com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldBinaryOperator (PeepholeFoldConstants.java:188)
com.google.javascript.jscomp.PeepholeFoldConstants.optimizeSubtree (PeepholeFoldConstants.java:104)
com.google.javascript.jscomp.PeepholeOptimizationsPass$PeepCallback.visit (PeepholeOptimizationsPass.java:82)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:856)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.handleClassMembers (NodeTraversal.java:970)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:812)
com.google.javascript.jscomp.NodeTraversal.handleClass (NodeTraversal.java:945)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:809)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:984)
com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:748)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:800)
com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:459)
com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:566)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
shadow.build.closure/convert-sources-simple* (closure.clj:1980)
shadow.build.closure/convert-sources-simple* (closure.clj:1849)
shadow.build.closure/convert-sources-simple (closure.clj:2154)
shadow.build.closure/convert-sources-simple (closure.clj:2104)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
shadow.build.compiler/compile-all (compiler.clj:1467)
shadow.build.compiler/compile-all (compiler.clj:1330)
shadow.build.api/compile-sources (api.clj:261)
shadow.build.api/compile-sources (api.clj:253)
shadow.build/compile (build.clj:492)
shadow.build/compile (build.clj:482)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
clojure.lang.MultiFn.invoke (MultiFn.java:234)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
java.lang.Thread.run (Thread.java:836)node_modules/noble-ed25519 not the one you linkedjs-provider, I should bundle the dependencies with webpack?(ns (:require ["react" :as react]))So I can have this in my CLJS codes, if I bundle the react in a
lib.js?
But what code I should provide in that target/index.js?:external-index file to webpack or whatever--output no longer available... rather than at the :asset-path relative to the origin? We store our compiled JS files & sourcemap files on a cloud storage bucket:source-map-asset-path or :source-map-path.
https://clojurescript.org/reference/compiler-options
Not entirely sure of the difference between those two quite yet...sourceMappingUrl is a relative path. However, when I open up dev tools, I'm seeing some "Devtools failed to load source map. Could not parse content for <some-url>.js.map", with that url being the page origin rather than the Google Cloud Storage url.
It seems like the sourceMappingUrl relative path is being appended to the page origin rather than the GCS origin<script src=""></script>The other modules are then lazy-loaded as users interact with the app (those are also requested and served from the Google cloud storage bucket) Interestingly, for the initial
client.js bundle, I don't see a "Devtools failed to load source map" warning, perhaps suggesting that the initial one is loaded correctly? For all of the subsequent lazy-loaded modules, I see a corresponding warning about not being able to load that module's source maplazy-component , shadow.lazy, etc
:asset-path "/js/compiled"
:asset-path is a little misleading in the name. should be :asset-prefix or something. you can put an entire URL in thereclient.js bundle is lazy-loading the other modules from a relative path appended to our document location. This isn't erroring because those relative paths resolve to actual files that are hosted on the server (during the switchover from Firebase hosting to GCS, we continued to upload the compiled JS files to both locations). However, we are not uploading the source maps to Firebase hosting, which explains the initial "Devtools failed to load source map." issue from the lazy-loaded modules
User error on my part - thanks for patiently helping me work through the issue. To resolve this, sounds like I'd want to update the :asset-path to the GCS asset pathshadow-cljs watch does not publish any messages on file changes.
I found https://github.com/thheller/shadow-cljs/issues/210 but it does not work (maybe too old).
This does not appear to be a network problem, as a websocket connection is established and ping/pong messages are sent.
Does anyone know any hints?
Thanks:target :browser support js/require?require(...)? 😛 no, it doesn't.(def sym (js/require...) but
I'm sure now that is the case for :target :react-native for eg. https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L11
Thanks for the confirmation. 😉createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props }) {
render(<App {...props} />, el)
},
})js/require would be supported, assuming the shadow-cljs is run through the webpack build as well:js-provider :externaloption for example.
I'm thinking about using your Next-cljs hook trick https://github.com/thheller/next-cljs/blob/master/shadow-cljs.edn#L13 to generate pages to require it automatically like the above Inertia example.:external would not work for this. the CLJS output doesn't go through webpack in that case:external would not work for this
Ha ok. so what the solution? Continue to use :target :browserand pass the generated JS bundled file through Webpack directly?data-page attribute containing a stringify JSON obj. Eg:
<div id="app" data-page="{component: \"homepage\", props:{}">pageobject to get props and the current component name (here homepage).
createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props }) {
render(<App {...props} />, el)
},
})require line automatically import ./Pages/homepage.js component.:npm-module sort of is the most granular:browser output is not meant to go through another build tool:npm-module or :esm for that:target :node-library and I want to use js/performance.now which is a browser global, available with const { performance } = require('perf_hooks'); on node.
see this https://stackoverflow.com/questions/23003252/window-performance-now-equivalent-in-nodejs ...
Is there an easy way to get this work, I am hacking with someone elses code, so I am mostly in the dark with clojure tbh.
I tried (:require ["perf_hooks" :refer (performance)] ) but that was giving me "Use of undeclared Var performance/now"
I am stuck :|:refer you'd do (.now performance), :refer does not set up a namespace alias so performance/ doesn't work. you can do (:require ["perf_hooks$performance" :as perf]) and then (perf/now).:repl/exception! ; ; Execution error (TypeError) at (<cljs repl>:1). Cannot read properties of null (reading 'cljs$core$IFn$_invoke$arity$1')I can't figure out what's going wrong using just this info, is there any way to get more detailed traces?
(foo 1 2 3) when foo is nil(defn calls-nil [f] (f 1 2 3 4 5)) (calls-nil nil)Eval in REPL using standard Calva shortcut gets me:
:repl/exception! ; ; Execution error (TypeError) at (<cljs repl>:1). Cannot read properties of null (reading 'call')
calls-nil, I get proper traces in the browser console:(.-stack *e) after the errors(js/console.log *e) would give you the above too I guess*e , or is it only possible by js/console.log ing it?npx shadow-cljs -A:cljs:git-deps:test compile test-ci && node cljs-out/test-ci/node-tests.js
{:target :node-test
:compiler-options {:optimizations :whitespace}
:output-to "cljs-out/test-ci/node-tests.js"
;:ns-regexp "^\b([a-z\\-]+)\b(?<!render|ignoreme)-test"
; cannot use autorun if return code is needed. see shadow docs link above
:autorun true}
node -e "require('fs').mkdirSync(null)" echo $! does not have a 0 exit code?(assoc-in build-state [:compiler-env :cljs.analyzer/namespaces your.ns :shadow.resource/resource-refs "some/path.css"] last-mod)"resources/public/styles.css" becomes "public/styles.css":compiler-finish stage would do ittouch a-source-file.cljs to trigger a recompilation after editing the cssdeps.edn and shadow, and I didn't include the shadow-cljs in my release alias, and it failed to build.npm shadow-cljs package confused you. that is in fact only doing the CLI things. the actual building is done by the thheller/shadow-cljs dependency you have in deps.ednrelease alias for dependencies for a CLJS build and other heroku alternatives, they offer a free static site deployment. So what I was doing is compiling my shadow-cljs project in release mode on my computer and then pushing that whole project to github where it automatically gets deployed for me. So now I get to use their free deployment tier with no "sleep" mode like I have when deploying my full stack apps. Since I'm not including a Dockerfile to install java and compile it on their machines they are counting it as just a "static site." Does that sound reasonable or am I missing some obvious downside here?js bundle
• create the index.html
• pretend to use PHPmain.js file as I expected but it's also downloading a react_devtools_backend.js file that is 578 kb. Is that too be expected (I'm thinking that's react itself so required) or is that an artifact from my development builds? If the latter, how do I remove that before uploading to github in the method I mentioned in my first question?cljs-runtime folder I'm seeing in resources/public/js and can I throw that in my .gitignore file when pushing to github? I'll try that and see what happens.cljs-runtime folder in the release deployment and it still works so I assume it's not needed. But it's still downloading the react_devtools_backend.js file which is killing my lighthouse performance score (getting a 62 with a simple "Hello World") but I hear that might be an overrated benchmark anyways I guess.react_devtools_backend.js i.e. it only gets loaded when you open up devtools + have React devtools installedcljs-runtime dir is not needed for release builds.react_devtools_backend.js is indeed from the chrome extension and not something shadow-cljs bundles/producesmain.js https://shadow-cljs.github.io/docs/UsersGuide.html#build-report------ WARNING #1 - :redef ----------------------------------------------------- Resource: garden/color.cljc:390:1 -------------------------------------------------------------------------------- 387 | (let [d (util/clip 1 179 distance-from-complement)] 388 | (hue-rotations color 0 d (- d))))) 389 | 390 | (defn- abs -------^------------------------------------------------------------------------ abs already refers to: cljs.core/abs being replaced by: garden.color/abs -------------------------------------------------------------------------------- 391 | [x] 392 | (if (neg? x) (- x) x)) 393 | 394 | (defn tetrad --------------------------------------------------------------------------------I will probably submit a PR to the Garden project on GH, but it would be kind of nice to not have that warning in the meantime. It's not affecting me anyway.
(:refer-clojure :exclude [abs complement]) in the NS form of the relevant garden/color.cljc file. Not sure if that has anything to do with shadow-cljs though, or is an issue with the CLJS compiler1.3.10, and it looks like that version release was made after the commit you linked above, so it'd be odd for it not to be included in the release( "garden/color.cljc") and just look at it{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dca8b5bfb79cecf2e9f2ec"}, :content ("[email protected]")}. I changed my code to point to tick.core instead of tick.alpha.api. Running release locally I have no issues, but running on CI (github action) gives me the following error. I have removed all references to tick.alpha.api in my code. Any help in pinpointing what the issue could be?
Run shadow-cljs -v release app
shadow-cljs -v release app
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-puo472pwx35q/agent.1748
SSH_AGENT_PID: 1749
JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.16-8/x64
shadow-cljs - config: /home/runner/work/innsmouth/innsmouth/shadow-cljs.edn
shadow-cljs - starting via "clojure"
DEPRECATED: Libs must be qualified, change figwheel-sidecar => figwheel-sidecar/figwheel-sidecar (deps.edn)
DEPRECATED: Libs must be qualified, change hashp => hashp/hashp (deps.edn)
[2022-08-11 22:00:26.689 - WARNING] :shadow.build.classpath/bad-jar-contents - {:jar-file "/home/runner/.m2/repository/re-frame-utils/re-frame-utils/0.1.0/re-frame-utils-0.1.0.jar", :bad-prefix "out", :bad-count 67}
[:app] Compiling ...
-> build target: :browser stage: :configure
<- build target: :browser stage: :configure (5 ms)
-> Resolving Module: :app
The required namespace "tick.alpha.api" is not available, it was required by "innsmouth/controller/accounts.cljs".innsmouth/controller/accounts.cljs file actually is what you think it isdeps.edn so maybe you are loading that from a library or somethinghooks.main filehtml, I need to grab a component in the cljs side and call it inside hiccups htmlhtml formhtml, I want to write a symbol that references a reagent component definition written in cljs, then I want that fn call to return inside the html hiccup form, I want to eval it and return when the build calls html:node-script build that takes your CLJS code and uses react-based server side rendering to create that index.htmlCannot infer target type in expression (. (. Foo -prototype) -bar)
(deftype Foo [] Object (bar [this] nil))Tried this using
cljs.main and didn't see any such warnings. Seems like it was addressed awhile ago in this ticket - https://clojure.atlassian.net/browse/CLJS-2862, and I'm using the latest shadow-cljs / clojurescript version--cli-info, which gives me:
=== Version jar: 2.19.8 cli: 2.19.8 deps: 1.3.2 config-version: 2.19.8
shadow-cljs command itselfnpx , but I can setup a deps.edn file:deps or :lein key in shadow-cljs.edn?npx shadow-cljs compile :app with a shadow-cljs.edn that looks like:
;; shadow-cljs configuration
{:source-paths ["src" "test"]
:dependencies
[]
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main {:init-fn example.browser/init}}}}}example.browser?(ns example.browser) (deftype Foo [] Object (bar [this] nil)) (defn init [] (js/console.log (Foo.)))
:aot false in shadow-cljs.edn it goes away:deps/prep-lib {:alias :build
:fn compile
:ensure "target/classes"}
and get this error:
Error building classpath. The following libs must be prepared before use: [com.phronemophobic/membrane]cannot work out how to resolve it, clojure -X:deps prep doesn't appear to be doing anything
{:deps {io.github.phronmophobic/membrane {:git/sha "75d38cca6973a4cdd073d3c0a41cb7fb3f48ad77"}}}
and then the following terminal session:
❯ clj
Error building classpath. The following libs must be prepared before use: [io.github.phronmophobic/membrane]
/tmp/prep
❯ clj -X:deps prep
Prepping io.github.phronmophobic/membrane in /Users/dan/.gitlibs/libs/io.github.phronmophobic/membrane/75d38cca6973a4cdd073d3c0a41cb7fb3f48ad77
WARNING: compile already refers to: #'clojure.core/compile in namespace: build, being replaced by: #'build/compile
warning: [options] bootstrap class path not set in conjunction with -source 8
/tmp/prep
❯ clj
Clojure 1.11.1
user=> (doto 'counter require in-ns)
counter
counter=> (java2d/run #(counter @counter-state))
#:membrane.java2d{:repaint #object[membrane.java2d$run$fn__3719 0x38cf3ae1 "crossOriginIsolated and I've added this to my config:
:dev-http
{8280 {:root "resources/public"
:push-state/headers {"content-type" "text/html; charset=utf-8"
"Cross-Origin-Opener-Policy" "same-origin"
"Cross-Origin-Embedder-Policy" "require-corp"}}}
But js/crossOriginIsolated is still false. Is the only way to get this working by setting up https or am I missing something? I think I had it working in figwheel and I don't recall setting up any https certs.import that should be tree-shakable but its a lot of workALL is just a variable name and means nothingimport and not requirebuffer in browser:js-provider :externalbuffer in browser, without :js-provider :external, it works with buffer in dependencies.
But when I switch to :js-provider :external, Buffer is not defined.:external means shadow-cljs doesn't process ANY npm packages. whatever you use to process the :external-index (eg. webpack) will do that insteadsrc/deps.cljs file as {:npm-deps {"@fluree/sjcl" "1.0.8-3"}}.running: npm install --save --save-exact @fluree/, and installs the dependency as I expect. I can see the dependency in my node modules.Use of undeclared Var warning.Warning :undeclared-var in fluree/crypto/scrypt.cljc at 40:29 Use of undeclared Var fluree.crypto.scrypt/sjcl 37 | (encrypt raw salt n r p 32)) 38 | ([raw salt n r p dk-len] 39 | #?(:clj (SCrypt/scrypt raw salt n r p dk-len) 40 | :cljs (let [rawBits (sjcl.codec.bytes.toBits raw) 41 | saltBits (sjcl.codec.bytes.toBits salt) 42 | length (* 8 dk-len) 43 | res (sjcl.crypt.scrypt. rawBits saltBits n r p length)] 44 | (sjcl.codec.bytes.fromBits res)))))
["@fluree/sjcl" :as sjcl]:as sets up a namespace alias so sjcl.codec.bytes.toBits should be sjcl/codec.bytes.toBitsUse of undeclared Var is not related to npm in any way and those would not generate this errorfs module. When I build my browser package I get a The required JS dependency "fs" is not available error.
There's a helpful note:
"fs is part of the node-libs-browser polyfill package to provide node-native package support for none-node builds. You should install shadow-cljs in your project to provide that dependency."
Which I have done but I still see the error. Is there another way to fix this error? I'd rather just only try to require the fs module in the node build.:js-options {:resolve {"fs" false}} in the build config. if the lib however actually tries to use anything from fs that will cause an erroraccess-control-allow-origin CORS header
The reason I want to configure the client request is that I'm hoping to send a custom header from the client that can be used by the Cloud CDN as part of the cache key. By default, Cloud CDN ignores the origin request header (because theoretically there can be an unbounded number of origins, in which case the cache is very inefficient). As a result, Cloud CDN is caching headers/responses from one subdomain and sending it back to another requesting subdomain, causing CORS issues (since the access-control-allow-origin header doesn't match the requesting origin)
One fix is to set access-control-allow-origin: * on the server side, but I also wanted to explore passing a custom header up that cloud CDN can use as part of the cache keyIf-Modified-Since header is a common mechanism. The server checks if the resource has been modified since that datetime -- if so, returns 200 with the response; if not, returns a 304
> there is also no way to set any headers using the default loader mechanism. you can of course just build your own
Got it, thank youif-modified-since and stuff is already handled by the browser and you don't set anything for those yourself.shadow-cljs watch process on a browser build. I load the app in the browser and connect to the nREPL via CIDER.
Occasionally when I try to eval code in my source code buffer or REPL buffer, I get an error that "No JS runtime is available". I then reload the browser, thinking that might make the runtime available again; if that doesn't work, I disconnect from the nREPL server, then reconnect. Recently this hasn't been working for me
So today I navigated to Shadow's http server at localhost:9630 to see if it knew about the browser runtime. According to the dashboard, it did not (1st screenshot). I then restarted the shadow-cljs watch process, loaded the app up again in the browser, and verified that the browser runtime was available (2nd screenshot)
Do you know what might cause the shadow-cljs process to not recognize the browser runtime? Are there any additional debugging steps I should take?node_modules when bundling? assuming you use any npm packages?release build with something like https://github.com/vercel/ncc to bundle all npm dependencies:builds
{:lambda {:target :node-library
:exports {:handler com.pds.external-api.core/handler}
:output-to "target/lambda.mjs"
:compiler-options {:output-feature-set :es2020}}}:output-to "target/lambda.mjs" meaning its expected to be a ES module?:node-library outputs commonjs so that won't work:target :esm https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm:output-to "target/lambda.js" and just run without modules?npm ls -a --json | jq --arg v 'shadow-cljs' '[ .dependencies | .[$v] | .dependencies | .. | .dependencies? | objects | to_entries[] | .key ] | sort | unique' and changing the value of --arg v> sign?
lein clean && shadow-cljs watch app shadow-cljs - config: /media/ssd//my-project/shadow-cljs.edn shadow-cljs - connected to server >
/media/ssd//my-project/shadow-cljs.ednpackage.json for specific build(s)?package.json.
There is a * option, which tells Code to just activate after any possible activation event, which roughly translates to ASAP. An extension only needed in limited cases should avoid using *, because that slows startup for no reason. However while developing in cljs, it would usually be the best option, to ensure the js repl is available straight away, without awkward steps between building and repl-ing.
So it would be great to be able to declare * activation event only for a particular dev build, while still using the rest of package.json as written, and still allow writing more specific activation events that would apply otherwise.watch. so maybe npm run dev or whatever and the proper "scripts"Error: Unable to resolve module ./app/goog.math.long from /Users/mccraig/dev/employeerepublic/repos/yapster/yapster-app/app/.:
interestingly, i note that we had to use:
"entryPoint": "./index.js" in our expo app.json, instead of the "entryPoint": "./app/index.js" suggested by the shadow-cljs user guide and i'm wondering if these things are connected
has anyone seen anything similar ?/Users/mccraig/dev/employeerepublic/repos/yapster/yapster-app/app/app/goog/match.long.js? seems to have a duplicated app?app in app/goog.math.long is coming from actually... and we have a yarn workspace setup which might be messing things up too... the error messages from expo/metro are often not very informative, so i'm going to strip things back to a basic setup which works and move forward from thereapp/goog.math.long in your project should tell you where its coming frombrowser vs. node code? This is related to having host-specific impls for SSR https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3
For browser, I'll have something like
:modules {:browser {:entries [components.host-specific.browser]
:init-fn components.host-specific.browser/init
:depends-on #{:shared}}
Is it possible to get something up like this for the node-library target? I want to have the Node side call a similar node-specific init fn:node-library you can do it via :exports-var I guess(def my-exports (do (whatever-init-you-want) #js {:foo "bar"}) and :exports-var that.ns/my-exportsexports-var set to export an object of Firebase cloud functions. Is there a nice way to merge exports? Are :exports-var , :exports-fn and :exports mutually exclusive, or can they be used together?:exports-var since that can do everything you could possibly need?.cljc files and browser/node reader conditionals I originally went with:node-library build and I'm getting a No available JS runtime. error. The troubleshooting docs have a section on the :node-script and :node-library targets, but I'm not sure what it means to "run" a library in a node process.node-repl and use that. that has a manged node process started for you. otherwise it just means that you run whatever code that would have included your library code:shadow.build/mode in the macro &env(:shadow.build/mode &env) is nil when shadow is watching a build and hot reloading a namespace, is that expected?(:shadow.build/mode &env) inside macros, even when doing a release build. it's almost like there is some kind of compliation pass that happens which causes macroexpansion before the build environment is set. I also noticed that there are some macroexpansions that happen before the :configure stage of hooks are called.:configure. well unless those macros are in .cljc and you do anything in CLJ?(def foo (my-macro)). in those cases, could my-macro be being called with nil build-mode and before the :configure stage?:configure so no:compiler-options {:static-fns false} in your build configshadow.module.app.append.js:4 An error occurred when calling (<my-stuff>/init)
An error occurred when loading shadow.module.app.append.js
router.cljc:204 Uncaught ReferenceError: regeneratorRuntime is not defined
...
at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198:44)
at eval (router.cljc:146:64)
I saw there was some discussion in the channel before ( https://clojurians.slack.com/archives/C6N245JGG/p1644314413332399?thread_ts=1644313184.796159&cid=C6N245JGG ) and the recommendation was to install regenerator-runtime, but the problem seems to be coming from re-frame, it worked before, so I wanted to ask more about what's going on therenode.js as part of the ns form?(def json (js/require "./that.json")) works toojs/require looks for the file?(fs/readFileSync "./that.json"), just need to also (js/JSON.parse ...) it:node-script build?:output-to filefs/readFileSync would be relative to where the node process was startedfs/readFileSync is appropriate for merequire('node:path'); so I tried (:require ["node:path" :as path]) following along from https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html. That doesn't work. Neither does (:require [path :as path]):target do you use? just (:require ["path" :as path]) should be fine (this might be dependent on which node version you use though)(:require ["node:path" :as path]) should be fine too, but this is all dependent on which :target you use:target :node-library with node 18.7.0, and shadow-cljs 2.19.9. Thanks so very much for taking the time to make great software and answer questions. Will have a look at patreon shortly.Syntax error macroexpanding clojure.core/ns at (src/main/com/pds/external_api/storage.cljs:1:1). ((:require [fs :as fs] ["node:path" :as path] [cljs-bean.core :refer [->clj ->js]] [promesa.core :as p] [com.pds.external-api.config :as config])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form Syntax error compiling at (src/main/com/pds/external_api/storage.cljs:9:4).etc...
"node:path" :as path]Syntax error macroexpanding clojure.core/ns this is an error from the clojure REPLshadow-cljs node-repl (or whatever the equiv is for your editor)node target.js in addition to a watcher to provide a cljs repl that one can access with (shadow/repl :target) So I think of the node process as the repl provider.:node-library you need to manually start it again. that is correct.(shadow/repl :target) again normally. the shadow-cljs watch will automatically pick the new runtime when it is startedconst editor = Jodit.make('#editor', {
buttons: [
...Jodit.defaultOptions.buttons,
{
name: 'insertDate',
tooltip: 'Insert current Date',
exec: (editor) => {
editor.s.insertHTML(new Date().toDateString());
}
}
]
});
Main question is the …Jodit.defaultOptions.buttons part.{:buttons (into Jodit.defaultOptions.buttons {:name "my-custom-button" ,,,})} could work as well.{:buttons (into (vec Jodit.defaultOptions.buttons) [my custom buttons])}:extraButtonstag was the key.. I found in the Stackoverflow..
vec on it firstStdin: prompt in the Emacs minibuffer instead of using the in-buffer one.
Versions
shadow-cljs - 2.11.23
cider - 1.5.0
I have used the same setup in the past and didn’t have this issue. Does anyone have any idea what’s going on? Couldn’t find anything around and I’m not sure if it’s cider or shadow related:http-server and :http-port config under :build {:my-build {:devtools { .... I can't find this mentioned in the user guide. Are these deprecated, or does this have some other functionality that the :dev-http config does not give me?
• The user guide says that :dev-http is not needed for code hot reloading, but will configure hot-reload of CSS automatically. If I understand things correctly. So if I want to use my own web server, I can skip configuring a :dev-http and have code hot reload, but if I want to have CSS hot reload I should configure :watch-dir. Am I understanding this correctly?:dev-http replaces the config in :devtools, and not using :dev-http requires setting :watch-dir for CSS reloads:modules {:entries [...]. Here I have trouble formulating a question, actually. 😃 The guide says that it is:
> The namespaces that serve as the root nodes of the dependency graph for the output code of this module.
I don't quite understand what this means. Can it be elaborated on a bit? When does this get important? I'm looking at a sample project I once created and it doesn't have any :entries configured. Only :init-fn.:init-fn foo.bar/init desugars to :entries [foo.bar] plus calling (foo.bar/init) when the module is loaded:entries just gives you extra ways to add code to a module. you don't need to set it if you don't need extra namespaces:init-fn. usually there is no need for :entries without code-splittingCould not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.shadow-cljs watch frontend generates a js file with 41 warnings.
:web-worker true work in modules defined in :target :esm?(def exports #js {:all all :my my :fns fns}), which works, but I'd like to just export the whole ns.:profiles
{:cljs
{:source-paths ["src/cljs"]
:dependencies [[thheller/shadow-cljs "2.19.9"]
[reagent "0.9.1"]]}}
and got the same error trying to jack in
Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1). Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath. Socket closed Socket closed Socket closed Socket closeddo i need to make changes in the shadow-cljs.edn file?
:cljs alias when you jack-in?; Jacking in... ; Starting Jack-in Terminal: lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +cljs repl :headless ; nREPL Connection was closed ; Hooking up nREPL sessions... ; Connected session: clj ; TIPS: ; - You can edit the contents here. Use it as a REPL if you like. ; - `alt+enter` evaluates the current top level form. ; - `ctrl+enter` evaluates the current form. ; - `alt+up` and `alt+down` traverse up and down the REPL command history ; when the cursor is after the last contents at the prompt ; - Clojure lines in stack traces are peekable and clickable. clj꞉vgs.core꞉> ; Creating cljs repl session... ; Connecting cljs repl: Leiningen + shadow-cljs... ; The Calva Connection Log might have more connection progress information. ; Failed starting cljs repl for build: :frontend. Is the build running and connected? See the Output channel "Calva Connection Log" for any hints on what went wrong. ; Jack-in done. clj꞉vgs.core꞉>
Calva Connection Log? any more info on what it tried to do?Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1). Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath. Socket closed Socket closed Socket closed Socket closed Socket closed Socket closed Socket closed
js->clj doesn't actually convert anything and I'm unsure why.
This is post advanced compilation if that makes any difference? Not super confident if this is due to shadow specifically, I'll try and make a minimal reproducible case later.
Hmm, it's an :type #object[Array], but it's failing (array? x)
Ok, no idea why, but these predicates fails:
(identical? (type x) js/Object) (identical? (type x) js/Array)whereas these succeed:
(= (str (type x)) (str js/Object)) (= (str (type x)) (str js/Array))No idea what's causing it...
js->clj and :advanced. mostly related to very short property names clashing with protocols, this can be solved by externs.js->clj on a js object and then just doing a console log into chrome.js->clj and printed them as a sanity check to see which branch it goes down...
The answer is none of them, which is why it doesn't convert...
(println :satisfies? (satisfies? IEncodeClojure x))
(println :seq? (seq? x))
(println :map-entry? (map-entry? x))
(println :coll? (coll? x))
(println :array? (array? x))
(println :object (object? x))
(println :identical? (identical? (type x) js/Object))
(println :type (type x))
(println :type js/Object (identical? (type x) js/Object) (= (str (type x)) (str js/Object)) js/Array (identical? (type x) js/Array) (= (str (type x)) (str js/Array)))shadow-cljs release app --pseudo-names?[
{
"limit": 30,
"label": "Export ...",
"fn_name": "get_...",
"search_query": "...",
"task-id": "...",
"container_id": "214319799975"
},
{
"limit": 20,
"label": "Run ...",
"fn_name": "run_...",
"search_query": "...",
"task-id": "...",
"container_id": "799975628099"
}
]true is on the string check ones, ie: (println :type js/Object (identical? (type x) js/Object) (= (str (type x)) (str js/Object)) js/Array (identical? (type x) js/Array) (= (str (type x)) (str js/Array))):
:satisfies? false :seq? false :map-entry? false :coll? false :array? false :object false :identical? false :type #object[Array] :type #object[Object] false false #object[Array] false true :satisfies? false :seq? false :map-entry? false :coll? false :array? false :object false :identical? false :type #object[Object] :type #object[Object] false true #object[Array] false false
js->clj which uses string checks, though I can probably also use your to-clj, but it would be good to figure out how to fix itpostMessage to send the message between the contextsJSON.stringify and JSON.parse the object 😉:lein {:profile "+cljs"} in your shadow-cljs.edn. (Or simplify things for yourself and skip the :cljs alias, like @thheller mentioned. If you do that, then use :lein true, in the shadow config.):source-paths from shadow-cljs.edn weren't in project.clj. they no longer apply from shadow-cljs.edn when using lein.clojure is hella difficult(require 'shadow.cljs.devtools.server) and (shadow.cljs.devtools.server/start!)shadow.cljs.devtools.api namespace(shadow.cljs.devtools.api/watch :the-buid) and (shadow.cljs.devtools.api/repl :the-build) to get the REPLclojure command thats just the usual clojure -A:whatever:aliases, nothing special in startup required there.calva issued was
lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +cljs repl :headless
shadow.cljs.devtools.server.nrepl/middleware added to the middleware injection, or hardcoded manually in the project.cljshadow.cljs.devtools.server steps and the middleware injection. I'll experiment a bit with it and see if I get it working and can fix Calva's support for this.shadow-cljs separately and talk to that to handle CLJS thingsstartCode, but the shadow-cljs one hasn't.clojure command thats just the usual clojure -A:whatever:aliases, nothing special in startup required there.
Again, this is very tricky to get to actually work for Calva users. So there is something I need to fix, somewhere. Maybe it is the shadow.cljs.devtools.server stuff that's missing.:missing-nrepl-middleware when selecting the build. I am injecting it, though. Starting the project like so:
lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headlessThis is what I try with:
clj꞉shadow-lein.server꞉> (do (require (quote shadow.cljs.devtools.server)) (shadow.cljs.devtools.server/start!) (require (quote shadow.cljs.devtools.api)) (shadow.cljs.devtools.api/watch :app)) shadow-cljs - server version: 2.19.9 running at shadow-cljs - nREPL server started on port 54224 :watching ; shadow-cljs - HTTP server available at ; [:app] Configuring build. ; [:app] Compiling ... ; [:app] Build completed. (170 files, 0 compiled, 0 warnings, 1.24s) clj꞉shadow-lein.server꞉> (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/nrepl-select :app)) :missing-nrepl-middleware
:nrepl false in shadow-cljs.ednlein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headlessRemoving Calva from the picture, here's a lein-only repro:
% lein repl :connect
Connecting to nREPL at 127.0.0.1:51722
REPL-y 0.5.1, nREPL 1.0.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 18.0.1+10
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
shadow-lein.server=> (do (require (quote shadow.cljs.devtools.server)) (shadow.cljs.devtools.server/start!) (require (quote shadow.cljs.devtools.api)) (shadow.cljs.devtools.api/watch :app))
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.19.9 running at
shadow-cljs - nREPL server started on port 51913
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (170 files, 169 compiled, 0 warnings, 7.05s)
:watching
shadow-lein.server=> (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/nrepl-select :app))
:missing-nrepl-middleware
shadow-lein.server=>
I'm pretty sure I've done something wrong in some config...{:lein true
:dev-http {8700 "public"}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:init-fn shadow-lein.core/init}}}}}<script>shadow_lein.core.init();</script>^:dev/after-load metadata hintreleaseclojure to start the project, it works:
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]"
I've updated the sample project repo with a deps.edn file.% lein --version Leiningen 2.9.8 on Java 18.0.1 OpenJDK 64-Bit Server V
:missing-middleware` result with Leiningen 2.9.10.project.clj it starts working.
:repl-options {:nrepl-middleware [shadow.cljs.devtools.server.nrepl/middleware]}
Seems command-line injection takes a backseat...lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headlessd$ lein --version Leiningen 2.9.4 on Java 17.0.3 OpenJDK 64-Bit Server VM
~/.lein/profiles.clj or so?~/.lein/profiles.clj:missing-middleware result using lein 2.9.4 and 2.9.1. And also the same on another machine I have.lein repl :connect in the wrong dir :PDevTools failed to load source map: Could not load content for : Load canceled due to load timeoutAfaikt the source maps are created in the place the warning is talking about. Anyone recognize this situation?
:dev-http?main.js produced by shadow and went into a spin.shadow-cljs.edn:
{:source-paths ["src/main" "resources"]
:dependencies [[com.fulcrologic/fulcro "3.5.24"]
[com.fulcrologic/fulcro-rad "1.2.7"]
[com.wsscode/pathom "2.4.0"]
[datalevin "0.6.16"] ; <---
[mount "0.1.16"]
[ring/ring-core "1.9.5"]
[ring/ring-jetty-adapter "1.9.5"]]
:jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"] ; <---
:dev-http {8000 "resources/public"}
:builds {:app {:target :browser
:output-dir "resources/public/assets/app/js/compiled"
:asset-path "/assets/app/js/compiled"
:modules {:main {:init-fn com.kyleerhabor.hue.client/init
:entries [com.kyleerhabor.hue.client]}}
:devtools {:after-load com.kyleerhabor.hue.client/refresh
:preloads [com.fulcrologic.fulcro.inspect.preload
com.fulcrologic.fulcro.inspect.dom-picker-preload]}}}}
The file (`src/main/com/kyleerhabor/hue/db.clj`):
(ns com.kyleerhabor.hue.db (:require [datalevin.core :as d]))The error:
; Evaluating file: db.clj ; Syntax error compiling at (taoensso/nippy/crypto.clj:14:79). ; No such var: enc/secure-rng ; Evaluation of file db.clj failed: class clojure.lang.Compiler$CompilerExceptionI’m able to compile my
server.clj file just fine, which makes this confusing.:jvm-opts only for configuring shadow and not other parts of an app? I’ve been able to run a Ring server in the project just fine.{:shadow.build/stage :compile-finish} stage, which shadow-cljs displays in the browser(rf/reg-event ::m/tap-clear! (fn [...] ...))defn and not an anonymous function(rf/reg-event ::m/tap-clear! that.ns/var) (none of this actually uses re-frame, but it is very similar in concept):preloads [shadow.remote.runtime.cljs.browser]
from :devtools which I believe was given as a workaround for some other issue at some point in the distant past.npx shadow-cljs ? Does the NodeJS API do a lot of magic (middleware, etc.) in addition to calling (server/start!)?npx shadow-cljs server?server you just have (server/start!). thats all as far as the shadow-cljs build server is concernedshadow-cljs command cannot really be replicatedfigwheel-main to shadow-cljs and unfortunately I can’t change the structure of the project.
I have a backend module that serves my static files via /static route, and I have a frontend module that compiles js to the backend resource directory backend/resources/public/frontend2/assets/js. I don’t have a file index.html - the server generates it itself.
JS files are reloaded correctly, but I have some problems with reloading resources (CSS). Any changes to CSS files are not handled.
I have a webpack configuration that compiles less files to the backend resources directory /backend/resources/public/frontend2/assets/bundle.css
I added the parameters :watch-dir and :watch-path, but it didn’t help.
[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
:app {:target :browser
:output-dir "../backend/resources/public/frontend2/assets/js"
:asset-path "static/frontend2/assets/js"
:modules {:app {:init-fn frontend.core/-main}}
:devtools {:preloads [devtools.preload]
:watch-dir "../backend/resources/public/frontend2/assets"
:watch-path "static/frontend2"}
Thank you!:watch-dir "../backend/resources/public" but can't say exactly without known the paths[:link {:rel "stylesheet", :href "/static/frontend2/assets/bundle.css", :type "text/css"}]?[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
:watch-dir "../backend/resources/public/frontend2" and :watch-path "static/frontend2":watch-dir "../backend/resources/public" and :watch-path "static".shadow-cljs when a https://github.com/babashka/sci/blob/133a7565749ac6cd5a8308182f0b1c7fc47e8a3d/src/sci/impl/namespaces.cljc#L53-L64 depending on the contents of an env var? Maybe a way to whitelist env vars that shadow can take into account for caching?(get-in @cljs.env/*compiler* [:options :external-config :whatever-you-added]) during compilation:js-options :resolve be used only to re-route requires from cljs code or the config will also affect JS require/import declared in required NPM modules?
My use case is the following: NPM package X depends on Y, but I have replaced Y with a local custom build. This works fine as long as NPM stuff is built by Webpack that also has resolve config. Now that I want to require X directly in CLJS namespace and let Shadow bundle it, I also want to make sure that given resolve config in shadow-cljs.edn Shadow will take care of resolving local Y for NPM package X.:app
{:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:compiler-options {:optimizations :advanced}
:dev {:compiler-options {:optimizations :advanced}}
:modules {:app {:init-fn flow-ui.dev/init}}
:release
{:compiler-options
{:source-map true
:source-map-detail-level :all}}
:build-options
{:ns-aliases
{day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}}}
config?Module not provided: @babel/runtime/helpers/interopRequireDefault often. Tricky that it doesn't list which npm package / file is to blame. I think it has to do with using either @babel/runtime @babel/preset-react @babel/preset-env to pre-compile. Is it perhaps because I didn't configure .babelrc properly? I do have a babel.config.json that I think shadow-cljs uses.[2022-09-05 17:14:53.607 - WARNING] :shadow.build.babel/babel-transform-ex - {:code "/* eslint-env browser */\nexport const performance = typeof window === 'undefined' ? null : (typeof window.performance !== 'undefined' && window.performance) || null\n\nconst isoCrypto = typeof crypto === 'undefined' ? null : crypto\n\n/**\n * @type {function(number):ArrayBuffer}\n */\nexport const cryptoRandomBuffer = isoCrypto !== null\n ? len => {\n // browser\n const buf = new ArrayBuffer(len)\n const arr = new Uint8Array(buf)\n isoCrypto.getRandomValues(arr)\n return buf\n }\n : len => {\n // polyfill\n const buf = new ArrayBuffer(len)\n const arr = new Uint8Array(buf)\n for (let i = 0; i < len; i++) {\n arr[i] = Math.ceil((Math.random() * 0xFFFFFFFF) >>> 0)\n }\n return buf\n }\n", :file "/Users/baruchberger/nexus-core/node_modules/isomorphic.js/browser.mjs", :preset-config {:targets {"chrome" "90"}}, :shadow.build.babel/reply-to #object[clojure.core.async.impl.channels.ManyToManyChannel 0x2d46eb58 "@material-ui v4isomorphic.js thing is a dependency of y-webrtc which is you'd use with yjs a pretty cool lookin' crdt lib.} at the end?shadow-cljs will go there, there is some mention of manually passing things through babel, and that has worked out for me in the past. So just a .babelrc is supported, and I should get rid of the babel.config.json in my root?babel-transform-ex.babel.config.json seemed to be the problem, code now runs. Thank you very much!ES6 transpilation of 'Public class fields' is not yet implemented. from the closure compiler and was trying to get shadow’s babel config to use include @babel/plugin-proposal-class-properties, but it doesn’t seem to. Is this a bad idea?Resource: flow_ui/views/graph-tree-v2.js:809:19 Parse error. invalid param name "optContextPatch.changedNodeId"
shadow-cljs release app or shadow-cljs watch app or shadow-cljs compile app:infer-externs :all then you should not be doing that:infer-externs :all
retrying on :autoshadow-cljs release app --pseudo-namesgraph-tree-v2.js file does any interop with d3 then that is likely the source of your externs issuesshadow-cljs release app --pseudo-names produces good source mappinggoog.DEBUG which is true for dev buildstouch package.json["npm-lib" :as alias] :require form? AFAIK it's specific to shadow-cljs? I've been up and down the docs and there's only a sideways reference to it.["react-flow-renderer" :as rfr :default ReactFlow]from another answer elsewhere and it looks like the :default part is related to the
$default suffix in some examples in the users guide.:default was shadow specific. ClojureScript proper added “$default”:default was shadow-cljs only yes, the $default is the official way. and the string require syntax otherwise is exactly the same as in CLJS, not shadow-cljs specific in any way. never was, except for the :default addition."@mui/core" etc$default stuff was added to CLJS to not confuse users:autorun equivalent for :node-script?
I want that in development, executing shadow-cljs watch :some-build will automatically execute the resulting node script for the REPL runtime:autorun...:node-scriptstdin/stderr in the app:node-script for the REPL at allshadow-cljs node-repl instead. that just gives you the REPL without any build config or so:node-script builds your entire project and produces a "executable" which you can then run via nodenode-repl just gives you a REPL, in which you can (require 'your.code) and run it, with no executable or other "output" apart from the REPL:node-script you might be doing something that takes command line arguments, executes and exits:node-script in addition to the node-replLeaderLine. The source for leader-line.min.js looks like this:
var LeaderLine=function(){...}();
But how do I use it in my ClojureScript code? (:require ["leader-line" :as leader-line]) gives me a JavaScript object, but it is no function and it has no .-LeaderLine property.{}
[[Prototype]]: Object
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
__proto__: (...)
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
When I include the library via <script src="..."> I can call (js/LeaderLine e1 e2). But js/LeaderLine does not exist when I just (:require ["leader-line"])(:require ["leader-line" :as leader-line]) and (leader-line.), ie. constructing a new instance?Uncaught TypeError: module$node_modules$leader_line$leader_line_min is not a constructormodule.exports = LeaderLine; as the last line in its sources to make it an actual npm package with an export[:app] Configuring build. [:app] Compiling ... [:app] Build failure: IllegalArgumentException: No matching method setOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) shadow.build.closure/set-options (closure.clj:166) shadow.build.closure/set-options (closure.clj:122) shadow.build.closure/convert-goog* (closure.clj:2290) shadow.build.closure/convert-goog* (closure.clj:2255) shadow.build.closure/convert-goog (closure.clj:2434) shadow.build.closure/convert-goog (closure.clj:2384) shadow.build.compiler/maybe-closure-convert (compiler.clj:1233) shadow.build.compiler/maybe-closure-convert (compiler.clj:1226) shadow.build.compiler/compile-all (compiler.clj:1468) shadow.build.compiler/compile-all (compiler.clj:1345) shadow.build.api/compile-sources (api.clj:261) shadow.build.api/compile-sources (api.clj:253) shadow.build/compile (build.clj:512) shadow.build/compile (build.clj:493) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349) shadow.cljs.devtools.server.worker.impl/eval28465/fn--28467 (impl.clj:448) clojure.lang.MultiFn.invoke (MultiFn.java:234) shadow.cljs.devtools.server.util/server-thread/fn--28223/fn--28224/fn--28232 (util.clj:283) shadow.cljs.devtools.server.util/server-thread/fn--28223/fn--28224 (util.clj:282) shadow.cljs.devtools.server.util/server-thread/fn--28223 (util.clj:255) java.lang.Thread.run (Thread.java:833)Has anyone seen this before? I could not find anything neither in the web nor here….
[com.google.javascript/closure-compiler-unshaded "v20220905"]
Reverting to
[com.google.javascript/closure-compiler-unshaded "v20220502"]
solved the issue.[com.google.javascript/closure-compiler-unshaded "v20220803"] for 2.20.1shadow-cljs release build1 build2 is much faster than shadow-cljs release build1 && shadow-cljs release build2 since only one shadow-cljs instance is startedshadow-cljs support subpath imports in the context of :esm target? Or am I doing something wrong? https://github.com/dmg46664/problems/tree/main/02_shadow-subpath-imports:js-options {:js-provider :import} in the build config as described here https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration:local-ip option, looks like option from command shadow-cljs watch android --verbose --config-merge '{:local-ip "127.0.0.1"}' isn't picked up but adding it to ~/.shadow-cljs/config.edn does work.
Docs mention that --verbose output should display the used IP(s) but I'm not seeing those messages (https://github.com/thheller/shadow-cljs/blob/846446eb49e51daf9c25b6016603afe38b6d4768/src/main/shadow/cljs/devtools/api.clj#L604 https://github.com/thheller/shadow-cljs/blob/846446eb49e51daf9c25b6016603afe38b6d4768/src/main/shadow/cljs/devtools/api.clj#L604)::multiple-ips log call is inside comment form now.::server-addr log calls::server-addr log call was removed hereadb reverse to tunnel traffic, in that case the phone needs to access localhost which isn't included in the list.:local-ip per build back in (since config-merge only applies to the build config)--config-merge example: https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native"preact/hooks" in a cljs app, but every time I try to use one of the hooks, I get an error like this:
Cannot read properties of undefined (reading '__H')
it happens in the repl and when running the app.
the require looks roughly like this in the app: (:require ["preact/hooks" :refer [useState]])
anyone happen to know why I might be getting that error and/or what I'm missing?:target like this:
{:target :node-test
:output-to "tests.js"
:ns-regexp "sitefox.*$"
:autorun true}
And an npm script that looks like this for running it:
shadow-cljs compile test && node tests.jsI'd like to be able to do this on each push/PR on Linux and Mac.
(:shadow.build/mode &env) in the macro. :release for release builds, otherwise :devlein install this lib, and use it in a different project. The latter project only started to work properly after I supplied borderBoxSize, inlineSize, blockSize to its externs/app.txtexports symbol. It seems that when using the :export metadata on a function shadow emits a goog.exportSymbol call, but this one is not picked up by VS-Code. I think it "exports" to goog.global, which is this || self, but not exports.
I can set the JavaScript properties to js/exports manually and it seems to work, but this seems like a hack?:esm target but this threw errors that export was not defined
https://code.visualstudio.com/api/extension-guides/web-extensionsjs/exports is a hack and should not be done:node-library targetrelease mightrequire for "vscode", but not for others. I am using this in my build config:
:js-options {:js-provider :shadow
:keep-native-requires true
:keep-as-require #{"vscode"}}
This seems to work; however, for some reason my compile output now also wants to require("path") which does not exist, when I (:require ["vscode-languageclient/browser" :as browser]). The browser lib is specifically for this purpose and should not use "path"...:node-library but get errors about global being undefined. I figured this is just for node, not for browsers:node-library in both Calva and Joyride. Maybe that closes the door for enabling them for the Web version of VS Code...:npm-modules and process them with webpack. I hope I never have to step through the resulting JavaScript by hand 😄:target :npm-module and using their webpack example configcljs_env.js reads:
var $CLJS = {};
var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;
Looks like this, too, is targeting node?:target that just emits exactly what the web extensions expectsprocess (among others), and then it worked. Even though I am probably pulling in a process implementation just for the process.browser flag 😄:npm-module adds it so it works in node and the browser!process || process.browser?process is undefinedtypeof(process) === undefined?:runtime :browser in the build config?globalThisprocess.browser bit anymore in the output files. Will keep an eye on itConnection Type = Socket REPL
Just leaving this here in case someone comes across long overflow trying to start a cljs repl via Cursive.:warnings-as-errors
search for it in the user guide there is a link to the list of possible values:ignore-warnings true instead in the :devtools section so that's probably this one:compiler-options {:fn-deprecated false} to get rid of them:devtools {:ignore-warnings true} to ignore them for hot-reload purposes:compiler-options {:warnings {:fn-deprecated false}}/app/might work?:WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced. remote: You should remove this library from non-dev builds completely because it impedes dead code elimination. remote: The best way is to use :preloads compiler option: . remote: To silence this warning please set :silence-optimizations-warning config key to true. remote: More details: .My shadow-cljs config is:
{:nrepl {:port 7772}
:builds {:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}}
:dev {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries []}}
:devtools {:preloads [day8.re-frame-10x.preload]
:watch-dir "resources/public"}
:dev {:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}
:test {:target :node-test, :output-to "target/test/test.js"
:autorun true}}
:lein true}
I thought taking the dev tools out of the ‘app’ build (used for deployment) would resolve the issue - any help appreciated#!/usr/bin/env bash npx shadow-cljs release app lein uberjar
devtools.*?devtools.core or devtools.preload or something:dev build is not idiomatic. you can configure dev/release specific things in the main config. see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration:compile-prepare hook
(:compiled (:shadow.build/build-info build-state)is empty (obviously), is there an equivalent way to get the updated files in prepare stage? The goal is to
reset! state used by a macro in order to communicate to the macro which namespaces need to be re-instrumented, which needs to be updated before compilationshadow-cljs - connected to server [:app] Compiling ... Closure compilation failed with 1 errors --- externs.shadow.js:8 Parse error. 'identifier' expectedI went through suggested solutions here https://clojurians.slack.com/archives/C6N245JGG/p1612542030435100 and added the following variations of build-hooks as suggested in that thread, but didn't turn up a comparable solution. I'm wondering if there's another strategy to take to find whats causing this. I also went through and removed any unicode symbols and non-english characters in case that was the issue, but still have 1 error somewhere.
;; ;; This didn't find any empty ""
(defn find-it
{:shadow.build/stage :optimize-prepare}
[build-state]
(prn (shadow.build.closure/extern-props-from-cljs build-state))
build-state)
;; [:app] Compiling ...
;; #{"useLayoutEffect" "useRef" "useCallback" "useImperativeHandle" "$$Signature$$"
;; "getElementById" "removeEventListener" "createRoot" "createElement" "flushSync"
;; "Fragment" "PersistentVector" "useDebugValue" "$$Register$$" "DateTimeFormat"
;; "useMemo" "hasNext" "forwardRef" "createContext" "PersistentArrayMap"
;; "Suspense" "useReducer" "Component" "useEffect" "now" "useState" "useContext"
;; "addEventListener" "Element" "core" "memo" "equiv"}
;; Closure compilation failed with 1 errors --- externs.shadow.js:8 Parse error.
;; 'identifier' expected
(defn find-it
{:shadow.build/stage :optimize-prepare}
[{:keys [output] :as build-state}]
(doseq [{:keys [resource-id properties]} (vals output)
prop properties
:when (< (count prop) 2)]
(prn [:prop resource-id prop]))
build-state)
;; this one didn't log anything at all
;; beyond initial error
(defn find-it
{:shadow.build/stage :optimize-prepare}
[{:keys [output] :as build-state}]
(->> (vals output)
(filter #(contains? (:properties %) ""))
(map :resource-id)
(prn))
build-state)
;; [:app] Compiling ...
;; ()
;; Closure compilation failed with 1 errors
;; --- externs.shadow.js:8
;; Parse error. 'identifier' expected
(defn find-it
{:shadow.build/stage :optimize-prepare}
[state]
(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-properties]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-properties "")]
(prn [:found ns js-access-properties]))
state)
;; [:app] Compiling ...
;; Closure compilation failed with 1 errors
;; --- externs.shadow.js:8
;; Parse error. 'identifier' expected
"_peek-at" looks suspiciousfind-it helper but looking for that not the empty string?"Children.toArray" is also incorrect"_peek-at" was from the old thread, I don't have any of that in my output..shadow-cljs/builds/<the-id>/release/externs.shadow.jsshadow-cljs - connected to server [:app] Compiling ... Closure compilation failed with 1 errors --- externs.shadow.js:8 Parse error. 'identifier' expected
/** @const {ShadowJS} */ var Intl;
/** @const {ShadowJS} */ var Promise;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var clearInterval;
/** @const {ShadowJS} */ var clearTimeout;
/** @const {ShadowJS} */ var module;
/** @const {ShadowJS} */ var setInterval;
/** @const {ShadowJS} */ var throw;
/** @const {ShadowJS} */ var undefined;undefined coming from 😛(js/throw ...) now has it compiling without error though.(throw ...) is fine. no need for the js//** @const {ShadowJS} */ var Intl;
/** @const {ShadowJS} */ var Promise;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var clearInterval;
/** @const {ShadowJS} */ var clearTimeout;
/** @const {ShadowJS} */ var module;
/** @const {ShadowJS} */ var setInterval;
/** @const {ShadowJS} */ var undefined;find-it helper fnextern-globals-from-cljs instead of the extern-properties-from-cljs(defn find-it
{:shadow.build/stage :optimize-prepare}
[build-state]
(prn (shadow.build.closure/extern-globals-from-cljs build-state))
build-state)
[:app] Compiling ...
#{"window" "Symbol" "Promise" "Date" "document" "Intl" "clearTimeout" "React" "JSON" "clearInterval" "RegExp" "undefined" "Error" "setTimeout" "setInterval"}
[:app] Build completed. (72 files, 0 compiled, 0 warnings, 11.43s)(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-properties]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-properties "undefined")]
(prn [:found ns js-access-properties]))find-it hookundefined not the empty string(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-global]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-global "undefined")]
(prn [:found ns js-access-global]))(defn find-it
{:shadow.build/stage :optimize-prepare}
[state]
(doseq [src-id (:build-sources state)
:let [{:keys [ns file] :as src}
(get-in state [:sources src-id])
{:shadow/keys [js-access-global]}
(get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
:when (contains? js-access-global "undefined")]
(prn [:found ns js-access-global]))
state)[:app] Compiling ...
[:found helix.impl.props #{"RegExp" "undefined" "Error"}]
[:found helix.core #{"window" "Symbol" "undefined" "Error"}]
[:found helix.hooks #{"undefined" "Error"}]
[:app] Build completed. (72 files, 0 compiled, 0 warnings, 11.77s)js/undefined* filter in the generate-css function. once i adjusted that it now works as a wonder.:asset-path "/app-js"shadow-cljs release with advanced compilation and a browser target. One library that's contributing quite a bit seems to be https://www.npmjs.com/package/@aws-amplify/ui-react. When I remove the library from the codebase, ~7M is saved. I was able to slightly reduce its footprint by directly referencing the classes we're using (ex ~700Kb).
Any tips to further investigate or different directions I should go? I could permanently use webpack along with shadow if that's the recommended way to go but wanted to check if I can get it working w/ just shadow. Thanks in advance!:compile-prepare hook though. I didn't see a way to get that information in the prepare stage, is there one?(ns server.main (:require ["fs" :as fs])) and evaluate it in a node-repl, then type (fs/rea|), (pretend the cursor is at |) Should I be expecting an autocomplete in emacs with clojure-lsp and/or cider? Or is there something wrong with my setup:target :esm is still https://clojureverse.org/t/generating-es-modules-browser-deno/6116/21?js/require as a https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs#L35, so I'm at a loss for how I should handle this with ESM... any pointers would be appreciated 🙏ajax.xml_http_request.xmlhttprequest="undefined"!==typeof goog&&"undefined"!==typeof goog.global&&"undefined"!==typeof goog.global.XMLHttpRequest?goog.global.XMLHttpRequest:"undefined"!==typeof require?function(){var a=require;return(a.cljs$core$IFn$_invoke$arity$1?a.cljs$core$IFn$_invoke$arity$1("xmlhttprequest"):a.call(null,"xmlhttprequest")).XMLHttpRequest}():null;ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxImpl$=cljs.core.PROTOCOL_SENTINEL;
ajax.xml_http_request.xmlhttprequest.prototype. <<-- "Cannot read properties of null (reading 'prototype')require doesn't exist in ESM so the conditional shouldn't do anything? and yes :target :esm is an official target nowajax.xml_http_request.xmlhttprequest="undefined"
null(js/require) statements to (js/import)s?:esm https://antfu.me/posts/publish-esm-and-cjs; SHADOW import error D:\projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow.js.shim.module$node_fetch.js ; ; Execution error (Error) at (<cljs repl>:1). require() of ES Module D:\projects\census\census-geojson\node_modules\node-fetch\src\index.js from D:\projects\census\census-geojson\[stdin] not supported. Instead change the require of index.js in D:\projects\census\census-geojson\[stdin] to a dynamic import() which is available in all CommonJS modules. :repl/exception!
:esm target?:esm can import ESM code yes:esm build at allclj꞉shadow.user꞉> ; Creating cljs repl session... ; Connecting cljs repl: shadow-cljs... ; The Calva Connection Log might have more connection progress information. ; Connected session: cljs, repl: :lib ; TIPS: You can choose which REPL to use (clj or cljs): ; *Calva: Toggle REPL connection* ; (There is a button in the status bar for this) ; Evaluating file: tests.cljs ; No available JS runtime. ; See nil cljs꞉cljs.user꞉>
No available JS runtime:esm?node-repl for that. ESM just gets in the way:browser target?:esm loaded in the browser, not node:esm buildlambdaisland.fetch and the following conditional :
(when isNode (set! js/fetch node-fetch))This works in the
node-repl but when I release it (`:esm` target), I get
fetch is not definedin the bundled code, it looks like:
// looks like it's referencing the lib:
Mi(In,rn,function(a,b,c){try{return Km(Pm(b.text.call(b),function(d){var e=Rs.h(c,C(Mt)).read(d);if(null!=e?e.v&262144||D===e.Lf||(e.v?0:y(Ib,e)):y(Ib,e)){var f=qd(e);d=Hf.j?Hf.j(f,Ps,d):Hf.call(null,f,Ps,d);e=pd(e,d)}return e}))}catch(d){return Nm(d)}});Mi(In,Wl,function(a,b){return b.json.call(b)});var Nt=esm_import$node_fetch <<------- :)
// ... but further down
Gh("ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž","aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz");var Tt="undefined"!==typeof process&&"undefined"!==typeof process&&"undefined"!==typeof process.versions&&"undefined"!==typeof process&&"undefined"!==typeof process.versions&&"undefined"!==typeof process.versions.node,fq=Tt?"":"",dq=Error;Tt&&(fetch=Nt) <<------- why?
Is it because I set the global variable shim in Node wrong?shadow-cls.edn build setup:
:builds {:lib {:target :esm
:output-dir "public/census"
:modules {:census {:exports {default census.core/census}}}
:js-options {:js-provider :import}
:compiler-options {:optimizations :advanced}}clj -M:shadow-cljs pom to produce a pom (or do anything) instead i get "Unknown action" which is also what i get if i replace "pom" with "help" or "info", meanwhile "watch app" seems to work.pom is a task by the shadow-cljs cli command, which you do not use? however you can ask clj to generate a pom file for you, since it is in charge of generating the classpath? -Spom I believe?shadow-cljs command, which runs in node and doesn't execute java for thoserelease watch compile are all done by the clojure partsshadow-cljs command? it'll just call clj for you. you only lose features by going with cljshadow-cljs.edn with :cljs alias
> {:deps {:aliases [:cljs]}
> :builds ...}
> Example deps.edn
> {:paths [...]
> :deps {...}
> :aliases
> {:cljs
> {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}}}
> Running with clj directly.
> {:paths [...]
> :deps {...}
> :aliases
> {:shadow-cljs
> {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}
> :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
> clj -A:shadow-cljs watch app
a pom has nothing to do with creating a release build, i didn't mean to imply it did.
Build the following command fails:
> clj -A:shadow-cljs pomAnd reports
Unknown action
As where
> clj -A:shadow-cljs watch appCorrectly watches the app. Similarly, >
clj -A:shadow-cljs release appfails with "unknown action" just like pom, which is why i pointed out that more "actions" then the one i wanted to run were failing. The readme implies this should work. If i just use shadow-cljs i get a very different complaint about missing devtools:
shadow-cljs release app shadow-cljs - config: /home/drewverlee/Centriq/centriq-web/frontend/shadow-cljs.edn shadow-cljs - starting via "clojure" Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. Full report at: /tmp/clojure-5691110849954872601.ednMy best guess this is because shadow doesn't know about binaryage/devtools because it's a hidden behind a deps.edn aliase as an extra dep. But that guess doesn't seem great because the path is shadow/cljs/devtools/cli and nothing about binaryage. My only other thought is that my package.json has shadow as a devDependency as well, though thats what i feel i have done in all my projects and i don't recall running into this.
shadow-cljs release:deps {:aliases [:cljs]} to shadow-cljs.ednthheller/shadow-cljs dependency to your deps.edn :cljs alias (or :shadow-cljs, or whatever alias you want)shadow-cljs commandclj -M:shadow-cljs release app?package.json is not relevant in this stageclj and no longer use the shadow-cljs command:deps key to your shadow-cljs.edn. The :deps value is going to Shadow where
to look for the theller/shadow-cljs dependency in your deps.edn.
If you want to place that in your deps.edn :deps directly then set your shadow-cljs.edn :deps to true
Which looks like this:
shadow-cljs.edn
{:deps true}
deps.edn
{:deps {theller/shadow-cljs ...}}
Now when you run
bash
shadow-cljs some-shadow-actionthe command line tool will find theller/shadow-cljs in the deps.edn through the shadow-cljs.edn file. If you want to move the shadow depency under a deps.edn :aliases, then you will have to tell shadow about that aliase (or aliases) that you want to use when the shadow is invoked. You do this by changing the deps.edn
:deps value to a list of keywords that shadow will use to look up in the deps.edn and use there extra-deps from. for example
shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}} }
Here shadow finds theller/shadow-cljs through the :shadow-cljs keyword, but you can use any :keyword as long as it matches.
## Having the clj command line call through to Shadow
If for some reason you want to use the clj command line tool to call out to Shadow, you will need to tell the clj command line how to do that by updating your deps.edn to have an alias with a :main-opts and a value of exactly ["--main" "shadow.cljs.devtools.cli"]. "--main" is a function that takes the string representation of the clojure namespace that has a -main function that you want to pass arguments from the command line to. A full example might look like this:
shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}
:main-opts ["--main" "shadow.cljs.devtools.cli"]}}
bash
clj -M:shadow-cljs pomOf course, clj -M can pass through arguments to any namespace with a main function. Shadow isn't special in this regard.
clj -M:shadow-cljs pom this won't work so doesn't make for a good example in the last sectionclj tool constructs the classpath with shadow-cljs in it, when the process it started it can then be loadedclj -M:shadow-cljs pom this won't work so doesn't make for a good example in the last section
Oh you right (big surprise 🙂 ) Why does clj -M:shadow-cljs watch app work then? I guess the main function of shadow-cljs.devtools.cli doesn't take the same arguments as the command line then? as shadow-cljs pom would work right?shadow-cljs node script and never execute any java to do thatpom just generates a xml file, it doesn't need java for thatshadow.cljs.devtools.cli:esm target) like this:
import * as esm_import$node_fetch from "node-fetch";How can I get it to do
import esm_import$node_fetch from "node-fetch";
(:require ["node-fetch$default" :as node-fetch]), see translation table provided here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages/api/ path to a deployed server.
Unfortunately hot-reloading ist not working and I noticed that the websocket connection to localhost:9630 is not established.
Is there a way to enable it?localhost then you might need to set https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support:devtools {:use-document-host false}:devtools {:use-document-host false} worked :thumbsup:^:deprecated, but it only warns on new usagesimport Prism from "prism-react-renderer/prism";
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-clojure");(ns ui-cards
(:require
[com.fulcrologic.fulcro.algorithms.react-interop :as interop]
[com.fulcrologic.fulcro.dom :as dom]
[nubank.workspaces.card-types.react :as ct.react]
[nubank.workspaces.core :as ws]
[nubank.workspaces.model :as wsm]
["prism-react-renderer" :default Highlight :refer [defaultProps]]
["prism-react-renderer/themes/github" :default _ :as theme]
["prism-react-renderer/prism" :as Prism]
["prismjs/components/prism-clojure" :as Clojure]))
(set! (. (if (exists? global)
js/global
js/window)
-Prism) Prism))main.js:1426 ReferenceError: Prism is not defined
at shadow$provide.module$node_modules$prismjs$components$prism_clojure (prism-clojure.js:3:1)
at shadow.js.jsRequire (js.js:66:18)
at shadow.js.require (js.js:113:20)
at eval (ui_cards.js:5:68)
at eval (<anonymous>)
at goog.globalEval (main.js:472:11)
at env.evalLoad (main.js:1534:12)
at main.js:1889:12require call - it gives an error stating that the require must be part of the ns form:
ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form)["prismjs/components/prism-clojure" :as Clojure], building, and then uncommenting it and building again. It just doesn't survive a page refresh.
Any tip for how to get this working? Please excuse me if I'm missing this in the docs.Prism object(js/require ["xterm"] #(.Terminal %))). What's the recommended/proper way to solve this? Do I need to manually write an externs file?(js/require ["xterm"] #(.Terminal %)) this is supposed to be? ah I guess require.jsCannot infer target type in expression (. p1__240117# Terminal)[xterm :refer [Terminal]] in my (:require ...) statement gives the following error (for xterm 5.0.0, which is the latest version):
Closure compilation failed with 1 errors --- node_modules/xterm/lib/xterm.js:2 Illegal variable reference before declaration: e
xterm/lib/xterm.js, and I should be requiring something else?.Terminal call verbatim without bothering with externs, or do I need to add an externs file?^js tag(js/require ["xterm"] #(.Terminal ^js %)) should be enoughClass constructors cannot be invoked without 'new'new with this type hint/tag? (new Terminal. ^js %) gives me Use of undeclared Var my.ns/Terminal(let [ctor (.-Terminal ^js %)] (new ctor)) works 😅#() function to make this more understandable?(new Terminal. ^js %) is just invalid code and not related to ^js in any way 😛(new (.-Terminal ^js %)) also doesn't work(.- Terminal ^js %) call out into a bindingshadow-cljs info prints a basic info:output-dir entry as optional but in the latest shadow-cljs version if :output-dir is omitted it throwsInvalid configuration
-- Spec failed --------------------
{:target :npm-module, :entries [main], :build-id :app}
should contain key: :output-dir
| key | spec |
|=============+===============================================|
| :output-dir | shadow.build.targets.shared/non-empty-string? |export default in shadow ? i’d like to import Function from 'shadow-cljs/demo.foo from within JS:local/root instead.:target :esm? https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm(defn ^:export init [] (router-start!) (start))
(defn ^:dev/after-load start [] (router-start!) (d/render [current-page] (.getElementById js/document "app")))
router-start! doesshadow.lazy/loadable to lazily load some modules. If I naviagte to the page localhost:4000/utils, it will properly load localhost:4000/js/routes.utils.js. If I navigate to localhost:4000/utils/example, it is failing to load because it’s looking for the file at localhost:4000/utils/js/routes.utils.js. I have asset path configured to /js - how do I configure the equivalent for lazily loaded modules?js? it should be using the :asset-path "/js" if actually set like that(defn component [loadable]
(let [lazy (react/lazy
#(-> (lazy/load loadable)
(.then (partial to-hot-react-component loadable))))]
(fn [& props]
(react/createElement lazy #js {:props props}))))
(defn get-lazy [namespace]
`(captain.util.lazy/component (shadow.lazy/loadable ~namespace))))shadow.loader ns somewhere?:module-loader true in the config:asset-path "js", "/js" shouldn't do thisshadow$modules/utils :thinking_face:$ tree build build ├── 1664911033746 │ ├── captain.css │ └── js │ ├── captain.docs.routes.about.js │ ├── captain.docs.routes.about.me.js │ ├── captain.docs.routes.index.js │ ├── captain.docs.routes.utils.$util.js │ ├── captain.docs.routes.utils.index.js │ ├── captain.docs.routes.utils.js │ ├── captain.js │ ├── cljs-runtime │ │ ├── applied_science.js_interop.impl.js │ │ ├── applied_science.js_interop.impl.js.map │ │ ├── applied_science.js_interop.js │ │ ├── applied_science.js_interop.js.map │ │ ├── captain.app.js │ │ ├── captain.app.js.map .................................. │ │ ├── shadow.util.js │ │ └── shadow.util.js.map │ ├── manifest.edn │ ├── module-loader.edn │ ├── module-loader.json │ ├── quartermaster.js │ └── shared.js ├── index.html └── index.html.clj 3 directories, 859 files
asset-path, I would have been chasing ghosts for hours 😂
Still no idea how the browser was loading those files though? :thinking_face: but not important, it’s working!:proxy-url always tries to load from proxies for files that don't exist?:use-index-files true should work, :dev-http {3000 {:root "public" :use-index-files true :proxy-url ...}} that isClosure compilation failed with 4 errors --- node_modules/@ffmpeg/ffmpeg/src/browser/defaultOptions.js:17 This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support. --- node_modules/@ffmpeg/ffmpeg/src/browser/fetchFile.js:43 This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support. --- node_modules/@ffmpeg/ffmpeg/src/browser/getCreateFFmpegCore.js:44 This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support. --- node_modules/@ffmpeg/ffmpeg/src/browser/getCreateFFmpegCore.js:80 This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support.I tried tinkering with
:output-feature-set but it doesn't seem to help.chunk_output_type flag on the Closure pass?["@ffmpeg/ffmpeg/dist/ffmpeg.min" :refer [createFFmpeg fetchFile]]
["react-bootstrap/Card$default" :as card] in my require form and I see the modules being loaded in the console but I can't figure out how to use it correctly. When I call it like a function I get a use of undeclared var warning and nothing elseCard {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, Img: {…}, Title: {…}, render: ƒ, …}$$typeof: Symbol(react.forward_ref)Body: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Footer: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Header: {$$typeof: Symbol(react.forward_ref), render: ƒ}Img: {$$typeof: Symbol(react.forward_ref), render: ƒ}ImgOverlay: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Link: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Subtitle: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Text: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Title: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}defaultProps: {body: false}render: ({bsPrefix,className,bg,text,border, body,children,as:Component="div",...props},ref)=> {…}displayName: (...)get displayName: ƒ ()arguments: nullcaller: nulllength: 0name: "get"prototype: {constructor: ƒ}[[FunctionLocation]]: react.development.js:1497[[Prototype]]: ƒ ()[[Scopes]]: Scopes[4]set displayName: ƒ (name)[[Prototype]]: Object
so it seems to be imported correctly but I still get those undefined var warnings on invocation.create-react-class function here? I tried what the original SO thread showed, i.e.
[:div [:> Card [:> Card.Body]]]etc, but I suspect that's also wrong
["react-bootstrap/Card" :as Card](js/console.log "Card" Card)
(defn some-interop-fn [obj] (.interopCall2 (.interopCall1 obj)))If I typehint the
obj the compiler warning disappears, does the compiler not need a typehint on the result of the first call?^jsconstructor(...args){
super(...args)
}
will be generated.[this & args]and can't apply a super macro clause, something like this
(constructor [this & args] (apply super args))
apply wouldn't work here since super is not a functionconstructur(a,b,c) { super(a,b,c) }?(constructor [this arg] (super arg))works like a charm.
(binding [*out* (io/writer (System/out))]) around the prn calls because if it's run separately (with a shadow-cljs run for example) and it jacks in to an already-running server it loses its original stdout and crashes: in a css map or something) it'll try to prn to stdout but it doesn't have its own anymore resulting in a closed stream exception(require '[goog.object :as gobj]) => nil gobj => Use of undeclared Var calva.read-config/gobjPutting the require in a
:require in the ns form gives the same result. I can use goog.object this way: (js/goog.object.set o k v), but I would prefer to use :require...gobj is just a namespace binding? so you'd use gobj/get?Cannot read properties of undefined (reading 'set').(:require [goog.object :as gobj]) and (gobj/set x "thing" 1) definitely workscljs.core/clj->js, so I copied it https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L11031-L11056 and also copied how goog.obj was required. Then when trying my local version of clj->js, I got that ^ error.unchecked-get and unchecked-set from cljs.core instead. works the sameunchecked-set works great. Thanks!clj->js from core.cljs and pasted it in my file as my-clj->js.
2. Copied [goog.object :as gobject] from the ns form of core.cljs and pasted it in my ns from.
3. Evaluated (my-clj->js {:foo 1}) => BOOM Cannot read properties of undefined (reading 'set').unchecked-set so I am fine. And I'm not confused any longer. 😃 Even if it would have been better that I had done something weird rather than there being this REPL mystery.(gobj/set #js {} "x" 1)
I get a bit surprised that it evaluates to 1. Never thought about the return value of these before. I notice that also:
(set! (.-x #js {}) "y") => "y"
foo["x"] = 1; returns 1:as as a variable only works for npm JS requires, not for CLJS or closure namespacesERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...app.css> (g/css) Execution error (ReferenceError) at (<cljs repl>:1). Can't find variable: garden :repl/exception!I'm using deps.edn where I have added garden, and my ns declaration looks like this:
(ns app.css (:require [garden.core :as g] [garden.stylesheet :as gs] [re-frame.core :as rf]))I don't get any error when using re-frame, only with garden. Any ideas of what's wrong?
------ WARNING - :redef -------------------------------------------------------- Resource: <eval>:390:1 abs already refers to: cljs.core/abs being replaced by: garden.color/abs --------------------------------------------------------------------------------As for how I required things, I required it with the
ns macro, as I showed.:devtools {:ignore-warnings true} in the build configshadow-cljs watch my-buildThis will stay in the foreground, I can cancel with
ctrl+c.
I can also start a server without watchers using:
shadow-cljs start...and then start (background) watches using the UI at
.
After starting the server in the background, can I also start a watcher in the background, using the CLI?user(.clj) ns like
(defn watch-foo
{:shadow/requires-server true}
[]
(shadow.cljs.devtools.api/watch :foo))
you can then run it either from the repl or with shadow-cljs run user/watch-fooshadow-cljs start command is nice because you can stop a watch without stopping the server, meaning starting other watches is fastwatch in the background is not feasible I fear.
@UAEH11THP - this looks interesting, will have a lookwatch in the background is not feasible I fear."shadow-cljs watch my-build &
shadow-cljs start, it starts in the background.
I can then go to the UI and start a watch, without having to keep a terminal open for the watcher.
I'd like to have the same behaviour at the CLI: To start/stop a watcher without binding the watch to my terminalshadow-cljs watch my-build directly from your terminal, then adding & at the end will start it in the background.
if you're using babashka to run it, then you should be able to start the babashka process in the background.
but i don't really understand what you mean at this point, so i'll let others try and help(ns demo.jsxgraph (:require ["jsxgraph" :as jsx]))I see this:
failed to resolve: ../build/core.deps.js from /Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js
{:require-from #object[java.io.File 0x6560d23a "/Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js"], :require "../build/core.deps.js"}
ExceptionInfo: failed to resolve: ../build/core.deps.js from /Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js
which makes sense, since the NPM package doesn’t ship its build directory.
the last line of the https://raw.githubusercontent.com/jsxgraph/jsxgraph/master/distrib/jsxgraphsrc.js is
return require('../build/core.deps.js');
my question is… how can this ever work in Javascript land, since build is not available??jsxgraph and make my own build… I am thinking maybe there is some issue with the jsxgraph build where it is not properly bundling this file? Would love any clues.build folder into node_modules'/jsxgraph just to see what would happen if I made the file available["/jsxgraphcore.js" :as JSX]I get a different error (missing node-libs-browser), so I installed node-libs-browser, and then I get another error about canvas.
JXG present) but that’s the least desirable path..:foreign-libs is not supported by shadow, is that right?:node-library is UMD, which is AMD compatible as far as I remembernpm install jsxgraph gets you["complex.js" as Complex]), using the alias as a type hint (eg (defn angle [^Complex a] (.arg a))) doesn’t have the same effect as eg. ^js and breaks in advanced. Would it make sense to handle it like ^js, since (I believe) Complex would otherwise be treated as something from javascript-land?^js not Complex:as since that usually means namespace alias^Complex would work since it would have saved me the cljc fork inside the codecore.asyncclientX and whatever(defmethod g/magnitude [::complex] [a]
#?(:clj (.abs ^Complex a)
:cljs (.abs ^js a)))
so it sounds like this is what’s required, @U05224H0W, for a cljc file?.abs name so I guess it was cheating to try and share them before 🙂(:require ["some-npm" :as x]) and ^x/Complex worked but not ^x. should be fine as of 2.20.5. should be fine with clojure style annotations assuming they can all be resolved the same^js all overlazy/loadable be called at namespaces' top level, or is it fine to call it when it's used, e.g. in a Reagent component?test/nbb/main_test.cljs
3: ["module" :refer [createRequire]]
31:(reset! nbb/ctx {:require (createRequire (path/resolve "script.cljs"))})bb ci:test
(ns aerial.hanami.core
(:require
[cljs.core.async
:as async
:refer (<! >! put! chan)
:refer-macros [go go-loop]]
[clojure.string :as cljstr]
[com.rpl.specter :as sp]
[aerial.hanasu.client :as cli]
[aerial.hanasu.common :as com]
[aerial.hanami.md2hiccup :as m2h]
[aerial.hanami.common :as hc]
[aerial.hanami.templates :as ht]
;; Vega & Vega-Lite
[cljsjs.vega]
[cljsjs.vega-lite]
[cljsjs.vega-embed]
[cljsjs.vega-tooltip] .....
I was wondering is there some recommended way to have the library require the code from the npm dependency instead if it is present? So the last few requires would change to:
[vega] [vega-lite] [vega-embed] [vega-tooltip]I tried changing everything over to use cljsjs, because I presumed that cljsjs dependencies still work with shadow-cljs: https://github.com/jointprob/hanami-shadow-cljs/commit/ddf3bfe3aa99992ea8305f8a3d8100c2d89a74c0 But now get an error about react-dom being missing thought it is included as as cljsjs dependency: [:hanami] Build failure: The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs".
:lein {:profile "+cljs"} , but this applies for all the builds.--config-merge can help, but it affects only a build config.lein with-profiles +foo run -m shadow.cljs.devtools.cli watch the-build:nrepl stuff goes. This does not seem to be correct:
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:dev-http {8080 "public"}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn }}
:devtools {:repl-init-ns
:repl-pprint true
:nrepl {:port 9000
:middleware []
:init-ns }}}}}
Can anyone point out my mistake?TypeError: tick.core.goog$module$goog$object is undefined ? Shadow compiles without errors but when loading my file I see that error message and everything else after that failsnode_modules/fomantic-ui/dist/. If I want to include them in my html, what is the right way to refer to their location?"resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.node_modules/.... My public HTML files do not have access to the files in node_modules (I think..?)... sorry, I'm confused, could you elaborate please?// <projectRoot>/src/js/index.js import 'draft-js/dist/Draft.css';
(ns myproject.core (:require "/src/js/index.js"))
fomantic-ui/dist/something.cssshadow-cljs.edn looks like so
{}
Starting this with
npx shadow-cljs browser-replworks fine. But with
npx shadow-cljs node-replI get:
% npx shadow-cljs node-repl
------------------------------------------------------------------------------
WARNING: shadow-cljs not installed in project.
See
------------------------------------------------------------------------------
shadow-cljs - config: /Users/pez/.config/joyride/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[2022-10-15 13:43:16.382 - WARNING] TCP Port 9630 in use.
[2022-10-15 13:43:16.385 - WARNING] TCP Port 9631 in use.
shadow-cljs - server version: 2.20.5 running at
shadow-cljs - nREPL server started on port 57047
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
throw e;
^
Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1022:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
at global.SHADOW_IMPORT ([stdin]:63:44)
at [stdin]:1535:1
at [stdin]:1579:3
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:313:38)
[2022-10-15 13:43:18.498 - INFO] :shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1}
SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
throw e;
^
And a lot of those. Then a lot of:
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
Failed to read: java.io.IOException: Input/output error
cljs.user=> [stdin]:66
throw e;
^
Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1022:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
at global.SHADOW_IMPORT ([stdin]:63:44)
at [stdin]:1535:1
at [stdin]:1579:3
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:313:38)
Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
Am I missing some minimal config for this to work with node-repl?shadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version...ws dependency among others. thats why there is the WARNING: shadow-cljs not installed in project. warningshadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version..."resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.cljs.core -> javascript -> project cljs files -> other local javascript -> other local source files?// baseData.ts
get: () => any
}
interface ISettable<out T> {
set(x: any): T;
}
export interface IGetSet<out T> extends ISettable<T>, IGettable {
}
type MapType = cljs.core.PeristentHashMap | cljs.core.PersistentArrayMap;
export class MyData implements IGetSet<MyData> {
cljsData: MapType
constructor(data: MapType) {
this.cljsData = data;
}
get(): any {
cljs.core.get(this.cljsData, cljs.keyword("data"))
}
set(x: any): MyData {
let existingData = this.cljsData;
let path = cljs.keyword("data");
let newData = cljs.core.assoc(existingData, path, x);
return new MyData(newData)
}
}
(ns somens.core (:require ["./path/to/src/gen/baseData.js" :as my-data])) (defn ^:export fancy-cljs-fn [my-data] (.set my-data 42))
// fancyData.ts
import {fancy_cljs_fn} from "???"; // help needed
import {IGetSet, MyData} from "./baseData";
class FancyData implements IGetSet<FancyData> {
mydata: MyData;
constructor(data: MyData) {
this.mydata = fancy_cljs_fn(data);
}
get(): any {
return this.mydata.get();
}
set(x: any): FancyData {
let newData = this.mydata.set(x);
return new FancyData(newData);
}
}
(ns fancyns.core (:require ["./path/to/src/gen/fancyData.js" :as fancy])) (defn ^:export super-fancy [fancy-data] "yay")
import {fancy_cljs_fn} from "goog:somens.core"
Did you already try it?"goog:cljs.core" was a hardcoded constant or something, didn't realize that was extensiblesrc/gen in :source-paths, will it watch src/gen/sub, or do I need to mention that explicitly?js/cljs-runtime.
{:source-paths
["src/cljs"
"src/gen"]
:deps true
:dev-http {8080 "public"}
:nrepl {:port 9000
:middleware [cider.piggieback/wrap-cljs-repl]}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn cljstable.core/init}}
:devtools {:repl-init-ns cljstable.sidecar
:repl-pprint true}}}}
Here's the compilation results and relevant directory structure. Am I doing something wrong here?
Invoked via cider with:
;; Startup: /home/jay/.nvm/versions/node/v16.14.0/bin/npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d refactor-nrepl/refactor-nrepl:2.5.1 -d cider/cider-nrepl:0.26.0 server ;; ;; ClojureScript REPL type: shadow ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :frontend) (shadow/nrepl-select :frontend))
js/cljs-runtime/module$cljstable$baseData.js, it gets rebuild with the unchanged codecider-connect-cljs:init-fn namespace in order for shadow-cljs to recognize a recompilecider-connect-cljs
You'd have to have a look at whatever is your nrepl server (maybe some webapp?)yarn shadow-cljs watch frontend then whatever cider does when connecting:init-fn namespace in order to recompile... phew... thank god... can move on with my life now...~/.shadow-cljs/config.edn file, although it looks like it's not much advised:init-fn is following all :require in the namespaces (or import in JS files) and compiles those. a file that is not required is not compiled, as you learned 😉:deps true the :source-paths config in shadow-cljs.edn has no effect. you should be warned about that on startup, but depending on how you start things that may not be visible (eg. emacs hiding it in some buffer):middleware [cider.piggieback/wrap-cljs-repl] this you don't need at allExceptionInfo: no goog/base.js with target :graaljs , full error in 🧵no goog/base.js
{}
ExceptionInfo: no goog/base.js
shadow.build.output/closure-defines-and-base (output.clj:58)
shadow.build.output/closure-defines-and-base (output.clj:53)
shadow.build.targets.graaljs/flush-dev (graaljs.clj:127)
shadow.build.targets.graaljs/flush-dev (graaljs.clj:111)
shadow.build.targets.graaljs/process (graaljs.clj:168)
shadow.build.targets.graaljs/process (graaljs.clj:160)
clojure.lang.Var.invoke (Var.java:384)
shadow.build/process-stage/fn--26795 (build.clj:161)
shadow.build/process-stage (build.clj:158)
shadow.build/process-stage (build.clj:150)
shadow.build/flush (build.clj:494)
shadow.build/flush (build.clj:488)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:563)
shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:556)
shadow.cljs.devtools.server.util/server-thread/fn--28186/fn--28187/fn--28195 (util.clj:269)
shadow.cljs.devtools.server.util/server-thread/fn--28186/fn--28187 (util.clj:268)
shadow.cljs.devtools.server.util/server-thread/fn--28186 (util.clj:241)
java.lang.Thread.run (Thread.java:833)watch?{:deps {:aliases [:sci]}
:dev-http {7778 {:roots ["public" "classpath:public"]}}
:nrepl false
:builds {:browser {:target :graaljs
:output-to "public/js/viewer.js"
:output-dir "public/js"
:build-options {:ns-aliases {nextjournal.devcards nextjournal.devcards-noop}}
:modules {:viewer {:entries [nextjournal.clerk.sci-viewer
nextjournal.clerk.static-app]}}
:dev {:compiler-options {:optimizations :simple}}
:release {:output-dir "build/"
:compiler-options {:source-map true}}
:js-options {:output-feature-set :es8}}}}:dev {:compiler-options {:optimizations :simple}} does absolutely nothing since dev never does any optimizations at all:compiler-options {:optimizations :simple} without nesting in :dev/`:release`2.16.7:target :graaljs didn't support :modules?:entries [...]?:graaljs be added to this list?
Target ":node" for build :browser was not found. The built-in targets are: - :browser - :browser-test - :node-script - :node-library - :npm-module - :karma - :bootstrap
ILookup etc on both sides?:autorun true set and has worked well when I execute npx shadow-cljs compile test the tests run fine. Some new code I'm testing relies heavily on promises and I'm using https://github.com/funcool/promesa in my library and test code. Test assertions inside a promesa.core/let aren't run. I tried moving the deftest inside a promesa.core/let but that hasn't worked either and the test count went down, leading me to believe that the test runner has completely lost sight of the suite. Have I missed something or should tests with promises be conducted in a special way?shadow.loader?
(ns example.core
(:require [shadow.loader :as loader]))
(defn load-ui! []
(-> (loader/load "ui")
(.then #(example.other/mount-root))))
(defn ^:export ^:dev/after-load init []
(load-ui!))
where I'm using example.other/mount-root as it I had :required it at the top level? It seems to work, just making sure that's the intention. (and if so -- any editor sympathetic tips for autocomplete, etc?)
2. I'm trying to figure out what the hell an ESM environment is, e.g., https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm, so that I can use this sweet trick: https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import. But when I do
(shadow.esm/dynamic-import anything)I get
shadow_esm_import is not defined.then in the promise triggers, the namespace is now available to be used as if it were :required? I agree it's not the smartest way to split code.#(example.other/mount-root) technically works but not greatshadow.loader at all in that examplecljs.loader for compatibility reasons:target :esm builds, not in :target :browser(ns example.db
(:require [reagent.core :as reagent]))
(defonce app-db (reagent/atom {:data 0}))
(ns example.a (:require shadow.loader)) (-> (shadow.loader/load "db") (.then #(swap! example.db/app-db update :data inc)))
(ns example.b (:require shadow.loader)) (-> (shadow.loader/load "db") (.then #(swap! example.db/app-db update :data inc)))
(ns example.ui
(:require [example.db :as db]
reagent.ratom))
(defn show-me []
(let [number (reagent.ratom/make-reaction #(get @db/app-db :data))]
(fn []
[:div (str "Your number is: " @number)])))
I'm trying to imagine if show-me, when rendered, would show 0, 1, or 2 as the numberexample.db would be part of the base module(ns example.a
(:require
[example.db :as db]))
(swap! db/app-db update :data inc)app-db and possible derived reagent.ratom/make-reactions separate from things like the UI and application logic. And I'm struggling to understand how, for instance, if the DB, the make-reactions, the UI, and the domain logic were all in separate modules, how could an on-click on one of the UI components update the app-db state if it were in a separate module -- and then how would the make-reactions pick up the reactive changes from the app-db, and then how would that get communicated back to the UI components. Maybe tl;dr I'm trying to figure out what sort of things MUST be directly coupled and which things can be indirect.app-db in the end, not one per module or whateverapp-dbDependency: @heroicons/react/24/outline not provided by external JS. Do you maybe need a recompile?Any ideas?
:js-provider :external. did you recompile the :external-index file with whatever tool you use? (webpack?):after-load a/render in my build config.
If I have
;; a.cljs (ns a (:require [b]) (defn app [] [b/render]) (defn render [] (uix.dom/render [app] (js/document.getElementById "app"))) ;; b.cljs (ns b) (defn render [] [:p "Hello world"])Everything works fine (ie. it will update if I modify
b/render and save the file
If I have:
;; a.cljs (ns a (:require [b])) (defn app [] [b/render]) (defn render [] (uix.dom/render [app] (js/document.getElementById "app"))) ;; b.cljs (ns b (:require [c])) (defn render [] [c/render]) ;; c.cljs (ns c) (defn render [] [:p "Hello world"])It will not reload if I modify
c/render until I also re-save b.cljs.
If I add c as a require to a then it will work properly. I suspect it has to do with caching intermediates, but I would expect this to work… Is this expected?c.cljs will cause c and b to be reloadedc from a then the render function is fired… Which is what I am having trouble understandingc from a cause it to work?(ns a (:require b c))is probably not going to be the same as
(ns a (:require c b))
c/render needs to be redefined first, then b/render, then a/render for hot reload path to function correctlyeval statement. I’m suspecting that react-native doesn’t support source maps on eval’d code. Is there a workaround for this?:target :npm-module for that:target :npm-module I'll happily change :target :react-native:react-native. it is there for good reasons:target :npm-module and you'll see if its still slow:target :esm so I'm able to keep a single bundle that I can run in the browser and in node (or graal). Are there any reasons I'm missing why this would be a bad idea?release builds would work:node-script, it just is the most straightforward way for node:node-script on the first glitch I run into:node-script first, thanks for the rec!:esm these days or also sticking with :browser?:browser, unless you want to load ESM code dynamically via import:esm instead of :node-scriptReferenceError: WebSocket is not defined at shadow$cljs$devtools$client$websocket$start (full error in 🧵 ) with target :esm and trying to run it via node .node public/js/viewer.js
Installing CLJS DevTools 1.0.3 and enabling features :formatters :hints :async
file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
^
ReferenceError: WebSocket is not defined
at shadow$cljs$devtools$client$websocket$start (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14)
at Object.attempt_connect_BANG_ (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
at file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:957:36
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
Node.js v18.7.0
:target :esm presumes browser runtime as the default:runtime :custom in the build configpublic/js/viewer.js that I can load without errors in node but am too stupid to write another script that imports and uses it 🙈 The js ecosystem often makes me feel this way…public for node. to me that look like it would end up as a public script in http sense, which I assume what you are not building hereshadow.cljs.devtools.client.env.module_loaded("viewer");./ path but didn't figure out how to make it workimport "viewer.js"?import { somethingYouExported } from "./public/js/viewer.js"import "viewer.js" is viewed by node a npm package and it'll try to load an npm package./ or ../public/js/viewer.js and /public/js/viewer.js but not ./public/js/viewer.js/ would be an absolute path, so absolute on your filesystempublic/js/viewer again would look for the public npm package:output-dir in a browser build.shadow-cljs are build supporting files (eg. caches). they are build internal and aren't used anywhere besides that(nth [] 1)npx shadow-cljs release app --debug to debug issuesnpx shadow-cljs release app --pseudo-names but that doesn't have source maps, so a little lower level and may require looking over some JS code--debug is best(spit "lib/nbb_core.js"
(str/replace (slurp "lib/nbb_core.js") (re-pattern "self") "globalThis"))clerk$ npx shadow-cljs release viewer --pseudo-names shadow-cljs - config: /mnt/c/Users/thheller/code/oss/clerk/shadow-cljs.edn shadow-cljs - starting via "clojure" Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. Full report at: /tmp/clojure-13405443538645289994.edn
import 'draft-js/dist/Draft.css';The only way to get that to work is to webpack compile it then require the webpack compiled javascript with shadow via the normal js interop routes? aka
// ./src/js/project/css.js import 'draft-js/dist/Draft.css';
(defn project.css (:require "/project/css")) ;; <-- Invalid namespace declarationetc?
shadow-cljs server and open (its UI)shadow-cljs watch frontend:8080 now? :dev-http?;; shadow-cljs configuration
{:deps true
:dependencies
[]
:dev-http {8080 "public"}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn }}}}}
Ah, ok. I need to specify a :handler for my non-static assets.:dev-http {8080 "public"} then:dev-http server. it is not involved in thatimport cljs from "goog:cljs.core";Is this a shadow thing or a Google Closure Compiler thing?
<div id="app"></div><script src=""></script>
This is great way to try a new frontend in a production. And even fulcro inspect is working.
Connecting shadow-cljs server is solved by changing devtools-url.
(when *localjs*
[:script "shadow.cljs.devtools.client.env.devtools_url=':' + shadow.cljs.devtools.client.env.server_port"])]]))
But there are still hundreds 404s when loading *.maps
https://production.example.com/js/main/cljs-runtime/com.fulcrologic.rad.rendering.semantic_ui.semantic_ui_controls.js.map
So is there a similar way to load *.map files from localhost?:asset-path controls this, it is badly named so it isn't obvious but it accepts a full url:script(assoc 26 :whatever "invalid")(meta (var my.ns/a-fun)) the function metadata does not appear to be included in the release builds by default! great!import cljs from "goog:cljs.core" style statement? I cannot find anything on this anywhere. Is the goog: part a shadow convention or is that a google closure compiler convention?cljs when I do import cljs from "goog:cljs.core"; but if I write some "resolve as" code it will work -- just need a few more clues about how it works under thehoodgoog.requiregoog: part is from google closure apigoog: part is some obscure and mostly undocumented feature in the closure compilerimport is ESM and CLJS and the Closure Library use ClojureJS module formatgoog: is just the way to bridge the two, nothing elsecljs-runtime directory but it's not obvious to me howimport files it just rewrites them to remove import and export and instead replaces everything with global referencescljs-runtime doesn't play a role in this in any way, apart from that being the location where the files end up 😉public
index.html
sub-app
index.html
any ideas to serve sub-app/index.html when localhost:8280/sub-app url is hit (other than downgrading)?binaryage/oops was complaining about js-fn? not existing. It looks like if i jump to 2.12.7 i fix the binaryage/oops error and still get the same index serving pattern.:dev-http where you can set :use-index-files true to get back the old behavior:dev-http {8000 {:root "public" :use-index-files true}}:builds {:app {:devtools
{:http-root "public"
:http-port 8280
:preloads [devtools.preload day8.re-frame-10x.preload portal.preload]}:dev-http {8280 {:root "public" :use-index-files true}} at the top level instead:http-root :http-port from the build config(shadow/release :main) in my build.clj I get "The required namespace is not available...", the being the first dependency required by my code, defined in the :deps key of my deps.edn. When I copy paste that dependency under :replace-deps of the :shadow-cljs alias then I get the same error with the next one (meaning that dependency is now visible to shadow/release).
My question would be if that is expected? Is there a way to tell shadow-cljs to use the deps from deps.edn :deps key like it does during development?:replace-deps, so the Clojure CLI will build a classpath with only the defined deps, and then you use Shadow’s API within the same JVM, so Shadow will have the same classpath.
You probably need to adjust your classpath and make sure that all ClojureScript deps are on the classpath as well, or spawn a sub-process from your build.clj to call Shadow with its own classpath.:shadow-cljs
{:paths ["src/main"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.20.2"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}build.clj? Using clojure -T:build?:build alias defined?:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.3" :git/sha "0d20256"}}
:ns-default build}-T will ignore the root-level :deps. In general, you should not use :deps in your aliases, but :extra-deps or :replace-deps. Normally, tools are meant to run in a classpath that is different from your project’s, so they use :replace-deps. In your case, can you try using :extra-deps in both your :build and :shadow-cljs aliases?:shadow-cljs already-T: https://clojure.org/reference/deps_and_cli#_running_a_tool
> When running a tool, the project’s :deps and :paths are not used.-T, as this is meant for standalone tools with their own classpath.
Instead, if you use :extra-deps in the :build alias, you should be able to use the -X switch to run your build functions, with a classpath built from your project’s :deps and all extra deps from additional aliases.:extra-paths ["."] so that your build.clj in on the classpath.
Note that:
> Tools declared with an alias can also be executed with -T, just as they can be executed with -X. The only difference is that -T implies {:replace-deps {}, :replace-paths ["."]}, so the project deps/paths will not be included, by default.shadow-cljs.edn to deps.edn (when configured) and builds the basis:npm-deps {:install false} top level in shadow-cljs.edn:app {:target :browser
....
:modules {:shared {:entries []}
:other {:entries ..}
...
My assumption is if the entries is empty (i.e []) then bundling all dependencies in public/shared.js file. I want to exclude a library which is not required at client side. I appreciate your time. Thanks:require in the ns forms, thus you need to remove the require to get rid of it?:require controls what is included, so thats what you need to work out. can't give many tips besides that:js-options {:resolve {"package-you-dont-want" false}} but that won't affect the CLJS code getting included:modules and a single build to compile client and server code together? so you don't have a :shared module and then a :client and :server?:entries [our-app.ui.pages.getting-started] if :init-fn is the same namespace. :init-fn desugars to that :entries, so specifying it again is redundant. just :init-fn is fine.shadow-cljs.edn? When I Google it, people say to use deps.edn as a fallback, but then I won't be able to use NPM packages. I feel stuck between a rock and a hard place.:local/root from deps.edn?{:builds {:preload {:target :node-script
:output-to "resources/preload.js"
:main app.preload.core/main
:hashbang false}
...}
...}
Now, I'm getting tons of warnings like DevTools failed to load source map: Could not parse content for file:///C:/Users/richie/Documents/org/projects/electric-clj-play/resources/public/goog.debug.error.js.map: Unexpected end of JSON input
It's not at resources/public/goog.debug.error.js.map , it's at resources/public/js/cljs-runtime/goog.debug.error.js.map.
How can I fix this?
Thanks!:target :browser but had some trouble and then found https://clojurians.slack.com/archives/C6N245JGG/p1634150800435700 thread. I'll try :target :browser again since now I don't remember what the problem was.:node-script really assumes node and at least watch/compile builds will probably only run in actual node:target :esm might also be an option. last time I looked at electron it didn't support ESM but its been a while:preload {:target :browser
:devtools {:watch-dir "resources/public"}
:output-dir "resources/public/js/preload"
:asset-path "js/preload"
:modules {:preload {:entries [app.preload.core]
:init-fn app.preload.core/main}}}
:renderer {:target :browser
:devtools {:watch-dir "resources/public"}
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:entries [user]
:init-fn app.renderer.core/start!}}}
which gives me a bunch of errors like ReferenceError: goog is not defined
and I tried not adding a browser target for preload and instead just adding a module
:renderer {:target :browser
:devtools {:watch-dir "resources/public"}
:output-dir "resources/public/js"
:asset-path "js"
:modules {:shared {:entries []}
:renderer {:entries [user]
:init-fn app.renderer.core/start!
:depends-on #{:shared}}
:preload {:entries [app.preload.core]
:init-fn app.preload.core/main
:depends-on #{:shared}}}}}
but that gives me
Unable to load preload script: C:\Users\richie\Documents\org\projects\electric-clj-play\resources\public\js\preload.js ReferenceError: SHADOW_ENV is not defined Uncaught ReferenceError: SHADOW_ENV is not defined
:target :esm didn't work right away although now I can't remember what was wrong... shoot.ReferenceError: __dirname is not defined coming from the preload.js file.
https://github.com/rgkirch/electron-help
Thanks a million! My goal was to add a second electron window to help debug things. I have some tracing in my main app that I wanted to send over. Initially I assumed they'd share my global state but it looks like I have to use ipc.nodeIntegration enabled. e.g. :webPreferences {:nodeIntegration true I'm back to just having the warnings.
That means I just don't know the "right" way to do this since I'm override the default behavior and what I'm doing here is discouraged for security reasons.:target shouldn't be a :node-script, do you have any suggestions on how to make it work as :esm or :browser?
Thanks again!:esm https://github.com/rgkirch/electron-help/compare/master...target-esm. I get SyntaxError: Cannot use import statement outside a module.:target :browser might be a better fit, but running with :js-options {:js-provider :require} so it doesn't attempt to bundle stuff:target :browser or :target :node-script with :js-options {:js-provider :require}
I tried
:preload {:target :browser
:devtools {:watch-dir "resources/public"}
:output-dir "resources/public/js"
:asset-path "js"
:modules {:preload {:entries [app.preload.core]
:init-fn app.preload.core/main}}
:js-options {:js-provider :require}}
:renderer {:target :browser
:devtools {:watch-dir "resources/public"}
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:entries [user]
:init-fn app.renderer.core/start!}}}
but get ReferenceError: goog is not defined(:require ["/my/awesome/stuff" :as awesome-stuff])
Previously I'd been using figwheel with webpack to make an index.bundle.js and then
(:require awesome-stuff)with
// index.js
awesomeStuff = require('src/js/my/awesome/stuff.js')
window.awesomeStuff = awesomeStuff
then yarn webpack etcimport {Config} from "../config"; // this explodes in the browser
Ironically, if I do this:
(ns app.lib.ext.config (:require ["/app/config" :as app-config])) (def ^:export Config app-config/Config)and then in my javascript I do
import config from "goog:app.lib.ext.config"; const Config = config.Config;it works great
goog.require work “(def ^:export Config app-config/Config) why is there an ^:export?import config from "goog:app.lib.ext.config"; why is this importing the CLJS ns instead of just the config directly?goog.require is no-op and does nothing at runtime. it merely serves as static information for the compiler so it can sort sources in the proper order”/app/config”Uncaught (in promise) ReferenceError: Config$$module$app$config is not defined"/app/config.js"expand to
"/js/compiled/cljs-runtime/app/config.js"instead?
"/js/compiled/cljs-runtime/app/config.js"config and module that calls a webworker, thread-utils) and (webworker worker)
◦ thread-utils depends on config (this is where the error is happening)
• tsconfig file that compiles the typescript into a location in src/gen
• shadow project builds :main, :base, and :worker
• clojurescript code from :main calls thread-utils from src/gen
• crash (:require ["/classpath/to/thread-utils" :as thread-utils]) (thread-utils/testAdd)
./config.js if they are all in the same dir// case1.js
export class Config {}
Config.fooPath = Paths.foo
Config.barPath = Paths.bar
vs
// case2.js
export class Config {
fooPath = Paths.foo
barPath = Paths.bar
}
the top one does not work with
import {Config} from "/path/to/config";
while the bottom on does. I have no idea why this is the case. But this is the result of:
// case1.tsx
export class Config {
static readonly fooPath = Paths.foo
static readonly barPath = Paths.bar
}
// case2.tsx
export class Config {
fooPath = Paths.foo
barPath = Paths.bar
}
export is declared in the generated code before the static methods are added, the static methods are not exportedError: xx is not a function?xx originally was in the source code:pretty-print and :pseudo-names default to false. You can use shadow-cljs release app --debug to enable both temporarily without touching your config. This is very useful when running into problem with release builds
from the https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options
Information about https://clojurescript.org/reference/compiler-options#pseudo-namesshadow-cljs release app --pseudo-names, which is without source maps. sometimes some optimizations make the source maps inaccurate and confusing. then its just better to decipher the generated JS, which pseudo names make possible somewhatpadding-[50px] like I could with Tailwind but yeah, I could get the same result with {:padding "50px"}:padding-[50px] is not a valid keyword, so can't do thatnvd-clojure that shadow-cljs has I should care?release outputs, should be anywhere near a production environments, so it really shouldn't mattershadow-undertow?(def component (js/require "./typescript/component.tsx"))
(ns my-project.my-ns (:require ["./assets.json" :as assets]))or
(def assets (js/require "./assets.json"))
#?(:org.babashka/nbb
(do
(ns crunchy.assets)
(def assets (js/require "./assets.json")))
:cljs
(do
(ns crunchy.assets
(:require
[shadow.resource :refer [inline]]))
(def assets (inline "./assets.json"))))
(defn asset
[rel-path]
(let [actual-path (aget assets rel-path)]
(when-not actual-path
(throw (js/Error. (str "Could not lookup asset " rel-path))))
actual-path))
Error:
[:app] Compiling ...
Closure compilation failed with 1 errors
--- crunchy/assets.cljc:8
Required namespace "shadow.resource" never defined.do to define ns. ns must be its own top level form(ns crunchy.assets
(:require
#.npmrc or something setting some invalid config?npmrc.deftype declaration, not even about calling those methods. Maybe the problem is that these "private" methods are just extending Object and they aren't declared on any protocols?(set! *warn-on-infer* false) in the file to get rid of the warnings:prod {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:build-hooks
[(build/move-directory
"node_modules/@fortawesome/fontawesome-pro/webfonts"
"resources/public/webfonts")]
...}}}
and same for dev. When using shadow-cljs release prod this build hook does not seem to move the files… Should it?dev build via shadow-cljs compile devcp node_modules/@fortawesome/fontawesome-pro/webfonts resources/public/webfonts solve the same problem in a much simpler way?copy-directory , not move. i do think it’s more logical to move this specific build step into a Makefile or so. thanksrelease the same way as devshadow-cljs compile dev the build is called prod? which is not a recommended build separation. dev/prod should be the same build:devtools {:watch-dir "public" :watch-path "/foo"}
But unfortunatly nothing happens.
I have a folder with javascript files, and I am using (js/require "...") to require it in my react native project. I would like a change in the folder to trigger my :after-load function so that the changes become visible without having to reload the app.npx shadow-cljs cljs-repl the-build or if you are connected to a CLJ nrepl already (shadow.cljs.devtools.api/repl :the-build)shadow-cljs compile app using this edn:
{:lein {:profile "+shadow-cljs"}
:builds {:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:app {:init-fn reagent-project.core/init!}}
:js-options
{:js-provider :external
:external-index "target/index.js"}}}
:dev-http {3000 {:root "resources/public"
:handler reagent-project.handler/app}}}
2. run babel target/index.js --out-file resources/public/js/libs.js
3. run shadow-cljs watch app
I noticed that the intermediate compiled file at target/index.js is as shown:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!
var ALL = {};
ALL["relay-runtime"] = require("relay-runtime");
ALL["react-dom/client"] = require("react-dom/client");
ALL["react-relay"] = require("react-relay");
ALL["react"] = require("react");
global.shadow$bridge = function shadow$bridge(name) {
var ret = ALL[name];
if (ret === undefined) {
throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
}
return ret;
};
shadow$bridge.ALL = ALL;
and as such, the final build file /resources/public/js/libs.js shows the same. I was wondering if there's an obvious or few obvious things that I'm missing from this. I also tried to follow the guidance on https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external , but realized that I don't have an index.html file. I'm not exactly sure what the entry point is for an app. I apologize for the noob-ness of this question as I'm new to ClojureScript. Thank you!{:deps {:aliases [:cljs]}
:builds {:app {:target :esm :output-dir "resources/public/assets/js"
:modules {:main {:init-fn app.core/init}}}}
:dev-http {3000 "resources/public"}}
and then tried to complete the build by running it through vite with the babel plugin wrapped in vite-plugin-relay, but am still seeing an error which I'm reading to mean that the plugin had not been applied, although I've been able to get it to work for projects outside of clojurescriptimport _AppQuery from "./__generated__/AppQuery.graphql";
import React from "react";
import { graphql, useLazyLoadQuery } from "react-relay";
export default function App() {
const data = useLazyLoadQuery((_AppQuery.hash && _AppQuery.hash !== "fe6589af5b8bfbe9722d3b296cc93444" && console.error("The definition of 'AppQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _AppQuery), {});
return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement("h1", null, /* @__PURE__ */React.createElement("a", {
href: "",
target: "_blank"
}, "SpaceX"), " ", "Data Viewer"), /* @__PURE__ */React.createElement("h2", {
id: "ships-heading"
}, "Ships"), /* @__PURE__ */React.createElement("ul", {
"aria-labelledby": "ships-heading"
}, data.ships?.map(ship => /* @__PURE__ */React.createElement("li", {
key: ship?.id
}, ship?.name))));
}
shadoww-cljs compiled js:
import "./cljs_env.js";
goog.provide('app.core');
var module$node_modules$react_dom$client=shadow.js.require("module$node_modules$react_dom$client", {});
var module$node_modules$react_relay$index=shadow.js.require("module$node_modules$react_relay$index", {});
app.core.query = module$node_modules$react_relay$index.graphql`
query app_pages_homeQuery {
rates(currency: "USD") {
currency
rate
}
}
`;
/**
* testing
*/
app.core.gql = (function (){var G__32142 = (function app$core$gql_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32143 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);
var map__32146 = (app.core.query.cljs$core$IFn$_invoke$arity$1 ? app.core.query.cljs$core$IFn$_invoke$arity$1(module$node_modules$react_relay$index.useLazyLoadQuery) : app.core.query.call(null,module$node_modules$react_relay$index.useLazyLoadQuery));
var map__32146__$1 = cljs.core.__destructure_map(map__32146);
var rates = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32146__$1,new cljs.core.Keyword(null,"rates","rates",-990130920));
var map__32147 = rates;
var map__32147__$1 = cljs.core.__destructure_map(map__32147);
var currency = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32147__$1,new cljs.core.Keyword(null,"currency","currency",-898327568));
var rate = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32147__$1,new cljs.core.Keyword(null,"rate","rate",-1428659698));
return helix.core.get_react().createElement("div",(function (){var obj32149 = ({"key":currency});
return obj32149;
})(),helix.core.get_react().createElement("p",null,currency,": ",rate));
});
if(goog.DEBUG === true){
var G__32150 = G__32142;
(G__32150.displayName = "app.core/gql");
return G__32150;
} else {
return G__32142;
}
})();
/**
* A component which greets a user.
*/
app.core.greeting = (function (){var G__32152 = (function app$core$greeting_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32153 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);
var map__32156 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32153,(0),null);
var map__32156__$1 = cljs.core.__destructure_map(map__32156);
var name = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32156__$1,new cljs.core.Keyword(null,"name","name",1843675177));
return helix.core.get_react().createElement("div",null,"Hello, ",helix.core.get_react().createElement("strong",null,name),"!");
});
if(goog.DEBUG === true){
var G__32157 = G__32152;
(G__32157.displayName = "app.core/greeting");
return G__32157;
} else {
return G__32152;
}
})();
= (function (){var G__32160 = (function app$core$app_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32161 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);
var vec__32164 = helix.hooks.use_state(new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"name","name",1843675177),"Helix User"], null));
var state = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32164,(0),null);
var set_state = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32164,(1),null);
return helix.core.get_react().createElement(module$node_modules$react_relay$index.RelayEnvironmentProvider,(function (){var obj32168 = ({"environment":app.core.environment});
return obj32168;
})(),helix.core.get_react().createElement("div",null,helix.core.get_react().createElement("h1",null,"Welcome!"),helix.core.get_react().createElement(helix.core.Suspense,(function (){var obj32170 = ({"fallback":"loading..."});
return obj32170;
})(),helix.core.get_react().createElement(app.core.gql,null))),helix.core.get_react().createElement(app.core.greeting,(function (){var obj32172 = ({"name":new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(state)});
return obj32172;
})()),helix.core.get_react().createElement("input",(function (){var obj32174 = ({"value":helix.impl.props.or_undefined(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(state)),"onChange":(function (p1__32158_SHARP_){
var G__32175 = cljs.core.assoc;
var G__32176 = new cljs.core.Keyword(null,"name","name",1843675177);
var G__32177 = p1__32158_SHARP_.target.value;
return (set_state.cljs$core$IFn$_invoke$arity$3 ? set_state.cljs$core$IFn$_invoke$arity$3(G__32175,G__32176,G__32177) : set_state.call(null,G__32175,G__32176,G__32177));
})});
return obj32174;
})()));
});
if(goog.DEBUG === true){
var G__32178 = G__32160;
(G__32178.displayName = "app.core/app");
return G__32178;
} else {
return G__32160;
}
})();
app.core.init = (function app$core$init(){
if((typeof app !== 'undefined') && (typeof app.core !== 'undefined') && (typeof app.core.root !== 'undefined')){
} else {
app.core.root = module$node_modules$react_dom$client.createRoot(document.getElementById("root"));
}
return app.core.root.render(helix.core.get_react().createElement(,null));
});
goog.exportSymbol('app.core.init', app.core.init);
//# sourceMappingURL=app.core.js.map
PouchDB
var pouchdb = function() {};
pouchdb.plugin = function() {};
pouchdb.plugin().auth = {};
var auth = {};
auth.default = {};
var perms = {};
var pfind = {};
pfind.default = {};
var pmemory = {};
pmemory.default = {};
pouchdb.logIn = function() {};
pouchdb.changes = function() {};
pouchdb.changes().on = function() {};
pouchdb.createIndex = function() {};
pouchdb.get = function() {};
pouchdb.put = function() {};
= function() {};
pouchdb.remove = function() {};
pouchdb.allDocs = function() {};
pouchdb.find = function() {};
pouchdb.sync = function() {};
pouchdb.sync().on = function() {};
pouchdb.destroy = function() {};
pouchdb.bulkDocs = function() {};
pouchdb.getAttachment = function() {};
:infern-externs :auto and just annotate with ^js as prompted. But for literal js files I get no warning, only runtime errors.if (parent && parent.type.allowsMarkType(type)) {
here, the allowsMarkType gets renamed:inter-externs:pretty-print trueallowsMarkType would be renamedshadow-cljs release app --pseudo-names:advanced. you do that by changing them to commonjsrequire/module.exports instead of import/export(shadow.cljs.devtools.api/cljs-eval :app "(js/console.log ::foo)" {:ns 'foo.bar})cljs.analyzer.api/resolve, which requires the env(shadow.cljs.devtools.api/compiler-env :app) but its not the env required for resolve, its the compiler env usually bound to cljs.env/*compiler* atomcljs.analyzer.api/with-compiler-env macro or so where this would goshadow-cljs changes you're aware of that contributed to the dramatic decrease in bundle size:js-provider :import (ie. shadow-cljs not in charge of bundle npm dependencies):js-provider :import along w/ webpack and the commit above made our webpack bundle much smaller 🎉:js-provider :import bundles all npm deps into a single file to be fed into the external JS bundler. Since modules are loaded all or nothing, would this mean all our deps would be loaded as soon as our first "app" module required a dep? in a lazy-loaded/code-split environment, the benefit is not as clear-cut right? maybe it's still worth the reduced bundle size -- i might have to experiment 🙂:js-provider :import doesn't do any bundling of the JavaScript dependencies and instead leaves that to some other tool (in our case webpack).:js-provider :external. thats different. :js-provider :import fully supports code splitting as well, :external puts all JS deps in one file and is not splittable:import depends on the npm deps you use. not all are tree shakeable:js-provider :import over :js-provider :external would I just need to hand roll a js file for the requires? I’m not sure how they’d be exposed to shadow-cljs. I’ve got a 1mb production artifact I’m convinced could be split down some.main corresponds to the module that I have defined in my shadow-cljs.edn file.
if (process.env.NODE_ENV !== "production") {
require("./.shadow-cljs/cljs-runtime/shadow.cljs.devtools.client.browser.js");
}
import init from "./.shadow-cljs/main.js";
init();:init-fn in the build config. no need for exports then. also the extra conditional require shouldn't be required at all. you can just point webpack directly at the shadow-cljs output;; shadow-cljs.edn
{:builds
{:web
{:target :esm
:output-dir ".shadow-cljs"
:devtools {:watch-dir "resources/public"}
:js-options {:js-provider :import}
:modules {:main {:init-fn com.vistaly.web.core/init!}}}
}}
is all you need:output-dir. the .shadow-cljs dir is for shadow-cljs internal runtime files and caches. at some point this may create conflicts and either create problems in your builds or shadow-cljs internallyrelease also sets goog.DEBUG false, so no need to specify it. it also defaults to :optimizations :advanced:infer-externs :auto ?util.cljc :
(ns util
#?(:clj (:refer-clojure :exclude [slurp]))
#?(:cljs (:require-macros [util])))
#?(:clj
(defmacro slurp [file]
(clojure.core/slurp file)))
And a file parse.cljs:
(ns parse (:require [util :refer [slurp]])) (comment (slurp "shadow-cljs.edn") )Then I need to load
parse.cljs twice to use the macro:
% npx shadow-cljs node-repl
shadow-cljs - config: /Users/pez/Projects/sass2garden/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[2022-11-01 15:10:18.802 - WARNING] TCP Port 9630 in use.
[2022-11-01 15:10:18.805 - WARNING] TCP Port 9631 in use.
shadow-cljs - server version: 2.20.7 running at
shadow-cljs - nREPL server started on port 54616
cljs.user=> shadow-cljs - #4 ready!
(load-file "src/main/parse.cljs")
[]
cljs.user=> (in-ns 'parse)
nil
parse=> (slurp "shadow-cljs.edn")
Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of undefined (reading 'call')
:repl/exception!
parse=> (load-file "src/main/parse.cljs")
[]
parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n \"src/main\"\n \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"
parse=> :require-macros in the ns form https://clojurescript.org/guides/ns-forms#_macros:require-macros in util ns but not in the parse ns. My guess is you just need to tweak that to use your slurp macro:require-macros from util.cljc, things should be good, right? It's equivalent to, util.cljs:
(ns parse (:require [util :refer [slurp]])) (comment (slurp "shadow-cljs.edn"))+
util.clj:
(ns util (:refer-clojure :exclude [slurp])) (defmacro slurp [file] (clojure.core/slurp file))And I get the same strange behaviour if I do it like that. Loading
parse.cljs twice makes it work.(require 'parse) (parse/slurp ...) work?cljs.user=> shadow-cljs - #4 ready!
(require 'parse)
nil
cljs.user=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------
cljs.user=> (in-ns 'parse)
nil
parse=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------
parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n \"src/main\"\n \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"cljs.user=> shadow-cljs - #4 ready!
(load-file "src/main/parse.cljs")
[]
cljs.user=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------
cljs.user=> (in-ns 'parse)
nil
parse=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
Resource: <eval>:1:2
Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------
parse=> (slurp "shadow-cljs.edn")
Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of undefined (reading 'call')
:repl/exception!
parse=> (load-file "src/main/parse.cljs")
[]
parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n \"src/main\"\n \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"require was crap. It does work with require, it is with load-file it doesn't work. I also found out another interesting detail <- click-bait https://github.com/thheller/shadow-cljs/issues/1059:node-library and have to use :js-provider :require (for mariadb since it has syntax the Closure compiler does not understand right now), is there anyway to get shadow-cljs to import a ESM module? I tried the "https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import" section in the User Guide, but I got ReferenceError: shadow_esm_import is not defined:target :esm adds the proper code to make that work:target :esm instead?:prepend "global.shadow_esm_import = function(s) { return import(s); };" to your build config:target-defaults :node-library :prepend . Thank you for your help.shadow-cljs 2.20.7 in both deps.edn and package.json. Tried to run a build report via
npx shadow-cljs run shadow.cljs.build-report client js-provider-import-report.htmland ran into the following error
File: /Users/alex/code/icebreaker/src/icebreaker/config.cljc failed to require macro-ns "icebreaker.macros", it was required by "icebreaker.config" Error in phase :execution FileNotFoundException: Could not locate digest__init.class, digest.clj or digest.cljc on classpath.
digest ns. This is a CLJ error, it is not from shadow-cljs. So I'm guessing you maybe don't have a deps.edn alias activated or something like that:js-provider :import will cause shadow-cljs to not bundle any npm dependencies. so your build report will shrink, depending on how many you used. it'll only contain cljs code after that. don't get mislead by that. the build will only work if something else provides those dependencies, so be sure to compare the final size. not the build reports.:js-provider :import - that makes sense:deps {:aliases [:dev :storybook]}
but can I alternatively set different aliases for different builds?:CljEval (shadow/repl :app)? Would be cool if I could specify this in shadow-cljs.edn or similar.[:app] Build failure: Closure compilation failed with 5 errors --- node_modules/@chakra-ui/descendant/dist/index.cjs.js:69 Transpilation of 'Not a class declaration' is not yet implemented. --- node_modules/@chakra-ui/modal/dist/index.cjs.js:85 Transpilation of 'Not a class declaration' is not yet implemented. --- node_modules/@chakra-ui/react-use-pan-event/dist/index.cjs.js:39 Transpilation of 'Not a class declaration' is not yet implemented. --- node_modules/@chakra-ui/react/node_modules/@chakra-ui/utils/dist/index.cjs.js:999 Transpilation of 'Not a class declaration' is not yet implemented. --- node_modules/@chakra-ui/system/node_modules/@chakra-ui/utils/dist/index.cjs.js:999 Transpilation of 'Not a class declaration' is not yet implemented.Hi guys, getting these errors with shadow-cljs latest versions, any help ^^
:js-options
{:js-provider :external}
it throws a this error regarding react object?
but the object shadow.js.shim.module$react is available … weird 😕:js-provider :external doesn't use this? did you maybe load the wrong code or some bad cache?:figwheel-always for shadow-cljs?
Specifically in relation to reloading javascript changes for things that aren't directly in the path of the init-fn ? I'm trying to use some sidecar files to not clutter up the program while I'm experimentingcomment block. Yeah exactly:dev/always but that won't magically include the files in the build:preloads to add them thoughFailed to inspect file
<elided>/node_modules/pdfjs-dist/build/pdf.js
it was required from
<elided>/node_modules/@react-pdf-viewer/core/lib/cjs/core.min.js
Errors encountered while trying to parse file
<elided>/node_modules/pdfjs-dist/build/pdf.js
{:line 2118, :column 9, :message "Semi-colon expected"}
Might just be an actual problem with this version of pdfjs, but posting here in case it has something to do with compilation iteself
--- has anyone seen this type of error during compilation?
Thank you 🙏wrap-out that redirects all std out to the cider REPL, which I personally find a bit of a pain to work with.
Normally I would just remove it from the stack, but I haven't been able to figure out how to provide shadow with a custom middleware list. I've tried both ~/.nrepl/nrepl.edn and using the .shadow-cljs.edn {:nrepl {:middleware ...} option, which the docs say are supported, but neither seems to have the desired effect. In fact, the shadow nREPL server does not seem to want to recognize "ls-middleware" operation so I can verify what middleware is being loaded:
({:id "1a43aa3c-2865-4513-9a2b-51c1166e2e40",
:op "ls-middleware",
:session "8dc66073-fd36-4cf1-a6b0-936d59c1993b",
:status ["done" "unknown-op" "error"]})
When I start up the same version of nREPL server and Cider outside of shadow, the above :op return the full list of middleware being loaded by the server, as expected.
Am I doing something wrong? Any suggestions where I can go from here?:nrepl {:middleware ...} should be fine but it is only additive. it'll not override or remove defaultsmathlive in my clojure namespace paths?
I have a namespace mathlive.core , which compiles great. But if I do this:
(ns mathlive.core (:require ["mathlive" :as ml])) (defn Mathfield [!state] [:div "testing"])then I see this error:
TypeError: Cannot set properties of undefined (setting 'Mathfield')triggered from this compiled js:
mathlive.core.Mathfield = (function mathlive$core$Mathfield(_BANG_state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),"test"], null);
});
of course this restriction would make sense, for some reason I thought when this came up for the “mathbox” library I had decided that I WAS able to use namespaces like mathbox.core etcmathlive.something; just this one, maybe since it is the first namespace to require the js “mathlive” dependency?mathlive JS variable? that would indeed clash with and destroy the CLJS namespacewindow.mathlive = whatever; or global.mathlive = whatever.nils being both logically false AND the default return value of a function that crashes AND a missing key is kind of a rough overlap nil doesn't have to be the missing key return. When I need distinction I use (get a-map :my-key ::not-found) or (:my-key a-map ::not-found)::not-found is logically true except by convention. And then you’ve started on the slippery slope. Because then you need a class of predicates that treats ::not-found as false. And the long tail of that is a cascade of issues. However I do think that what you said about showing early rapid progress to stakeholders is incredibly important app? I was trying to make a very minimal example and my :init-fn is app/init and I get errors stating “Error: Namespace ‘app’ already declared” and “An error occurred when calling (app/init)” “TypeError: app.init is not a function”. That’s on the first load of the page. If I save a file in the project, shadow recompiles and reloads the browser and I don’t get the errors. But on a fresh reload I get the errors back again. If I change my namespace to something else, like myapp, no errors. If I move the file down into a subdirectory, so the namespace is , no errors. But I can’t seem to use just plain app directly under my ‘src’ directory as my main entry point.app variable like var app or from somewhere else?:node-library target for reaching a ClojureScript library from a JS script. It works fine except that when I watch my build, and then run my JS script, it never exits. If I don't watch the build, then things are all fine. Is there something I can do to be able to watch the build and be able to call functions in the library that don't keep my calling script hanging?:devtools {:enabled false} in the build config:target :esm, see docs.:js-options {:js-provider :import}tailwindcss in a shadow-cljs (re-frame) project.
When making release builds (using npm run release ) I notice that various css classes that use the data variants (https://tailwindcss.com/blog/tailwindcss-v3-2#data-attribute-variants) like data-[enabled=true]:bg-red-800 are not included in the generated css file. I suppose it is some kind of obfuscation problem where shadow-cljs obfuscates the class names in the output code and tailwindcss cannot properly detect in the optimized output that they are used? Anybody encountered this?rm -rf resources/public/{js,css}; npx shadow-cljs compile app; NODE_ENV="production" TAILWIND_MODE="build" ./node_modules/.bin/tailwindcss -i tailwind.css --config tailwind.config.js -o resources/public/css/site.css
.group[data-edit=false] .group-data-\[edit\=false\]\:hidden {
display: none;
}
.group[data-edit=true] .group-data-\[edit\=true\]\:hidden {
display: none;
}
While using rm -rf resources/public/{js,css}; npx shadow-cljs release app; NODE_ENV="production" TAILWIND_MODE="build" ./node_modules/.bin/tailwindcss -i tailwind.css --config tailwind.config.js -o resources/public/css/site.css
(with only difference being npx shadow-cljs release instead of compile)
.group[data-edit\x3dfalse] .group-data-\[edit\\x3dfalse\]\:hidden {
display: none;
}
.group[data-edit\x3dtrue] .group-data-\[edit\\x3dtrue\]\:hidden {
display: none;
}
\x3d come from?"resources/public//**/*.js",
"resources/public//**/*.html"
as the sources btwnvim -d to diff them and saw this<>= etc\x3d with =?:advanced may have removed some tailwind string that you didn't use but still have in the sourcesfalse. ie. it doesn't trust strings in the source, and to be safe escapes certain characters (eg. <>=) with \x3d etc2.20.8 and :compiler-options {:trusted-strings true} in your build config(cljs.repl/source-fn env 'cljs.core/first) but I don't have an environment. I know I can get the compiler environment for a build-id with shadow.cljs.devtools.api/compiler-env but most functions I want to use require the analysis env instead. Is there a way of calling this functions? I know how to call them with macros at macroexpansion time by using the analysis environment provided as &env but I would like to do it from the clojure repl.env via (cljs.analyzer/empty-env). it expects *cljs-ns* to be bound for the current ns thoughcljs.user also works depending on what you are trying to do?cljs.env/compiler like this :
(binding [cljs.analyzer/*cljs-ns* 'cljs.user
cljs.env/*compiler* (atom (shadow.cljs.devtools.api/compiler-env build-id))]
(repl/source-fn (ana/empty-env) symb))localhost:9630 I think you can recompile from there:npm-module target and the default :advanced optimizations in a Release build.
The module output for clojure.string.js changes depending on whether I use remove-watch in my code or not.
Without, everything works fine, and the file’s second line starts like this:
'use strict';var Sl,Ul;$CLJS.Fh=function(a,b){return $};Sl=function(a,b){var c=Array(a.length-2);$CLJS.fc...
When I refer to remove-watch, then this line looks like this, skipping the creation of the Fh function:
'use strict';var Sl,Ul;Sl=function(a,b){var c=Array(a.length-2);$CLJS.fc(a,0,c,0,2*b);$CLJS.fc....
But $CLJS.Fh is later used in the same file, e.g.:
$CLJS.ae.prototype.nd=$CLJS.Fh(27,function(a,b,c)...And I get a JavaScript error that
$CLJS.Fh is not defined.
Took my a lot of time and frustration to narrow it down to remove-watch… What’s special about that var? Any ideas?Fh definition is moved to taoensso.encore.js when I use remove-watch, but this file is not required by clojure.string of coursenpx shadow-cljs release <your-build> --pseudo-namesFh of one build is Fh in another buildFh definition is exactly the same. And anyway, I do get the problem that clojure.string uses this but does not have itFh is this:
$CLJS.$JSCompiler_unstubMethod$$ = function($JSCompiler_unstubMethod_id$$, $JSCompiler_unstubMethod_body$$) {
return $CLJS.$JSCompiler_stubMap$$[$JSCompiler_unstubMethod_id$$] = $JSCompiler_unstubMethod_body$$;
};:compiler-options {:cross-chunk-method-motion false} in your build configclass Thing { foo() { ... } } or soshadow.modern/defclassfoo is only used on one module but Thing in multiple. it may move the definition of foo elsewheredeftype defrecord and or JS type really, even reify.:target :esm with :js-provider :import:npm-moduleremove-watch in the end and came up with a better design anyway:cross-chunk-method-motion false seems to indeed solve this! 🎉"mermaid/dist/mermaid.core.mjs" it seems to work fine. can't tell if the commonjs variant you get via "mermaid" is busted itself, or if the closure compiler rewriting it messes it up"mermaid/dist/mermaid.core.mjs" and it worked.:advanced optimizationsConnecting to remote nREPL server... Clojure 1.11.1 (shadow/nrepl-select :main) To quit, type: :cljs/quit => [:selected :main]And in this namespace I have imports:
(ns dev-test
(:require [com.fulcrologic.fulcro.data-fetch :as df]
)
But it seems that the requires just don’t work. They work in the app, just not in the REPL:
df/load! ------ WARNING - :undeclared-ns ------------------------------------------------ Resource: <eval>:1:1 No such namespace: df, could not locate df.cljs, df.cljc, or JavaScript source providing "df" -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:1 Use of undeclared Var df/load! -------------------------------------------------------------------------------- => nil ::df/id [line 1, col 8] Invalid keyword: ::df/id. => nilIt does work if I write this:
(require '[com.fulcrologic.fulcro.data-fetch :as df]) => nil df/load! => #object[com$fulcrologic$fulcro$data_fetch$load_BANG_]What gives?
Connecting to remote nREPL server... Clojure 1.11.1 (shadow/nrepl-select :main) To quit, type: :cljs/quit => [:selected :main] (in-ns 'roklenarcic.cookery.dev-cli) => nil Loading src/main/roklenarcic/cookery/ui/category.cljs... ------ WARNING - :redef -------------------------------------------------------- Resource: <eval>:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs -------------------------------------------------------------------------------- config ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:1 Use of undeclared Var /config -------------------------------------------------------------------------------- => nil
(in-ns 'roklenarcic.cookery.dev-cli) doesnt' load the ns, it only switches to itLoading src/main/roklenarcic/cookery/ui/category.cljs...roklenarcic.cookery.dev-cli(in-ns 'roklenarcic.cookery.dev-cli) this is likely the first problemLoading src/main/roklenarcic/cookery/ui/category.cljs... ------ WARNING - :redef --------------------------------------------------------
in-ns WITHOUT the namespace being already loaded that is an ERROR------ WARNING - :redef -------------------------------------------------------- Resource: <eval>:33:1 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs --------------------------------------------------------------------------------somehow
in-ns you should do (require 'roklenarcic.cookery.dev-cli)in-ns will just issue a blank (ns roklenarcic.cookery.dev-cli) which means your require aliases won't be available:esm trying to load the js built by shadow from another port it fails because browsers are more strict about module includes, requiring a Access-Control-Allow-Origin` header set. I tried using my own http-handler but that only gets called when a file doesn't exist. Wondering if you'd be open to adding that header with a * value?:roots but defaulting to the header set might be simpler?fs is part of the node-libs-browser polyfill package to provide node-native package support for none-node builds. You should install shadow-cljs in your project to provide that dependency. npm install --save-dev shadow-cljsI’m getting this message despite shadow cljs being installed in package.json. version is
2.20.10:js-package-dirs?node_modules for client and server code though and above this message I’m seeing my client build fail because I’m requiring fs — which I guess kind of makes sense but worked with 2.15.102.15.10:js-package-dirs, but then basically confirmed that you do in the next sentence? I'm confused by what you mean there. If you have :js-package-dirs ["client/node_modules"] or something then the node-libs-browser or shadow-cljs package needs to be installed in that node_modules folder?app.client in different paths for two different builds. In src/website and src/launcher:website deps.edn alias (with extra path src/website associated with the :website shadow.cljs build, then same with the :launcher buildapp.website and app.launcher or whatever namespaces that do distinctive thingsclj directlyshadow-cljs watch website is the same as clj -A:whatever:aliases -M -m shadow.cljs.devtools.cli watch websiteInspect feature of shadow-cljs UI not datafying?(comment
(require '[clojure.core.protocols :as p])
(extend-type js/HTMLDivElement
p/Datafiable
(datafy [o]
(.-outerHTML o)))
(def div (doto (js/document.createElement "div")
(.appendChild (js/document.createTextNode "Hello World"))))
(p/datafy div) ;; "<div>Hello World</div>"
(tap> div) ;; [object HTMLDivElement]]
(def m (with-meta {} {`p/datafy (fn [_] :map)}))
(p/datafy m) ;; :map
(tap> m) ;; {}
)
Which the tapped versions in the UI don't datafy when they're in the "viewer" (after clicking on them).div. protocols on native types like that can be icky(p/datafy ...) directly does, so that's why it's odd to me(satisfies? p/Datafiable (js/Error. "oops")) ;; true (tap> (js/Error. "oops"))This does work, so it is datafying somethings
(deftype Foo [x])
(extend-type Foo
p/Datafiable
(datafy [this]
{:x (.-x this)}))
(tap> (Foo. :a))
So it's something w/ native types and then also metadata protocols?p/datafy, just something about the Inspect UI not recognizing them to datafy(nb/base64encode "abc"), from a REPL I get module$node_modules$nata_borrowed$nataBorrowed.base64encode is not a function
I'm really impressed that I got that far on the first shot! It knows where to find the function, but it says it isn't a function. Maybe this is a clojurescript question. How do I call a function? I see lots of example of calling methods.var utils = require('./utils');
var dateTime = require('./datetime');
const nataBorrowed = (() => {
'use strict';
// Then the function definition
// Bottom of file...
return {
base64encode
};
})();
module.exports = nataBorrowed;const getName = () => {
'use strict'; // Linting wanted this line.
return 'Jim';
};
exports.getName = getName;
Then I did npm publish --dry-run and copied the results and package.json into a directory
that I placed in my program's node_modules directory. It contained:
-rw-rw-r-- 1 pdenno pdenno 2009 Nov 17 11:51 package.json
-rw-rw-r-- 1 pdenno pdenno 1005 Nov 17 11:55 smallExample-es5.js
-rw-rw-r-- 1 pdenno pdenno 829 Nov 17 11:55 smallExample-es5.min.js
-rw-rw-r-- 1 pdenno pdenno 0 Nov 17 11:55 smallExample.js
-rw-rw-r-- 1 pdenno pdenno 527 Nov 17 11:55 smallExample.min.js
I added smallexample 1.0.0 to my program's package.json and fired up shadow.
npx shadow-cljs -d nrepl/nrepl:1.0.0 -d cider/piggieback:0.5.3 -d cider/cider-nrepl:0.28.5 watch kaocha-test
Connecting with cider-connect-cljs, in the REPL:
(se/getName)
Execution error (TypeError) at (<cljs repl>:1).
module$node_modules$smallexample$smallExample.getName is not a function
I suspect that I just don't know how to call the function.(ns rad-mapper.builtin
(:require ...
#?(:cljs ["smallexample" :as se])))
Then I'm just calling it with (se/getName) for example.
I am using shadow-cljs 2.20.5.
It could be something really stupid. This is all pretty new to me.["jsonata" :as ja] and then added (js/console.log "ja" ja) and it appears to be all fine? I can't test your other package locally? or is it somewhere in that repo?-rw-rw-r-- 1 pdenno pdenno 0 Nov 17 11:55 smallExample.js
which I did not notice is a file of size of 0 bytes.
For anyone reading this thread, there were a few useful thing I learned in the process:
Most significantly, I didn't realize that, for example, (require '["jsonata" :as ja]) binds ja to the object that you export from the npm module. You can just evaluate ja in the REPL and see the object. The object bound to the empty npm module smallExample.js is #js {}. That's good to know for debugging. Secondly, you might have to explicitly do the require in the REPL. Just being in a namespace that requires it might not be enough. (Or perhaps I have another bug to chase down.)
Thanks for the help! Sorry for the noise. shadow-cljs is a great tool.(in-ns 'your.ns) in the REPL before having loaded it the namespace will indeed be empty and contain no requires(require 'your.ns) first(:require [goog.crypt.base64 :as b64]) then (b64/decodeString ...)java.lang.NoSuchFieldError: __thunk__0__ issue commented on in commit https://github.com/thheller/shadow-cljs/commit/b034b24d8d20e538afe31b6a19087f021d0813e2
After quite a bit of fault searching and trial-and-error. I’ve come to the point where a suggestion or two would be nice.
Some details:
• My project is based on the https://luminusweb.com.
• All was good until shadow-cljs started using core.async v1.6.673
• The issue goes away if I downgrade to core.async v1.5.648
• My dependencies list all versions of clojure, clojurescript, clojurescript, closure-compiler-unshaded and core.async that shadow-cljs requires according to clojars and error message. I also tried moving all of them to :managed-dependencies in project.clj, without noticeable effect.
• As a test I started out with a clean lein new luminus myproject +shadow-cljs and bumped shadow-cljs to v2.20.11 and all mentioned libs to the versions shadow requires, it still worked. I then started adding other libs my project uses and error reappeared when I added [com.wsscode/pathom3 "2022.10.19-alpha"] as a dependency and required it as [com.wsscode.pathom3.connect.operation :as pco] in myproject/core.clj. I noticed that Pathom3 also uses shadow-cljs.
It’s honestly not that clear to me which library is to “blame” here. Seems like a snowballing effects starting with a change to core.async, but this is all a bit deeper than where I usually spend my time.
Staying at core.async v1.5.648 might be a workaround for now, but does not seem like a good option in the long run. Other suggestions would be very much appreciated.(def query (js-template graphql "
query reagentProject_pages_homeQuery {
rates(currency: \"USD\") {
currency
rate
}
}
"))
...
(let [{:keys [rates]} (-> useLazyLoadQuery query)]
such that instead of getting this:
reagent_project.pages.home.query = module$node_modules$react_relay$index.graphql`
query reagentProject_pages_homeQuery {
rates(currency: "USD") {
currency
rate
}
}
`;
var map__42409 = (reagent_project.pages.home.query.cljs$core$IFn$_invoke$arity$1 ? reagent_project.pages.home.query.cljs$core$IFn$_invoke$arity$1(module$node_modules$react_relay$index.useLazyLoadQuery) : reagent_project.pages.home.query.call(null,module$node_modules$react_relay$index.useLazyLoadQuery));
I can get this:
var query = graphql`
query reagentProject_pages_homeQuery {
rates(currency: "USD") {
currency
rate
}
}
`;
var data = useLazyLoadQuery(query, {});
I had tried to update my shadow-cljs.edn like so:
:builds {:app {:target :esm
:compiler-options {:optimizations :simple}
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:app {:init-fn reagent-project.core/init!}}}}
:dev-http {3000 {:root "resources/public"
:handler reagent-project.handler/app}}}
useLazyLoadQuery come from?(-> useLazyLoadQuery query) why the ->?(useLazyLoadQuery query) should generate the proper code?useLazyLoadQuery is:refer or how did you declare it?(defnc home []
(let [{:keys [rates]} (-> useLazyLoadQuery query)]
(let [{:keys [currency rate]} rates]
(d/div {:key currency}
(d/p currency ": " rate)))))
;; (d/span {:class "main"}
;; (d/h1 "Welcome to reagent-project")
;; (d/ul
;; (d/li (d/a {:href (path-for :items)} "Items of reagent-project"))
;; (d/li (d/a {:href "/broken/link"} "Broken link"))))
;; )
(defn home-page []
(helix.core/suspense
{:fallback "loading..."}
($ home)))useLazyLoadQuery:require in your ns? is it a local def?(ns reagent-project.pages.home
(:require
[reagent-project.utils.path-for :refer [path-for]]
["react-relay" :refer [useLazyLoadQuery graphql]]
[helix.core :refer [defnc $]]
[shadow.cljs.modern :refer [js-template]]
[helix.dom :as d]
[reagent.core :as reagent :refer [atom]]))
(def query (js-template graphql "
query reagentProject_pages_homeQuery {
rates(currency: \"USD\") {
currency
rate
}
}
"))
(defnc home []
(let [{:keys [rates]} (-> useLazyLoadQuery query)]
(let [{:keys [currency rate]} rates]
(d/div {:key currency}
(d/p currency ": " rate)))))
(defn home-page []
(helix.core/suspense
{:fallback "loading..."}
($ home)))->?(defnc home []
(let [result (useLazyLoadQuery query)
{:keys [rates]} result
{:keys [currency rate]} rates]
(d/div {:key currency}
(d/p currency ": " rate)))):main ^:skip-aot myproject.core, but I do not active use AOT myself.:uberjar profile in project.clj has :aot :allException in thread "main" Syntax error macroexpanding at (closure.clj:77:5). at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1750) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3713) at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457) at clojure.lang.Compiler.eval(Compiler.java:7199) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:551) at shadow.build.js_support$eval18536$loading__6789__auto____18537.invoke(js_support.clj:1) at shadow.build.js_support$eval18536.invokeStatic(js_support.clj:1) at shadow.build.js_support$eval18536.invoke(js_support.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:619) at shadow.build.resolve$eval16456$loading__6789__auto____16457.invoke(resolve.clj:1) at shadow.build.resolve$eval16456.invokeStatic(resolve.clj:1) at shadow.build.resolve$eval16456.invoke(resolve.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:2793) at shadow.build.api$eval16448$loading__6789__auto____16449.invoke(api.clj:1) at shadow.build.api$eval16448.invokeStatic(api.clj:1) at shadow.build.api$eval16448.invoke(api.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:3659) at shadow.build$eval16080$loading__6789__auto____16081.invoke(build.clj:1) at shadow.build$eval16080.invokeStatic(build.clj:1) at shadow.build$eval16080.invoke(build.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:3204) at shadow.cljs.devtools.api$eval7525$loading__6789__auto____7526.invoke(api.clj:1) at shadow.cljs.devtools.api$eval7525.invokeStatic(api.clj:1) at shadow.cljs.devtools.api$eval7525.invoke(api.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:1289) at user$eval140$loading__6789__auto____141.invoke(user.clj:1) at user$eval140.invokeStatic(user.clj:1) at user$eval140.invoke(user.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:368) at clojure.lang.RT.maybeLoadResourceScript(RT.java:364) at clojure.lang.RT.doInit(RT.java:486) at clojure.lang.RT.init(RT.java:467) at clojure.main.main(main.java:38) Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Streams at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:259) at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:154) at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:146) at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:414) at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:178) at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method) at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160) at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300) at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newMethodAccessor(MethodHandleAccessorFactory.java:71) at java.base/jdk.internal.reflect.ReflectionFactory.newMethodAccessor(ReflectionFactory.java:159) at java.base/java.lang.reflect.Method.acquireMethodAccessor(Method.java:720) at java.base/java.lang.reflect.Method.invoke(Method.java:575) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167) at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1743) ... 178 more Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Streams at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 192 more
clj -StreeX and :superseded, shadow-cljs is not doing this. so it must be your deps.edn file. com.google.guava/guava 31.1-android :newer-version`
luminus-transit/luminus-transit {:mvn/version "0.1.5" :exclusions [com.cognitect/transit-clj]}:devtools {:after-load kit.net.core/mount-root
:devtools {:watch-dir "resources/public"
:watch-path "/"}}:devtools {:after-load kit.net.core/mount-root
:watch-dir "resources/public"}:injections in ~/.shadow-cljs/config.edn like we can do in ~/lein/profiles.clj?:injections is a leiningen thing, so it is not supported no. you can of course just use leiningen, and use all the features it has:injections i can require a namespace in leiningen. I wanted to replicate that in shadow-cljs.:injections even does, so please explain. I only know that it exists:init-ns 😅:init-ns?#?(:clj (do (intern 'clojure.core (with-meta 'defn* (meta #'defn*)) #'defn*)
(intern 'clojure.core (with-meta '*fn (meta #'*fn)) #'*fn)
(intern 'clojure.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
(intern 'clojure.core (with-meta '*let (meta #'*let)) #'*let)
(try
(intern 'cljs.core (with-meta 'defn* (meta #'defn*)) #'defn*)
(intern 'cljs.core (with-meta '*fn (meta #'*fn)) #'*fn)
(intern 'cljs.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
(intern 'cljs.core (with-meta '*let (meta #'*let)) #'*let)
(catch Exception _))))
if I require it in the :injections of profiles.clj the macros get interned when lein starts up. I wanted to do something similar with shadow-cljs.user.clj work as well? that gets loaded unconditionally in CLJ on startup?user.clj as a classpath rootsrc/dev/user.clj(ns user ...) with whatever require you want~/.shadow-cljs/config.edn(:require [a.b
[c.d]
[e.f]])
:content "" ? this will emit css content: ; which seems to be invalid. the "correct" way to write it in shadow-css would be :content "\"\"" but this is too easy to forget.0.4.2 done"dependencies": {
"pgsql-parser": "^13.4.0",
requiring it:
(:require ["pgsql-parser" :as pgsql]but when I go to build my own node lib I get:
Uncaught Error: Cannot find module 'pgsql_parser'
goog.provide("shadow.js.shim.module$pgsql_parser");
goog.provide("module$shadow_js_shim_module$pgsql_parser");
shadow.js.shim.module$pgsql_parser = require("pgsql_parser");
module$shadow_js_shim_module$pgsql_parser.default = shadow.js.shim.module$pgsql_parser;shadow.js.shim.module$pgsql_parser = require("pgsql-parser");- to _ for JS packages. I cannot reproduce it locally either? which shadow-cljs version do you use?[pgsql_parser :as pgsql] or [pgsql-parser :as pgsql] require somewhere else in your code?:node-script and :node-library. both totally fine:advanced is the only thing doing the DCE, so no there is no alternative(set! js/Foo bar) and getting a warning `
constant Foo assigned a value more than once. Original definition at externs.shadow.js:4` what's the right thing to do here?
set! if you want to export a global? use (js/goog.exportSymbol "Foo" bar) insteadIllegalArgumentException: No matching method legacySetOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) shadow.build.closure/set-options (closure.clj:166) shadow.build.closure/set-options (closure.clj:122) shadow.build.closure/convert-goog* (closure.clj:2295) shadow.build.closure/convert-goog* (closure.clj:2260) shadow.build.closure/convert-goog (closure.clj:2439) shadow.build.closure/convert-goog (closure.clj:2389) shadow.build.compiler/maybe-closure-convert (compiler.clj:1237) shadow.build.compiler/maybe-closure-convert (compiler.clj:1230) shadow.build.compiler/compile-all (compiler.clj:1472) shadow.build.compiler/compile-all (compiler.clj:1349) shadow.build.api/compile-sources (api.clj:261) shadow.build.api/compile-sources (api.clj:253) shadow.build/compile (build.clj:512) shadow.build/compile (build.clj:493) shadow.cljs.devtools.api/compile* (api.clj:296) shadow.cljs.devtools.api/compile* (api.clj:292) shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34) shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25) shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49) shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38) shadow.cljs.devtools.cli-actual/main/body-fn--17900--auto----18609 (cli_actual.clj:166) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132) clojure.core/apply (core.clj:671) clojure.core/apply (core.clj:662) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:667) clojure.core/apply (core.clj:662) shadow.cljs.devtools.cli/-main (cli.clj:75) shadow.cljs.devtools.cli/-main (cli.clj:67) clojure.lang.Var.invoke (Var.java:388) user/eval140 (form-init17017545089428182543.clj:1) user/eval140 (form-init17017545089428182543.clj:1) clojure.lang.Compiler.eval (Compiler.java:7194) clojure.lang.Compiler.eval (Compiler.java:7184) clojure.lang.Compiler.load (Compiler.java:7653) clojure.lang.Compiler.loadFile (Compiler.java:7591) clojure.main/load-script (main.clj:475) clojure.main/init-opt (main.clj:477) clojure.main/init-opt (main.clj:477) clojure.main/initialize (main.clj:508) clojure.main/null-opt (main.clj:542) clojure.main/null-opt (main.clj:539) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)no other changes made, and reverting “fixes” the issue… I tried searching here but didn’t see any mention of this
clojure -X shadow-cljs/release ?clj -M -m shadow.cljs.devtools.cli release app:release doesn't support {:optimizations :none}?
In case of node-script, I imagine it might make sense to avoid any code size optimization (ie skip the Closure compiler), but still strip out all the development related code.:compile is:simple:compile still has all the debug loader mechanisms and stuff and just is not a release build by any meanswatch injects thosecompile does notgoog.require and goog.provide callsrelease will remove those and also collapse the many input files into the configured output file(s):none as it never runs the closure optimizationsrelease will ALWAYS optimize, therefore it makes no sense to allow :none herecompile?--pseudo-names I guess. that gives sort of legible names for :advanced output, but still source maps are the solution here:simple is just as readable as :none is:compiler-options {:source-map true}:devtools {:ignore-warnings true} in the build config, but fixing warnings should be the first choicelein shadow release app --config-merge '{my.ns/HOST ""}'
(shadow/release :app {:closure-defines {'my.ns/HOST ""}})
I'm seeing the first one work, but the second doesn't.(shadow/release :app {:config-merge [{:closure-defines {'my.ns/HOST ""}}]})shadow-cljs version. The command does a lot of things to optimize the user experience (e.g. faster startup) which are not done by other tools. You’ll also save yourself a lot of headaches dealing with dependency conflicts and other related errors.
is this still strong advice? just curious because I use deps.edn for almost everything these days and am wondering what I am missing out on. (I guess mainly fast startup? I haven’t experienced much in the way of dependency conflicts)shadow-cljs command specificallyshadow-cljs watch app vs clj -M -m shadow.cljs.devtools.cli watch appshadow-cljs.edn as it defaults to using the AOT package by defaultthheller/shadow-cljs to thheller/shadow-cljs$aot to get the samenpx shadow-cljs watch frontendAnd when I save a file(views/app), changes don't affect the web page on reload And every time when I change something I need to restart the server to see the changes Here's my core.cljs
(ns frontend.core
(:require [reagent.core :as r]
[reagent.dom :as rdom]
[frontend.views :as views]))
(defn ^:dev/after-load start
[]
(rdom/render [views/app]
(.getElementById js/document "app")))
(defn ^:export main
[]
(start))
How can I fix it?:js-options {:resolve when i know they're not needed by the build? Since the closure compiler/shadow doesn't exclude them via DCEns-aliases e.g. https://github.com/dvingo/fulcro-release-build-incl-pprint/blob/main/shadow-cljs.edn:preloads:js-options {:resolve {"slate" {:target :global :global "window"}
"slate-react" {:target :global :global "window"}
"slate-history" {:target :global :global "window"}}}
With ns-aliases, I still have to define things within the noop ns"window" because target is browser and it won't error<script> tags?:ns form:resolve {"slate" false} to not include it at all, but yeah its better to organize the namespaces in a way they don't get included in the first place(defn interop-wrapper-fn [^js js-obj] (.interopCall js-obj)) (defn some-fn [^js js-obj] (.-js-attr (interop-wrapper-fn js-obj)))I would kind of expect that placing a type-hint on the return value of the interop-wrapper-fn as below would solve the issue, but it doesn't.
(defn interop-wrapper-fn ^js [^js js-obj] (.interopCall js-obj))Ofcourse placing the typehint in the some-fn as below does work but it would be great to solve this centrally. Besides i'm curious about the reason why the method above doesn't work?
(defn some-fn [^js js-obj] (.-js-attr ^js (interop-wrapper-fn js-obj)))
2.20.11 of shadow-cljs , I'm having problems to use build.clj and uber .2.20.10 and the problem gone.Execution error (IllegalArgumentException) at clojure.tools.build.tasks.uber/explode (uber.clj:152). / is not a relative path
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis
:exclude ["LICENSE"]
:main 'backend.application
:manifest {"Git-Revision" (str/trim-newline (:out (shell/sh "git" "rev-parse" "HEAD")))
"Git-Tags" (->> (:out (shell/sh "git" "tag" "--points-at" "HEAD"))
(str/split-lines)
(str/join " "))
"Build-Time" (.format (java.time.ZonedDateTime/now) (java.time.format.DateTimeFormatter/ISO_DATE_TIME))}})(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file "target/app.jar")shadow-cljs , but when I use 2.20.11it gives that erroruberjar process, I'm only referencing that in version 2.20.11 the problem shows up and I'm posting here the problem. When I use version 2.20.10 the problem is not happening.2.20.11-12only added since the closure-compiler didn't properly declare it itself. this is now fixed, so this is no longer needed.
[com.google.guava/guava "31.0.1-jre"] to your own deps if that fixes anything31.0.1-jre did not work to me:deps trueshadow-cljs.edn to be :deps {:aliases [:cljs]}thheller/shadow-cljs dependency from the main deps to a :cljs alias:alias worked. Thank yourequire-macros instead of :require for cljs.test in the test namespace. This was just a really weird interaction that took way too long to debug 😄@material-ui/.
Both of these items work just fine in :require:
["@material-ui/core/Button" :default Button] ["@material-ui/core/Button$default" :as Button]But if I replace
Button with Box, only the first import will work. Or rather, the component itself will work. The second import will produce cljs.core/Box instead of that MUI Box.["@material-ui/core/Box" :default Box] then Box becomes what I expect it to be.
If I import ["@material-ui/core/Box$default" :as Box] then Box is cljs.core/Box.Box to :refer-clojure :exclude seems to fix it. But there's also no warning about Box shadowing if I don't do that.["@material-ui/core/Box$default" :as Box] is completely ignored because there's already cljs.core/Box.
Still weird though that there's no warning for ["@material-ui/core/Box" :default Box] even though it properly shadows cljs.core/Box.:as alias are checked "too late"npx shadow-cljs watch build-a build-bnpx shadow-cljs server and then control/toggle the builds via the http://localhost:9630 web ui:compiler-options
{:output-feature-set :es2020
:output-wrapper false
:warnings {:fn-deprecated false}}
:release
{:closure-defines {goog.DEBUG false
goog.debug.LOGGING_ENABLED true}
:compiler-options
{:fn-invoke-direct true
:optimizations #shadow/env ["PENPOT_BUILD_OPTIMIZATIONS" :as :keyword :default :advanced]
:source-map true
:elide-asserts true
:anon-fn-naming-policy :off
:source-map-detail-level :all}}}
but the *assert* is still true
(we have released some "in development" code (new features) to production build because of this hehehe)*assert*?:elide-asserts truerelease build*assert* mean to you?*assert* value to be false on production builds, and I think it worked in this manner for some timebinding. so it really really depends on when and where you are looking at it*assert* has value true on release builds*assert* is a CLJ runtime binding, so it only works in macrosfalse on release builds, thats it:elide-asserts on cljs code(when *assert* to (when ^boolean js/goog.DEBUG*assert* assumptiongoog-define*assert*, It just worried me a bit because when we writted this code and other similar one, because it worked on first time, but I don't know why. In any case it is not shadow faultcljs-http I am getting this message about dependency conflict. Is there any way to resolve them? I used to handle this type of conflict in lein on backend but I am still a newbie on frontend (shadow).
[:frontend] Build completed. (232 files, 133 compiled, 2 warnings, 0.84s) ------ WARNING #1 - :redef ----------------------------------------------------- Resource: no/en/core.cljc:131:1 parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long -------------------------------------------------------------------------------- ------ WARNING #2 - :redef ----------------------------------------------------- Resource: no/en/core.cljc:136:1 parse-double already refers to: cljs.core/parse-double being replaced by: no.en.core/parse-double --------------------------------------------------------------------------------
parse-long and parse-double to exclude those with (:refer-clojure :exclude [parse-long parse-double])No available JS runtime. See
cljs-http dep?goog-define to conditionally require or not require some npm dep?["@cortex-js/compute-engine" :refer [ComputeEngine]]from require… and then ALSO strip the code in the namespace that uses
ComputeEngine… should I remove it from the namespace block and do a manual require?(when COMPUTE_ENGINE (require '["@cortex-js/compute-engine" :refer [ComputeEngine]]))Then this later fails:
(when COMPUTE_ENGINE
(def engine
(ComputeEngine.)))
[:clerk] Build failure: ------ ERROR ------------------------------------------------------------------- File: /Users/sritchie/code/clj/mathlive.cljs/src/mathlive/core.cljs:95:5 -------------------------------------------------------------------------------- 92 | 93 | (when COMPUTE_ENGINE 94 | (def engine 95 | (ComputeEngine.))) -----------^-------------------------------------------------------------------- null AssertionError: Assert failed: (symbol? module)
shadow.loader/load I get shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.:builds
{:main
{:target :browser
:output-dir "resources/public/cljs-out"
:asset-path "/app"
:build-hooks
[(shadow.cljs.build-report/hook
{:output-to "builds/report.html"})]
:modules
{:base {:entries []}
:main {:entries [myproject.web-app.main]
:depends-on #{:base}}
:pdf-viewer {:entries [myproject.web-app.pdf-viewer]
:depends-on #{:base}}}
}}}:main is all loaded, and then when I do any load, for example (shadow.loader/with-module "pdf-viewer" #(js/alert "LOADED")) I get the:
shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.
goog.global.shadow$modules is defined. In my browser session it is not defined>> goog.global.shadow$modules undefined
:module-loader true in the build config2.20.12 the basic http server doesn’t serve the index.html from /resources/public when given :root "resources/public" but the version 2.19.2 does. Is there some known configuration change that’s happened or is this a regression?2.19.2:<the-port> and it doesn't serve resources/public/index.html?:handler as well. since that didn't previously get called for those files, but now isshadow-cljs.edn? Thanks:maven {:local-repo "foo"}npx shadow-cljs run shadow.nrepl-debug 6001 6000target/nrepl-debug dirclj -M -m shadow.nrepl-debug 6001 600 (with shadow-cljs as added dependency)lein run -m shadow.nrepl-debug ... (same)nil from a sub in release, but it works fine in watch mode.shadow.module.main.append.js:4 An error occurred when calling (centriq-web.main/init!) eval @ shadow.module.main.append.js:4 goog.globalEval @ main.js:472 env.evalLoad @ main.js:1534 (anonymous) @ main.js:2253and the ns in question looks like this:
(ns centriq-web.main
(:require [centriq-web.admin :refer [admin-component]]
[reagent.dom :as dom]))
(defn init! []
(dom/render [admin-component] (.getElementById js/document "app")))
And as you might imagine the shadow cljs uses that init! function to as the init-fn
:builds
{:app {:target :browser
:compiler-options {:externs ["datascript/externs.js"]}
:modules {:main {:init-fn centriq-web.main/init!}}}}
The if i follow the error to the shadow.module.main.append file i don't learn much. MY two theories are that
1. this error comes from my not properly configuring shadow. e.g i forgot to add some build configuration or maybe a hook or annoate the init! function with some meta data.
2. this error is a catch all and the real issue is surfaced else where in the console log.:npm-info has a funny :package-id and empty :package-name and :version for some files.@mui/x-data-grid contains separate package.json under components/ folder so I think that will be picked up by read-package-jsoncomponents/ are still grouped under the real npm package{:npm-info {:package-id "/home/juho/Work/foo/bar/frontend/node_modules/@mui/x-data-grid/"name" if there isn't oneshadow.build.npm but as far as I understand, it is finding the closest package.json on purpose, so it doesn't seem to be trivial to change this. Perhaps there should be separate info for "real" package.json for the files that are under these nearly empty package.json files, and then build report could use that information.:target :browser generates the manifest. the other targets don't need it(defn init!
[]
(f/clear-subscription-cache!)
(shadow.loader/load "debug") ; Must happen here
(some->> "container"
(.getElementById js/document)
(dom/render [ui/app])))
However, it seems that with the code above the debug module is actually being executed after the dom/render. I have the following in my shadow config:
{:module-loader true
:modules {:main {:init-fn app/init!}
:debug {:depends-on #{:main}
:entries [app.debug.loader]}}}
Are my expectations wrong that the module would be loaded synchronously at (shadow.loader/load "debug")?{:module-loader true
:modules {:main {:entries [app.debug.loader]
:init-fn app/init!}}}:advanced and likely make your build much larger even in the :main moduleapp/init! one with the debug line and one without?{:modules {:main {:init-fn app/init!}}
:dev {:modules {:main {:entries [app.debug.loader]}}}}:app build? How do you mean "one build".
A little more detail on what I'm trying accomplish: I'm putting together a little OSS lib that has both domain features and debug features. In an ideal world, a user would use the domain features as normal, and where necessary include a preloads namespace for the debug module. However, the use of re-frame f/clear-subscription-cache! introduces imperative logic around instantiated subscriptions in the debug module. I can't just dump the debug module in a preload namespace because the debug module has to be loaded after the (f/clear-subscription-cache!), but ideally before the render. I'm not really sure I see how to accomplish this imperatively without dynamic module loading.
I guess a solution where the user defines two builds, with duplicated init methods one with and without the debug loading could work. But I've been trying to identify the approach that would be easiest to use as a library, and I'm not sure I've found it yet.shadow-cljs works?
I've got it setup in my user.clj to require shadow in the form of [shadow.cljs.devtools.api :as shadow] so I can then call (shadow/watch :app) and (shadow/browser-repl).
However just trying to start the repl blows up. Commenting out the require seems to work and then sending the form to my repl does this:
Connecting to local nREPL server... Clojure 1.11.1 nREPL server started on port 63444 on host 127.0.0.1 - (ns user (:require [shadow.cljs.devtools.api :as shadow])) Execution error (NoSuchMethodError) at com.google.javascript.jscomp.deps.ModuleLoader/createRootPaths (ModuleLoader.java:257). 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'I'm using
[thheller/shadow-cljs "2.20.13"] via lein.*e
=>
#error{:cause "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'",
:via [{:type clojure.lang.Compiler$CompilerException,
:message "Syntax error macroexpanding at (closure.clj:77:5).",
:data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"},
:at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1750]}
{:type java.lang.NoSuchMethodError,
:message "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'",
:at [com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]}],
:trace [[com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 147]
[com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 48]
[com.google.javascript.jscomp.deps.ModuleLoader$Builder build "ModuleLoader.java" 139]
[com.google.javascript.jscomp.deps.ModuleLoader <clinit> "ModuleLoader.java" 408]
[com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 182]
[jdk.internal.misc.Unsafe ensureClassInitialized0 "Unsafe.java" -2]
[jdk.internal.misc.Unsafe ensureClassInitialized "Unsafe.java" 1160]
[jdk.internal.reflect.MethodHandleAccessorFactory
ensureClassInitialized
"MethodHandleAccessorFactory.java"
300]
[jdk.internal.reflect.MethodHandleAccessorFactory
newMethodAccessor
"MethodHandleAccessorFactory.java"
71]
[jdk.internal.reflect.ReflectionFactory newMethodAccessor "ReflectionFactory.java" 159]
[java.lang.reflect.Method acquireMethodAccessor "Method.java" 720]
[java.lang.reflect.Method invoke "Method.java" 575]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1743]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3713]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7199]
[clojure.lang.Compiler load "Compiler.java" 7653]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6908 invoke "core.clj" 6161]
[clojure.core$load invokeStatic "core.clj" 6160]
[clojure.core$load doInvoke "core.clj" 6144]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5933]
[clojure.core$load_one invoke "core.clj" 5928]
[clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
[clojure.core$load_lib invokeStatic "core.clj" 5974]
[clojure.core$load_lib doInvoke "core.clj" 5953]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$load_libs invokeStatic "core.clj" 6016]
[clojure.core$load_libs doInvoke "core.clj" 6000]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$require invokeStatic "core.clj" 6038]
[shadow.build.js_support$eval5552$loading__6789__auto____5553 invoke "js_support.clj" 1]
[shadow.build.js_support$eval5552 invokeStatic "js_support.clj" 1]
[shadow.build.js_support$eval5552 invoke "js_support.clj" 1]lein deps :tree output[com.google.guava/guava "16.0.1"][com.google.guava/guava "31.1-jre"](shadow/watch :app) Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:10). shadow-cljs has not been started yet! In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it. If you have a shadow-cljs server or watch running then you are not connected to that process.But I have it running in a separate terminal.
.shadow-cljs folder(shadow.cljs.devtools.api/watch :app)
Which normally just says the watch is running. So I can confirm that the server REPL is seeing the same stuff that the watch command I'm running via npx shadow-cljs watch app is seeing.shadow-cljs has not been started yet! you are not connected to a running shadow-cljsnpx shadow-cljs watch app
2. Start the lein repl via cursive and require [shadow.cljs.devtools.api :as shadow]
3. Confirm the connection via (shadow/watch :app)
4. Start a browser repl with (shadow/browser-repl)
The problem is that if I don't do it this way, I don't get clojurescript symbol import.
Checking the embedded link you sharednpx shadow-cljs watch appstart! described in the docsnpx shadow-cljs watch app you don't need an extra (shadow/watch :app) since that is redundant(require '[shadow.cljs.devtools.server]) => nil (shadow.cljs.devtools.server/start!) Execution error (ExceptionInfo) at shadow.cljs.devtools.server/check-for-other-instance! (server.clj:412). shadow-cljs already running in project on . Use or terminate it before starting another one.So it can detect it, but not connect to it?
=> :shadow.cljs.devtools.server/started (shadow/watch :app) [:app] Configuring build. [:app] Compiling ... [:app] Build failure: IllegalArgumentException: No matching method legacySetOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) shadow.build.closure/set-options (closure.clj:166) shadow.build.closure/convert-goog* (closure.clj:2298) shadow.build.closure/convert-goog (closure.clj:2445) shadow.build.closure/convert-goog (closure.clj:2396) shadow.build.compiler/maybe-closure-convert (compiler.clj:1241) shadow.build.compiler/compile-all (compiler.clj:1475) shadow.build.api/compile-sources (api.clj:253) shadow.build/compile (build.clj:493) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:360) shadow.cljs.devtools.server.worker.impl/eval16926/fn--16928 (impl.clj:445) clojure.lang.MultiFn.invoke (MultiFn.java:234) shadow.cljs.devtools.server.util/server-thread/fn--16684/fn--16685/fn--16693 (util.clj:283) shadow.cljs.devtools.server.util/server-thread/fn--16684/fn--16685 (util.clj:282) shadow.cljs.devtools.server.util/server-thread/fn--16684 (util.clj:255) java.lang.Thread.run (Thread.java:1589)Thanks for your help =)... I'll try and see if I can re-engineer this to work again, the split workflow was helpful as I could keep the client-side / server side deps separate, whereas now I would need to co-mingle them. The biggest issue is no longer having easy access to the browser repl, though I can just use a remote repl connection to use that, so perhaps it's fine 😃...
shadow-cljs command doeshighlight.js and has it added as a normal dependency in my package.json file, instead of as a dev dependency. I want to avoid unnecessarily packing libraries into production buildsjs/document and of course ClojureScript libraries, but not node modulesexport class Test {
static foo = "bar";
static staticMethod() {
alert(this === Test);
}
}
But I'm wondering why because
> The Closure Compiler is used for processing all JavaScript found on the classpath using its ECMASCRIPT_NEXT language setting.
and the https://github.com/google/closure-compiler/issues/2731? I just want to make sure I'll not encounter issues if I go down this path.modern/defclass macro doesn't support static fields as well, correct? So would use something like (set! (.-foo Class) "bar")?shadow-cljs release compiles this without warnings
/**
* @nocollapse
*/
export class Test {
static foo = "bar";
static staticMethod() {
alert(this === Test);
}
baz = "blah";
}
And this works
(js/console.log (.staticMethod Test) (.-foo Test) (.-baz (new Test)))Is that a sufficient test? I still think this must be wrong somehow 🙂
:advanced@nocollapse helps against entire removal@nocollapse was to remove a warning. Actually, without it there was an error at runtime.release and it still seems to work. I guess I'll proceed 🙂Errors encountered while trying to parse file
/Users/abcd/projects/abcd/editor/node_modules/@chakra-ui/utils/dist/index.cjs.js
{:line 999, :column 10, :message "'(' expected"}
When I inspect the mentioned file I see a normal JS class:
// src/pan-event.ts
var PanSession = class {
history = []; // this is line 999 <------------------------------------
startEvent = null;
lastEvent = null;
lastEventInfo = null;
handlers = {};
removeListeners = noop;
threshold = 3;
win;
constructor(event, handlers, threshold) {
this.win = getEventWindow(event);
if (isMultiTouchEvent(event))
I don’t know why this is not compiling. Is this not supported or do I missed some configuration?:js-options
{:resolve {"@chakra-ui/react" {:target :global
:global "what-to-add-here"}}}
What would I provide for the :global value?2.20.14:build-options
{:cache-level :off}
import Split from '@uiw/react-split'; -> ["@uiw/react-split$default" :as Split] ?but this
Splitis returning nil.["@uiw/react-split" :as Split]:esm target with runtime :react-native ?
My understanding was that traditional :react-native target would let metro process deps, but seems that the runtime does not behave that way
I was seeing if it was possible to use shadow-cljs with expo-router, which requires integrating cljs into file-system routing which is why I’m using esm targetjs-provider does work, resolving dependency issue
but now when using import I’m seeing
dist/cljs-runtime/cljs_env.js: dist/cljs-runtime/cljs_env.js:Invalid call at line 1394: import(x.startsWith("./") ? "." + x : x)
full line referenced above
globalThis.shadow_esm_import = function(x) { return import(x.startsWith("./") ? "." + x : x); }
not sure why it’s an invalid callesm target do you think it’s more feasible?
I was excited about Cherry providing better interop with JS ecosystem, but also recently learned about esm target in shadow-cljs, which servers similar purpose. One distinction may be that in Cherry cljs logic is imported in shared in npm package, but other than I imagine behavior is similarthheller/shadow-cljs {:mvn/version "2.20.14"}
deps.edn is used for dependencies and add nrepl middleware (#portal in this case). Failing so far, with a message nREPL middleware: shadow.cljs.devtools.cli has no namespace. Details in 🧵deps.edn looks like so:
{:paths ["src" "test" "env/dev"]
:deps {binaryage/devtools {:mvn/version "1.0.6"}
djblue/portal {:mvn/version "0.35.0"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
reagent/reagent {:mvn/version "1.1.1"}
thheller/shadow-cljs {:mvn/version "2.20.14"}}
:aliases {:portal {:extra-deps
{djblue/portal {:mvn/version "0.35.0"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware"
"[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware,portal.nrepl/wrap-portal]"]}}}
And shadow-cljs.edn:
{:deps {:aliases [:portal]}
:dev-http
{8020 "public"}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules {:main {:init-fn main.core/init}}
:build-hooks [(portal.shadow.remote/hook)]
:devtools {:preloads [devtools.preload
portal.setup]}}
:test {:target :node-test
:autorun true
:output-to "target/node-test/tests.js"
:ns-regexp ".*-test$"
:build-hooks [(portal.shadow.remote/hook)]
:devtools {:preloads [devtools.preload
portal.setup]}}}}
Running this:
$ npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :app :test shadow-cljs - config: /Users/pez/Projects/shadow-portal/shadow-cljs.edn shadow-cljs - starting via "clojure" nREPL middleware: shadow.cljs.devtools.cli has no namespace Jack-in process exited. Status: 2
:main-opts in an alias used by shadow-cljsclj -A:portalshadow-cljs.edn:nrepl {:middleware [portal.nrepl/wrap-portal]}clojure.npx shadow-cljs ...clojure. I don't know why this works differently, just that it does.
As for the assumptions. Calva does actually connect to the nREPL server started by shadow-cljs if I choose the shadow-cljs jack-in option. (I don't know why I thought differently.)
So, in summary. Moving the portal nrepl middleware config to shadow-cljs.edn made things work exactly as I want them to. With the test runner output in the terminal and all. 🎉
Thanks again! I'll try to encode these learnings in an example project. And I will update the Calva docs. I would have had helped from that this time. 😃clojure. And also will make it start an nREPL server. I can't use that one with Portal nREPL middleware for reasons you have helped me understand here. But that's fine, since Calva will connect to the nREPL server started by shadow-cljs. Does this make sense?Exception in thread "main" Syntax error compiling at (shadow/build/closure.clj:80:3). Caused by: java.lang.RuntimeException: Unable to find static field: ECMASCRIPT_NEXT_IN in class com.google.javascript.jscomp.CompilerOptions$LanguageModeHere is my setup;
.... [thheller/shadow-cljs "2.20.14" :exclusions [nrepl commons-codec com.cognitect/transit-clj org.clojure/tools.reader]] [com.google.javascript/closure-compiler-unshaded "v20221102"] [org.clojure/clojurescript "1.11.60" :exclusions [org.clojure/tools.reader]] ....
(:require ') and ( "com/google/javascript/jscomp/CompilerOptions.class"):test build? In ^ that ^ project tests are set to :auto-run and that works great. But I can't reach the build via the REPL.:auto-run isn't for CI, is it?:auto-run tests to end up in Portal. I don't strictly need a REPL for that, but that would make it easier to examine the environment. So, then my next question is, can I hope to ba able to add a tap to these test runs?:node-test target this doesn't happen, even though it uses the same port. This is where I lose track of it and was thinking a REPL might help me.goog packages in React Native lately? I'm currently upgrading an application to 0.70.6 and was hit with an error metro trying to resolve ./app/goog.math.long.js – I got around this by patching metro's resolver and made it ./out/goog.math.long.js – but it seems that something is wrong still since it still complains about
ReferenceError: Property 'Long' doesn't exist, js engine: hermes. I'm figuring this out myself but wanted to ask if someone has already been seeing this 🙂
ERROR ReferenceError: Property 'Long' doesn't exist, js engine: hermes
:compiler-options {:output-feature-set :es5} in your build configout previously and it has worked earlier but now it does not.:output-dir:output-dir "out" – now I have :output-dir "app"out => app from relevant places)app so it's not a big deal, just threw me off since this had worked before.:output-dir you tell itout as before, but for some reason metro gets "app" from out of nowhere and tries to resolve from itERROR ReferenceError: Property 'Long' doesn't exist, js engine: hermes
["@mui/material/Box" :default Box] works as expected, but ["@mui/material/Box$default" :as Box] doesn't as any use of Box later will refer to https://cljs.github.io/api/cljs.core/Boxshadow.js.require() calls and then referring to objects with names like modules$node_modules$$DefaultExport$index.default, while the new one will skip the require and refer to shadow.js.shim.module$$DefaultExport$default.
I tried looking at the issues around the time this changed in the docs (Feb 20), but didn't find anything, so I wonder what the implications are. At first I thought that both styles would result in identical code, so I guess the translation is happening at a different place?worker.js:1453 failed to load shadow.module.gamelogic.append.js ReferenceError: shadow is not defined
at eval (shadow.module.gamelogic.append.js:2:1)
at eval (<anonymous>)
at goog.globalEval (robot.js:497:11)
at env.evalLoad (robot.js:1451:12)
at worker.js:1506:12
worker.js is my worker module
gamelogic is a shared module that it depends upo; presumably Ihave forgotton to import something..?:web-worker true in the build config for the worker module?:robot {:entries [foo.robot]
:depends-on #{:gamelogic}
:web-worker true}
}:gamelogic {:entries [foo.encode-board
foo.calc-moves]}shadow.module.gamelogic.append.js
shadow.cljs.devtools.client.env.module_loaded('gamelogic');
:init-fn to let shadow-cljs call a init function for you(defn init [] (do-stuff)) and shadow-cljs call it, instead of just (do-stuff) in an ns somewhere(js/self.addEventListener "message"
(fn [^js evt]
and you are saying that this should be done within an init function?:default true
like this
:main {:entries [foo.main]
:init-fn foo.main/main
:depends-on #{:gamelogic}
:default true}
and clearly it does no do what I expected it to dogamelogic.js:1451 ReferenceError: shadow is not defined
at eval (shadow.module.gamelogic.append.js:2:1)
at eval (<anonymous>)
at goog.globalEval (gamelogic.js:497:11)
at env.evalLoad (gamelogic.js:1559:12)
at gamelogic.js:1615:12[:foo] Build failure:
two modules without deps, please specify which one is the default
{:a :main, :b :robot}
ExceptionInfo: two modules without deps, please specify which one is the default
shadow.build.targets.browser/pick-default-module-from-config/fn--25576 (browser.clj:174)
:default true in the main module then I get a different error
[:foo] Build failure:
no common dependency found for src
{:src [:shadow.build.classpath/resource "goog/base.js"], :deps #{:main :robot}}
ExceptionInfo: no common dependency found for src
shadow.build.modules/compact-build-modules/find-closest-common-dependency--15601:default flag really do?:depends-on. the rest must have it:asset-path is mostly intended for loading JS modules rather than other assets. My project separates cljs source and svg assets in separate folders (src and assets), respectively. Is there some shadow-cljs command to symlink the folder to my asset-path or is there a much better way to do this?
EDIT: For additional context, I am using the default server provided by shadow-cljs. I suppose it wont hurt to finally have a proper server in the front-endpublic folder and access them by pathpublic/img/foo.svg and [:img {:src "/img/foo.svg"}]public typically contained compiled cljs artifacts. But I suppose I can also restructure my project so that I always have a public folder with my assets, then I can simply add public/js to my .gitignorepublic/js is gitignored as well as public/css. the rest is tracked in gitcljs_env.js has all the Google classes and sourcesgarden/garden {:git/url ""
:sha "7a47503d0481382f85b643ae431cefb2ad88ee4c"}
in shadow-cljs.edn dependencies?:js-provider (for pnpm) and thus extend the s.b.resolve/find-resource-for-string* multimethod, https://github.com/thheller/shadow-cljs/issues/670#issuecomment-732788677, how do I do that? Can it be in my own code or do I need to clone shadow-cljs and then somehow use the local, extended version of it? (I guess via direct invocation with clj it would be possible.) Thank you!s.b.resolve/find-resource-for-string* that calls my own resolve-pnpm was correct, and the way to go about it is to use REPL and run shadow build from there.cljc code between the frontend and the backend? Foremost and most important, how do you make a project that has both a normal deps.edn project for backend and a shadow-cljs.edn project for frontend?project.clj and shadow-cljs.edn reside in the root directory, each with the correct src settings. The settings don't overlap much.npx shadow-cljs release app --pseudo-namesrun and clj-run commands?cljs.pprint is only used from a certain module, but stating this in shadow-cljs.edn gives me:
[:main] Build failure:
Module Entry "cljs.pprint" was moved out of module ":scittle.pprint".
It was moved to ":scittle" and used by #{:scittle.pprint :scittle}.
^C%
since shadow itself presumably uses this for dev tooling. It works in the production build though. Any way around this?shadow-cljs.edn to use AWS codeartifact as a repository source. I ran the AWS codeartifact to update my ~/.m2/settings.xml with the tokens to authorize me to Download from codeartifact, but I am getting the error
DependencyResolutionException Failed to collect dependencies at xxx:xxx:jar:a.b.c org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:351) jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke (Method.java:566) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167) clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102) cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:806) cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:707) clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) cemerick.pomegranate.aether/resolve-dependencies (aether.clj:815) Caused by: DependencyCollectionException Failed to collect dependencies at xxx:xxx:jar:a.b.c org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:293) org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:307) jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2) ... AuthorizationException Not authorized , ReasonPhrase:Unauthorized. org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1021) org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:976) org.apache.maven.wagon.StreamWagon.getInputStream (StreamWagon.java:126)But the same works when I use leiningen to download the same dependency from AWS codeartifact.
username and password from ~/.m2/settings.xml that codeartificat generated:target :node-js build? I tried adding the :deps {:aliases [ ... ]} key for that build only, with a deps alias that includes a path with those namespaces but :deps only seems to work on the global level. Any other suggestions?:build-options {:ns-aliases {the.ns.you.dont.want the.replacement}} in the build config:ns-aliases tip, could come in handy in the future. vscode-test exposes a runTests function that launches VS Code. To runTests I provide an argument pointing at a module exporting a run function that is responsible for running the actual tests. I'm using the :node-script target to build a script that both calls runTest and exports a run function from where I am calling cljs.test/run-all-tests. I run into a strange error when the extension has started complaining about swap! not being defined for cljs.core/Atom. Adding the log to a reply....npm run integration-test >So, right before the
SHADOW import error I see println messages from my extension and from shadow, indicating that it starts OK. It all works fine if starting VS Code with this extension installed. I don't understand why this way of starting things would trigger this particular error...[main 2022-12-26T15:54:04.111Z] UtilityProcess<1>: Creating new... don't know what it is creating but the error happens when cljs.core is loaded twice, because the protocol is redefined and then things go weirdrun function in the same module that starts VS Code. I'll try to avoid that and see if it gets me to a new place.release I get rid of the error. Which is fine. However, it doesn't actually run the tests. There is only one in this test run, a failing one, yet:
% npx shadow-cljs release :integration-tests && npm run integration-test shadow-cljs - config: /Users/pez/Projects/joyride/shadow-cljs.edn shadow-cljs - connected to server [:integration-tests] Compiling ... [:integration-tests] Build completed. (53 files, 1 compiled, 0 warnings, 2.65s) >
cljs.test/run-all-tests it reports Testing tests for promesa and all other libraries used which has tests, including my failing test. And still reports that 0 tests and assertions are run. I'll keep digging...async correctly? otherwise the test runner will just exit since it doesn't know that tests are still running:dev/always true in the ns meta will have the same effectcom.rpl.specter. It says com.rpl.specter/select is an undeclared var. A JS symbol com.rpl.specter.select indeed doesn't appear in any of the js/com.rpl.specter* files in the output of the :bootstrap build.
In the source select's a macro https://github.com/redplanetlabs/specter/blob/67e86806020b9d02fbca8cdb1efad3002fc81a32/src/clj/com/rpl/specter.cljc#L347-L351
My :bootstrap build config is:
{:target :bootstrap
:output-dir "public/bootstrap"
:compiler-options {:warnings {:infer false}}
:exclude #{cljs.js}
:entries [cljs.js com.rpl.specter]}
I copied {:warnings {:infer false}} from other examples of self-hosted cljs, without knowing what it does and whether it's necessary.
I didn't find statements that self-hosted cljs doesn't support macros. Should this work? What am I missing?
Thanks!
Addendum: It seems that certain macro syntax isn't supported by the self-hosted clojurescript clojurescript compiler. There's a PR in specter that seems to address this partly. I'll see if that gets me further. https://github.com/redplanetlabs/specter/pull/299macros.cljs, or it written as .cljc with the proper :require-macros for itselfcom.rpl.specter/select macro should appear as com.rpl.specter$macros.select in the JS source, right?
Also, when you say that macros need to be used correctly, one of the things you mean in particular is that wrapping macro definitions in #?(:clj ..)would be wrong. While that works for Clojure and Clojure-hosted ClojureScript, it doesn't work for self-hosted Clojurescript.:clj branches are ignored$macros namespaces. that separation is what I mean by using it correctly. can't put macros in the com.rpl.specter ns directly even though it might appear so*ns* is always null.*ns* is always bound to the current ns when macroexpanding, but not otherwise:asset-path "absolute"? My frontend app works fine with routes like /login, but assets immediately fail to load when I navigate to a route like /app/panel, since the rendered views will look for assets in /app/assets/... instead of /assets/...:asset-path is only used in a few places for JS files, you just specify an absolute path, so :asset-path "/js" or so/.shadow-cljs to get a compilation working, that's a bug, right?
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83eee2f1e8f6f0c3f6e1f6edf7f6b1b1b3b7"}, :content ("[email protected]")}:target :bootstrap) are run through the Clojure compiler during reload when a watch is active for the normal ClojureScript build (`:target :browser`), and then complain about, for example, no such namespace: js. These files work as intended in the self-hosted environment.
Is this intended to work differently? Can I have self-hosted CLJS-only files in my sources that can assume to be run only in a CLJS context?:cljs branches in .cljc filesjs/some.name.space.js and js/some.name.space$macros.js are differentjs/ns) but different internally(macrovich/deftime (defmacro ...)) macros don't make it to the $macros output file for the namespace in my situation currently.
Also I read that defmacro is ignored – or produces no output – when compiled in CLJS, maybe that's one difference?select is undefined in CLJS in a self-hosted environment, I seems clear now why the upstream version behaves like this - it has (defmacro select ...) in #?(:clj. A PR/fork/branch that was reportedly working better has it in (macrovich/deftime ...) instead. However, select still didn't appear in the ...$macro.js output file.
I assumed that that must be correct, but maybe it isn't. Reading https://cljs.github.io/api/cljs.core/defmacro now, that looks helpful.#?(:cljs reader conditionals, correct?#?(:clj with (macrovich/deftime.defmacros` in macrovich/deftime aren't supposed to end up in the JS output?#(:clj ..) hides it from the CLJS macro compilation which will take the :cljs branch. so thats why select is missing, it is never there in the first place(defmacroalias richnav macros/richnav) don't know why this is theremacros/richnav. I never get these aliasing things, so not sure why it has to be in this ns(defmacro deftime
"This block will only be evaluated at the correct time for macro definition, at other times its content
are removed.
For Clojure it always behaves like a `do` block.
For Clojurescript/JVM the block is only visible to Clojure.
For self-hosted Clojurescript the block is only visible when defining macros in the pseudo-namespace."
[& body]
(when #?(:clj (not (:ns &env)) :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))
`(do defmacro s defined in a macrovich/deftime don't appear in JS output produced by a shadow-cljs :bootstrap build.:macros in the config.goog.provide('friday.myns$macros');
console.log("hello from toplevel");
friday.myns$macros.toplevelfunction = (function friday$myns$macros$toplevelfunction(){
return console.log("hello from toplevel function");
});
var ret__5824__auto___14156 = friday.myns$macros.toplevelmacro = (function friday$myns$macros$toplevelmacro(_AMPERSAND_form,_AMPERSAND_env){
console.log("hello from toplevelmacro expansion");
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("js","console.log","js/console.log",-2005248266,null),null,(1),null)),(new cljs.core.List(null,"hello from toplevelmacro result evaluation",null,(1),null)))));
});
(friday.myns$macros.toplevelmacro.cljs$lang$macro = true);
console.log("hello from usetime");
friday.myns$macros.usetimefunction = (function friday$myns$macros$usetimefunction(){
return console.log("hello from usetimefunction");
});
var ret__5824__auto___14160 = friday.myns$macros.usetimemacro = (function friday$myns$macros$usetimemacro(_AMPERSAND_form,_AMPERSAND_env){
console.log("hello from usetimemacro expansion");
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("js","console.log","js/console.log",-2005248266,null),null,(1),null)),(new cljs.core.List(null,"hello from usetimemacro result evaluation",null,(1),null)))));
});
(friday.myns$macros.usetimemacro.cljs$lang$macro = true);
//# sourceMappingURL=friday.myns$macros.js.map*ns* isn't actually bound to the $macros ns? never checked(ns-name *ns*) in all the places and only ever get null or markus.pumpkin, never markus.pumpkin$macros.*ns* is definitely bound to the correct value. most of your additions were incorrect though. I don't understand the problem with deftime either, but I do not see the point anyways so just do not use itfunction $promesa$exec$scheduled_executor$cljs$0core$0IFn$0_invoke$0arity$0variadic$$($p__32931$$) {
var $map__32932__$1$$ = $cljs$core$__destructure_map$$($p__32931$$)
, $parallelism$$ = $cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($map__32932__$1$$, $cljs$cst$172$parallelism$$, 1)
, $factory$jscomp$2$$ = $cljs$core$get$$.$cljs$core$IFn$_invoke$arity$2$($map__32932__$1$$, $cljs$cst$173$factory$$);
if ("undefined" === typeof $promesa$$ || "undefined" === typeof $promesa$exec$$ || "undefined" === typeof $promesa$exec$t_promesa$0exec32933$$) {
$promesa$exec$t_promesa$0exec32933$$ = function($p__32931$jscomp$1$$, $map__32932$jscomp$1$$, $parallelism$jscomp$1$$, $factory$jscomp$3$$, $meta32934$$) {
this.$p__32931$ = $p__32931$jscomp$1$$;
this.$map__32932$ = $map__32932$jscomp$1$$;
this.$parallelism$ = $parallelism$jscomp$1$$;
this.$factory$ = $factory$jscomp$3$$;
this.$meta32934$ = $meta32934$$;
this.$cljs$lang$protocol_mask$partition0$$ = 393216;
this.$cljs$lang$protocol_mask$partition1$$ = 0;
}
,
$promesa$exec$t_promesa$0exec32933$$.prototype.$cljs$core$IWithMeta$_with_meta$arity$2$ = function($_32935$$, $meta32934__$1$$) {
return new $promesa$exec$t_promesa$0exec32933$$(this.$p__32931$,this.$map__32932$,this.$parallelism$,this.$factory$,$meta32934__$1$$);
}
,
$promesa$exec$t_promesa$0exec32933$$.prototype.$cljs$core$IMeta$_meta$arity$1$ = function() {
return this.$meta32934$;
}
,
$promesa$exec$t_promesa$0exec32933$$.prototype.$promesa$protocols$IScheduler$_schedule_BANG_$arity$3$ = $JSCompiler_stubMethod$$(0),
$promesa$exec$t_promesa$0exec32933$$.$cljs$lang$type$ = !0,
$promesa$exec$t_promesa$0exec32933$$.$cljs$lang$ctorStr$ = "promesa.exec/t_promesa$exec32933",
$promesa$exec$t_promesa$0exec32933$$.$cljs$lang$ctorPrWriter$ = function($writer__5331__auto__$jscomp$87$$) {
return $cljs$core$_write$$($writer__5331__auto__$jscomp$87$$, "promesa.exec/t_promesa$exec32933");
}
;
}
return new $promesa$exec$t_promesa$0exec32933$$($p__32931$$,$map__32932__$1$$,$parallelism$$,$factory$jscomp$2$$,$cljs$core$PersistentArrayMap$EMPTY$$);
}
And a code sample form main.js
$promesa$exec$ScheduledTask$$.prototype.$promesa$protocols$ICancellable$_cancel_BANG_$arity$1$ = $JSCompiler_unstubMethod$$(1, function() {
// ...
});
$promesa$exec$t_promesa$0exec32933$$.prototype.$promesa$protocols$IScheduler$_schedule_BANG_$arity$3$ = $JSCompiler_unstubMethod$$(0, function($G__32936__$jscomp$255$$, $ms$jscomp$4$$, $f$jscomp$369$$) {
var $done$$ = $cljs$core$volatile_BANG_$$(!1)
, $tid$$ = setTimeout(function() {
try {
return $f$jscomp$369$$.$cljs$core$IFn$_invoke$arity$0$ ? $f$jscomp$369$$.$cljs$core$IFn$_invoke$arity$0$() : $f$jscomp$369$$();
} finally {
$cljs$core$_vreset_BANG_$$($done$$, !0);
}
}, $ms$jscomp$4$$);
$G__32936__$jscomp$255$$ = {
done: $done$$,
cancelled: !1,
"cancel-fn": function() {
return clearTimeout($tid$$);
}
};
return $promesa$exec$__GT_ScheduledTask$$.$cljs$core$IFn$_invoke$arity$1$ ? $promesa$exec$__GT_ScheduledTask$$.$cljs$core$IFn$_invoke$arity$1$($G__32936__$jscomp$255$$) : $promesa$exec$__GT_ScheduledTask$$($G__32936__$jscomp$255$$);
});
function $cljs$core$persistent_BANG_$$($tcoll$jscomp$14$$) {
/...
where you can see that $promesa$exec$t_promesa$0exec32933$$ is used in main.js, but this one will only be defined if the $promesa$exec$scheduled_executor$cljs$0core$0IFn$0_invoke$0arity$0variadic$$ called. And this function is not called until long after the first browser load+eval
Is this make sense?:compiler-options {:cross-chunk-method-motion false} in the build configClassNotFoundException: com.rpl.specter.Util? Isn't all compilation done by the JS/CLJS implementation of the CLJS compiler?{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1f727e6d746a6c5f6a7d6a716b6a2d2d2f2b"}, :content ("[email protected]")}:bootstrap target:
:bootstrap
{:target :bootstrap
:output-dir "public/bootstrap"
:exclude #{cljs.js}
:entries [cljs.js com.rpl.specter]}Util class are inside a #?(:clj reader conditional:
https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/impl.cljc#L22
and https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/impl.cljc#L91#?(:cljs branches are taken.#?(:cljs branches, correct? All mentions of the helper class are in #?(:clj branches.:cljs branch when compiling for macros. when compiling normally it is taking for :clj branch for the macros, since that runs in clj#?(:cljs branches? Is this an issue that's separate from the deftime question?
About changing or not changing *ns*:
"`macros/deftime` and macros/usetime to clearly demarcate regions of code that should be run in the macro-definition stage or in the macro-usage stage. (In Clojure there's no distinction; in pure Clojurescript it's easy: just wrap the first stage in #?(:clj ...) and the latter one in #?(:cljs ...); in self-hosted Clojurescript it's messy or everything gets evaluated twice; supporting the three at the same time is Macrovich's .)" (from https://github.com/cgrand/macrovich#usage)
I take this to mean that in other self-hosted environments deftime works, so maybe it's a good idea for shadow-cljs to be compatible in that regard to these other self-hosted environments.:bootstrap must compile the namespace twice. the first time it is compiled like regular CLJS, just the normal namespace using CLJ for macro expansion. this will end up loading all the related Java code. on the second pass it is compiled again in macro mode, which is purely CLJS.deftime is related to the *ns* binding, which I guess macrovich expects to be bound to the $macros variant, which is not the case in shadow-cljs and never has been::foo would have unexpected resultsdeftime. it is not needed and doesn't do anything useful here.deftime does. at its current stage it is broken with regards to how shadow-cljs handles it. so its either broken in shadow-cljs or macrovich:bootstrap build, which is producing artifacts that should be consumed by self-hosted ClojureScript?:bootstrap is to *pre-compile* namespaces. this is not something regular CLJS self-hosted does:macro false and :macro true , and read both without taking any CLJ branches? That must result in different analysis results than doing it on the server side with CLJ-hosted CLJS.Util is a problem suddenly? if its only in :clj branches everything is fine and I don't understand the context of the problem:bootstrap target is fine with just compiling cljs.core. there is no need to precompile anything else:entries [cljs.core] in :bootstrap and do the rest yourself:target :bootstrap that tried to do the same thing:bootstrap compiles namespaces in normal mode (i.e. :macro false) with the CLJ ClojureScript compiler. It'll correspondingly compile any required macro namespaces with Clojure and use these to expand macros.
It'll also compile any required namespaces in macro mode with the CLJ ClojureScript compiler, producing JS output. (Here there's no difference between using the CLJ ClojureScript compiler or a JS-hosted CLJS ClojureScript compiler.)
Effectively, if a namespace is required as both a normal and a macro namespace, it'll be compiled three times:
• a) once explicitly by :bootstrap with the CLJ ClojureScript compiler in non-macro mode as ClojureScript to produce output JS and analysis for the browser-side CLJS compiler
• b) once somewhat implicitly by the CLJ ClojureScript compiler with the Clojure compiler in macro mode as Clojure, to do macro expansion for a)
• c) once explicitly by :bootstrap with the CLJ ClojureScript compiler in macro-mode as ClojureScript to produce output JS and analysis for the browser-side CLJS compiler
Is this correct?(require 'that.ns) in CLJ only. the compiler never looks at them.{:entries [cljs.js my.separate]
:macros [my.separate]}
and a file my/separate.cljs:
(ns my.separate (:require-macros [my.separate])) ;; main code omittedand a file
my/separate.clj:
(ns my.separate) ;; macro implementations and supporting code omittedwe're asking the :bootstrap build to prepare everything so that I can require
my.separate:
(ns ... (:require [my.separate]))and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the
my.separate
namespace in non-macro mode. This uses the my/separate.cljs file, taking
#?(:cljs branches. It produces JS output suitable for execution in a JS runtime.
2. During this process, the CLJ ClojureScript compiler requests the
my.separate namespace in macro mode. The file my/separate.clj is provided to
it. It is compiled as Clojure, taking #?(:clj branches. The result is used
for macro expansion in step 1.
3. Step 1 finishes and produces JS output as well as analysis results.
4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate
namespace in macro mode. This uses the my/separate.clj file. It is compiled
as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for
the macro expansion phase of the self-hosted ClojureScript compiler.
my/separate.clj was compiled twice: once as Clojure in macro-mode, and once as
ClojureScript, also in macro-mode.
Here is what happens when combining the non-macro and macro namespaces in one
.cljc-file:
With the following :bootstrap configuration
{:entries [cljs.js my.combined]
:macros [my.combined]}
and a file my/combined.cljc:
(ns my.combined #?(:cljs (:require-macros [my.combined]))) ;; macro implementations and supporting code omitted ;; main code omittedwe're asking the :bootstrap build to prepare everything so that I can require
my.combined:
(ns ... (:require [my.combined]))and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the
my.combined
namespace in non-macro mode. This uses the my/combined.cljc file, taking
#?(:cljs branches. It produces JS output suitable for execution in a JS runtime.
2. During this process, the CLJ ClojureScript compiler requests the
my.combined namespace in macro mode. The file my/combined.cljc is provided to
it. It is compiled as Clojure, taking #?(:clj branches. The result is used
for macro expansion in step 1.
3. Step 1 finishes and produces JS output as well as analysis results.
4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined
namespace in macro mode. This uses the my/combined.cljc file. It is compiled
as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for
the macro expansion phase of the self-hosted ClojureScript compiler.
my/combined.cljc was compiled three times: once as ClojureScript in non-macro
mode, once as Clojure in macro-mode, and once as ClojureScript in macro-mode.
@thheller, is that accurate?require them.#? branches. thats CLJC only{:entries [cljs.js my.separate]
:macros [my.separate]}
and a file my/separate.cljs:
(ns my.separate (:require-macros [my.separate]) ;; main code omittedand a file
my/separate.clj:
(ns my.separate) ;; macro implementations and supporting code omittedwe're asking the :bootstrap build to prepare everything so that I can require
my.separate:
(ns ... (:require [my.separate]))and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build with regards to the
my.separate namespace:
1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate
namespace in non-macro mode. This uses the my/separate.cljs file. It produces
JS output suitable for execution in a JS runtime.
2. During this process, the CLJ ClojureScript compiler requires the
my.separate namespace. The file my/separate.clj is used. It is compiled as
Clojure. The result is used for macro expansion in step 1.
3. Step 1 finishes and produces JS output as well as analysis results.
4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate
namespace in macro mode. This uses the my/separate.clj file. It is compiled
as ClojureScript. It produces JS output suitable for the macro expansion phase
of the self-hosted ClojureScript compiler.
my/separate.clj was compiled twice: once as Clojure (implicitly by requiring
it during CLJS compilation), and once as ClojureScript in macro-mode.
Here is what happens when combining the non-macro and macro namespaces in one
.cljc-file:
With the following :bootstrap configuration:
{:entries [cljs.js my.combined]
:macros [my.combined]}
and a file my/combined.cljc:
(ns my.combined #?(:cljs (:require-macros [my.combined]))) ;; macro implementations and supporting code omitted ;; main code omittedwe're asking the :bootstrap build to prepare everything so that I can require
my.combined:
(ns ... (:require [my.combined]))Effectively, the following things will happen during the :bootstrap build with regards to the
my.combined namespace:
1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined
namespace in non-macro mode. This uses the my/combined.cljc file, taking
#?(:cljs branches. It produces JS output suitable for execution in a JS runtime.
2. During this process, the CLJ ClojureScript compiler requires the
my.combined namespace. The file my/combined.cljc is used. It is compiled as
Clojure, taking #?(:clj branches. The result is used for macro expansion in
step 1.
3. Step 1 finishes and produces JS output as well as analysis results.
4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined
namespace in macro mode. This uses the my/combined.cljc file. It is compiled
as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for
the macro expansion phase of the self-hosted ClojureScript compiler.
my/combined.cljc was compiled three times: once as ClojureScript in non-macro
mode, once as Clojure (again, implicitly by requiring it during CLJS
compilation), and once as ClojureScript in macro-mode.
And two observations:
• if you need differing macro implementations for CLJ and CLJS, there's no way around .cljc files, correct?
• In the first situation, a .clj file is compiled as a ClojureScript file, producing JS output, correct?
@thheller, is that all accurate?:macros [my.combined] in the build config. it is infered that this is require'd via the :require-macros. It is only needed for namespaces that are not otherwise required<p!. I require core.async like this:
[cljs.core.async :as async :refer [go >! <!]]
[cljs.core.async.interop :refer [<p!]]
and work with promises like this (heavily abridged)
(let [p+ (.readFile ^js (.-promises ^js FS) dict-path)]
(try (go (let [p (<!p p+)] ...))
(catch default e (println e)))
which prints the error
TypeError: aa.setTimeout is not a functionso it feels like I'm missing externs for core.async? any ideas? /cc @thheller
setTimeout is used? and which build :target is this?setTimeout availablenpx shadow-cljs release app --pseudo-names to figure out what the aa is supposed to be:browser build is fine:target :nodejs doesn't exist in shadow-cljs:node-script yes(defmethod integrant/init-key :app.system/x [_ system]
(let [{:keys [App]} system]
(.setAsDefaultProtocolClient App "foo")cljs.analyzer.api/emit and cljs.analyzer.api/analyze and with what state/env args so it knows symbols from my running shadow build?shadow.cljs.devtools.api/cljs-eval but I only want the js code, not the result):repl-state key in the build state, which contains a bunch of :repl-actionsrepl/process-input can be eval'dcljs.analyzer.api/analyze compatible state/env available either with shadow, is that right?watch and expect it to workWARN:
shadow-cljs - failed to load module$node_modules$$openfin$excel$openfin_excel
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ app.excel.js:2
goog.globalEval @ main.js:566
env.evalLoad @ main.js:1659
(anonymous) @ main.js:2574
main.js:1661 An error occurred when loading app.excel.js
env.evalLoad @ main.js:1661
(anonymous) @ main.js:2574
ReferenceError: fin is not defined
at shadow$provide.module$node_modules$$openfin$excel$openfin_excel (:3900/js/cljs-runtime/module$node_modules$$openfin$excel$openfin_excel.js:17:34)
at shadow.js.jsRequire (:3900/js/cljs-runtime/shadow.js.js:34:18)
at shadow.js.require (:3900/js/cljs-runtime/shadow.js.js:59:20)
at eval (:3900/js/cljs-runtime/app.excel.js:2:64)
at eval (<anonymous>)
at goog.globalEval (main.js:566:21)
at env.evalLoad (main.js:1659:12)
at main.js:2574:12
using shadow-cljs 2.11.5
tried changing https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider and https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules
any ideas?fin is supposed to be. looks to be expecting to be running in excel? but looks like you are running this in a browser?(exists? js/fin) check - so it never gets called).:browser so will just stick with this approach.
cheers!throw new Error('Namespace "' + name + '" already declared.');
I'm basically trying to use ViteJS and ShadowCLJS together but the hot reloading of Vite wants to recall goog.provide for everything when my ShadowCLJS ESM modules changes.
I found an https://github.com/minimal-xyz/minimal-shadow-cljs-webpack/blob/master/lib/page.js#L1-L5 that might workaround the issue, but I wanted to check with anyone if that seems correct, or if there is a better way to avoid calling all of the goog.provide functions again. Thanks in advance 🙏goog.provide as done here https://github.com/thheller/shadow-cljs/blob/0275661910fd356ae3312e834ef76546a42777d6/src/main/shadow/cljs/devtools/client/env.cljs#L152-L161{:test {:target :browser-test
...
:devtools {:http-port 8021 ...}}
:dev {:target :browser
...
:devtools {:http-port 8022 ...}}}
Only launching :dev:
$ clojure -M:cljs/dev:cljs/client watch dev shadow-cljs - HTTP server available at shadow-cljs - HTTP server available at shadow-cljs - server version: 2.20.2 running at shadow-cljs - nREPL server started on port 60050 shadow-cljs - watching build :dev [:dev] Configuring build. [:dev] Compiling ... [:dev] Build completed. (512 files, 0 compiled, 0 warnings, 4.21s)Am I doing something wrong?
release or compile builds as well as watchlein extern to generate them, and if I run that and include those externs in the build, its all fine.npx shadow-cljs release app --pseudo-names. that usually makes it easy to track what was renamed and which externs you would need.clj->js or js->clj alot?.a .b etc frequently.$whateverItWasBefore$js->cljlein extern is so dunno what that generaetd(.on win "close" #(do
(.set Settings "winBounds" (.getBounds win))
(when-not (contains? @!can-close window-id)
(.preventDefault %)
(async/put! event-queue
{:window-id window-id
:payload [:window/close-requested]}))))
this is code from an integrant init-key defmethod and doesn't produce any warnings about inferences:infer-externs in your build config somewhere?win and sSettings in the above?... source code ...
^js win (BrowserWindow. (clj->js opts))win once in the start should pretty much be enough for most things I see therewin ^js (BrowserWindow. (clj->js opts)) is not ideal since there are a few places in the compiler that lose type hints. I'm not sure this is one but to be sure just move it to the left(defn do-stuff [system]
(let [{:keys [Dialog]} system]
(.doSomething Dialog "foo")))
we do this kind of stuff a lot. system is a booted integrant system, Dialog is (.-dialog Electron) no warning about Dialog at build time, but xy is not a function during runtime:infer-externs true in your build config?*warn-on-infer*?{:editor {:target :browser
:output-dir "resources/public/js/compiled/"
:modules {:editor {:entries [editor.core]}}
:externs [
"resources/externs/react.ext.js"
"resources/externs/react-dom.ext.js"]}
:analyzer {:target :browser
:output-dir "resources/public/js/compiled/"
:modules {:analyzer {:entries [analyzer.core]
:web-worker true}}}
:app {:target :node-script
:main app.core/main
:output-to "resources/public/app.js"}
}:builds key – we only h ave source-paths and dependencies set otherwisePath or Url using this pattern does still not trigger warnings, though. (but e.g. FS App Dialog do trigger warnings)main entry in the package.json of this module does not properly export the names, but the module entry does. I would like to use this referred file in the build, but I'm wary of converting the entire build to :entry-keys ["module" "browser" "main"]. Is there a way to overide the entry key for one particular module? What is the best approach in a situation like this? Can I tell shadow somehow to use this specific entry point for that package?$ shadow-cljs watch app
com/google/javascript/jscomp/CompilerOptions has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0Getting this error when following the quickstart for shadow-cljs projects.
$ java -version
openjdk version "1.8.0_292" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)The shadow-cljs docs specify version 8 of java, I believe
File: /home/runner/work/nosco-gamma/nosco-gamma/cljs/nosco/ui/animations.cljs
invalid cljs source type
{:resource-id [:shadow.build.classpath/resource "nosco/ui/animations.cljs"], :resource-name "nosco/ui/animations.cljs", :source #object["[B" 0x27e3b83f "[
It is always with this file, and it is intermittent (a re-run will proceed normally). Is there anywhere I could look to stop it?:source is supposed to be a stringslurp or restored from transit json cache. so dunno how you make it return a byte array insteaduser.clj that modifies some stuff in weird ways? or other code that modifies something related to slurp or transit?goog.module("ham_fisted.BitmapTrie"); goog.module.declareLegacyNamespace(); in the first two linesmodule.exports.x assignments to just exports.x assignments(:require [ham-fisted.BitmapTrie :as bm]) with the usual bm/stuff access_ vs - situation. never tried a goog.module namespace with a - but should be fineextend-type in them can often get into states where they will fail to recompile after the first compilation.shadow.resource/inline so that I have access to the contents of a resource (a plain text file) in a browser setting. That means I had to https://github.com/luciolucio/holi/blob/99d59621d52b4a1193949143ab43dfb7cbf2adda/deps.edn#L6, i.e., it's now a runtime dependency for anyone that wants to use my library, which seems odd to me. Is this the way inline is supposed to be used?slurp like this:
https://gist.github.com/noprompt/9086232resource/internal does essentially the same thing as Chris McCormick's gist above, but adds logging to and lookup from a registry, to enable Shadow to cache those resources properly.; The result object failed to print. It is available via *1 if you want to interact with it.
;
; The exception was:
;
; #error {:message "The limit of 1048576 bytes was reached while printing.", :data {:tag :shadow.remote.runtime.writer/limit-reached, :limit 1048576}}
What is it means?(run-tests) from the cljs.test ns. I wonder if I'm missing something
; Execution error (TypeError) at (<cljs repl>:1). ; Cannot read properties of undefined (reading 'run_block')
(comment
(deftest test-smart-search-form-fields
(testing "If other fields list is truthy(not nil) then show dropdown"
(re-frame-test/run-test-sync
(js/console.log "does this work?")
(let [other-field-temp (reagent/atom "")
other-fields-focus (reagent/atom false)
other-fields ["one" "two" "three" "four"]]
(with-mounted-component
[smart-search-form-fields other-field-temp other-fields-focus other-fields]
(fn [_component]
(js/console.log (.-innerText (js/document.querySelector
"#smart-search-component")))))))))
(run-tests)){:dev-http {3449 "public"}
:builds
{:frontend
{:target :browser
:output-dir "public/js"
:module-hash-names true
:modules {:main {:init-fn app.core/init}}
:devtools {:preloads [day8.re-frame-10x.preload]}
:dev {:compiler-options
{:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}}
:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-test$"
:autorun true}}}
Is there a way to watch for the test and frontend build in separate servers?watch) but it is often advisable to have a dedicated server process running.npx shadow-cljs server and then you can toggle all builds via other commands or the UI at http://localhost:9630config.edn.localhost:8600/a) that user entered into the browser + just dump it to my console (e.g. directly via handler function). The next step will be that I will generate additional URIs (subaddresses) based on the app’s interaction with the user etc. For now console reaction would be great. But I just get 200 OK response when entering localhost:8600/a into browser (or when contacting server via GET API) – still without any reaction from handler function.
The app is barebones, it compiles, the server runs, the page renders and is displayed. But when I specify e.g. localhost:8600/a, I am unable to get the server to get the handler react. I run it using shadow-cljs watch app.
Here is my shadow-cljs.edn setup:
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies [[binaryage/devtools "1.0.6"]
[reagent "0.8.0-alpha2"]
[ring "1.9.6"]]
:nrepl {:port 8777}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:main
{:entries [when.core]}}
:devtools
;; before live-reloading any code call this function
{:before-load when.core/stop
;; after live-reloading finishes call this function
:after-load when.core/start
;; serve the public directory over http at port 8700
:http-root "public"
:http-port 8600
:ring-handler when.helpers/handler
:preloads [devtools.preload]}}}}
What I am doing wrong here?
Thank you very much!:dev-http {8600 {:root "public" :handler when.helpers/handler}} at the top level. not inside the build config, and removing the http related things from there;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies [[binaryage/devtools "1.0.6"]
[reagent "0.8.0-alpha2"]]
:nrepl {:port 8777}
:dev-http {8600
{:root "public"
:handler when.helpers/handler}}
:builds
{:app {:target :browser
:output-dir "public/js/compiled"
:asset-path "/js/compiled"
:modules
{:main
{:entries [when.core]}}
:devtools
{:before-load when.core/stop
:after-load when.core/start
:preloads [devtools.preload]}}}}
and I get:
:shadow.cljs.devtools.server.dev-http/handler-load-ex - {:http-handler when.helpers/handler}
FileNotFoundException Could not locate when/helpers__init.class, when/helpers.clj or when/helpers.cljc on classpath.
...
[:app] Build failure:
The required namespace "when.helpers" is not available, it was required by "when/core.cljs".
"when/helpers.clj" was found on the classpath. Should this be a .cljs file?
during compilation..clj file not .cljsshadow-cljs pom vs deps.edn? Including running REPL with Crusive in Intellij.:local/root supportws://-:9630/... , which causes a websocket connection error. any way we can point shadow towards localhost?:devtools {:use-document-host false} in the build configvreset! in https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server.clj#L567 is meant to be a reset!, since instance-ref is an atom.; eval (current-form): (reload!) ; (err) Execution error (ClassCastException) at shadow.cljs.devtools.server/reload! (repl_fast.clj:526). ; (err) class clojure.lang.Atom cannot be cast to class clojure.lang.Volatile (clojure.lang.Atom and clojure.lang.Volatile are in unnamed module of loader 'app')
shadow.cljs.devtools.api/release to build our production asset, but we need to inject closure-defines into the config. is there are way to do this currently? are we holding it wrong/shouldn't have to do this? if not, would you accept a PR to either accept :closure-defines inside the opts or to accept the build-config instead of a build id as the first arg? (so then we can fetch the config via s.c.d.config/get-build , override the closure-defines and pass it to release). could also go via release*, but then you have to set up the env etc. and from my current POV this could be a useful feature. (this is not about injecting a define that differs between envs – think e.g. hosted client vs on-prem client, where we need to configure different backends)release* function directly. just need to setup the runtime once. which is just (api/with-runtime ...) just like here https://github.com/thheller/shadow-cljs/blob/653dfa0cea96c496acc9a204ce644de284d69c50/src/main/shadow/cljs/devtools/api.clj#L343-L349{:config-merge [{:clojure-defines {'foo.bar 1}}]}. note the extra vector though.with-runtimeshadow.loader/load is working in dev, but not in release. The error is CustomError: Error loading <module>: Consecutive load failures and the stacktrace is just as cryptic.. any troubleshooting ideas? The xhr to get the .js file does succeed but it's fetched 3 times and fails after the 3rd.SHADOW_ENV.evalLoad("shadow.modul...(function(){
shadow$provide[390]=function(ya,Ba,Ja,Ra){var qa=Ba(156);Ja.exports=function(){return qa.Date.now()}};
shadow$provide
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')looks like there's a mistake in my routing+loading system somewhere as the error points to this line
$APP.$reitit$core$t_reitit$0core609782$$.prototype.$reitit$core$Router$routes$arity$1$ = $JSCompiler_unstubMethod$$(5, function() {
return this.$routes$;
});:compiler-options {:cross-chunk-method-motion false} in your build configreify in CLJS. https://clojure.atlassian.net/browse/CLJS-3207:node-library, and just wanted to ask here in case it's due to a simple oversight on my part.. it seems that async_hooks is a node-core-module, do I have to treat core-modules in a special way to make them available?
The required JS dependency "async_hooks" is not available, it was required by "node_modules/raw-body/index.js"
node_modules/raw-body/index.js? node-library doesn't process npm packages, so this weird(:require ["async_hooks" :as x]), not (:require [async_hooks :as x]). ie a string not a symbolnode_modules/raw-body/index.js is not one of my files, probably pulled in in my import of express (:require ["express" :as express])
The required JS dependency "async_hooks" is not available, it was required by "node_modules/raw-body/index.js". Dependency Trace: shadow/umd_helper.cljs test/lambdas/checkout.cljs node_modules/express/index.js node_modules/express/lib/express.js node_modules/body-parser/index.js node_modules/body-parser/lib/types/json.js node_modules/body-parser/lib/read.js node_modules/raw-body/index.js Searched for npm packages in: /Users/user/dev/checkout/node_modules
:stripe-checkout {:target :node-library
:output-to "landing/functions/checkout.js"
:exports {:handler test.lambdas.checkout/handler}
:js-options
{:js-provider :shadow
:keep-native-requires true}
:devtools
{:enabled false}}
:keep-as-require #{"async_hooks"} to the :js-options map:js-options from the config abovenpm-module target?
I’m running into some issues when bundling the output with many errors like:
cljs-dist/cljs_env.js does not export 'Nf'
> 1 | var window=global;var $CLJS=require("./cljs_env");require("./cljs_env.js");
> 2 | 'use strict';$=require("react");module.exports=$;
> |
And when I look at the cljs_env.js file, none of those fields exist. I’m using :advanced optimizations as well.
Do I need to create some kind of externs file or something? It seems like the optimizations are removing those fields, but I’m not sure. Any ideas?cljs-dist/cljs_env.js does not export 'Nf' mean? its not supposed to be exported? what is generating this error?require("./cljs_env");require("./cljs_env.js"); why is that duplicated?release command with shadow using this config:
{:source-paths ["src"]
:dependencies [[reagent "1.1.1"]]
:builds {:app {:output-dir "./cljs-dist"
:target :npm-module
:entries [app.main]
:release {:compiler-options {:optimizations :advanced}}}}}:simple optimizations that duplication does not happen.cljs-dist/cljs_env.js does not export 'Nf' refers to some mangled name that is supposed to be exported on the global $CLJS object / module$=require("react"); $CLJS is the global object:advanced optimized output?cljs-dist/cljs_env.js does not export 'Nf'? the error message I mean. the code is fine from what I can tell?cljs-dist/cljs_env.js requiring cljs_env is indeed a bug, that should not be2.20.18, a bad cljs_env.js file was indeed being generated.npm-module with compiler options :compiler-options {:external-config {:guardrails {}} :closure-defines {goog.DEBUG true}}}. We use the target to run jest tests. Starting the latest release of shadow-cljs, when we run jest we get this error:
● Test suite failed to run
Unable to resolve spec: :expound.spec/specs
at Object.cljs$spec$alpha$the_spec [as the_spec] (test-out/cljs/spec/alpha.cljs:121:18)
at Function.cljs.spec.alpha.spec_impl [as cljs$core$IFn$_invoke$arity$5] (test-out/cljs/spec/alpha.cljs:518:28)
at Function.cljs.spec.alpha.spec_impl [as cljs$core$IFn$_invoke$arity$4] (test-out/cljs/spec/alpha.cljs:513:28)
at Object.<anonymous> (test-out/expound/alpha.cljc:119:1)
at Object.<anonymous> (test-out/com.fulcrologic.guardrails.core.js:10:1)
I noticed that there were changes in the last shadow-cljs release to the npm-module target, but I have no idea if this is a regression or us doing something wrong, and I'm not sure where to start looking... Any hints on getting to the bottom of this maybe?:compiler-options {:cross-chunk-method-motion false} in the build config?:target :npm-module was entirely broken for release builds for the last few versions?shadow-cljs compile ... on that target)2.20.19:nrepl {:host "0.0.0.0"}:http {:port 9631} in shadow-cljs.edn top levelbuild-state that my hook receives. Does anyone has an idea ? thank you.:build-sources, which is a vector of resource-ids. if there is a corresponding (get-in build-state [:output resource-id]) it won't be recompiled. otherwise it will be(get-in build-state [:sources resource-id])reify?box given
(:require ["mathbox-react" :as box]
[reagent.core :as r])(defn get-me-the-thing [] box/foo) or whatever.Group ;
(def Group (reagent.core/adapt-react-class box/Group) , basically(defprim Group <some-map-that-I-will-turn-into-a-docstring>)(defprim box/Group ) and then strip off the namespace for the symbol I feed to def:maven {:repositories {"foo" {:id "foo" :url ...}}}(defn home-page [] [:<> [items-list] [map-container]]) ;; ------------------------- ;; Initialize app (defn mount-root [] (d/render [home-page] (.getElementById js/document "app"))) (defn ^:export init! [] (mount-root))
(ns coffee-tlv.components.map-container
(:require ["mapbox-gl" :as mapbox]))
(defn map-container []
[:div#map])
(set!
(.-accessToken mapbox)
"pk.eyJ1IjoiaXRheWRyZSIsImEiOiJja2RlczU5bmIwcDlzMnducmVuMDQ4cWlyIn0.BSyB9nVoIsnazX2PeUyPyg")
(def tlv-map
(new
(.-Map mapbox)
#js
{:container "map",
:style "",
:center #js [34.79 32.07],
:zoom 15}))shadow-cljs.edn looks like this:
{:lein true
:dev-http {3449 "resources/public"}
:builds
{:app
{:target :browser
:asset-path "js/compiled"
:output-dir "resources/public/js/compiled"
:compiler-options
{:infer-externs :auto}
:dev
{:closure-defines
{re-frame.trace.trace-enabled? true}}
:modules
{:app
{:init-fn lipas.ui.core/init}}
:devtools
{:after-load lipas.ui.core/mount-root
:preloads [devtools.preload
day8.re-frame-10x.preload]}}}}:output-feature-set :es8 and that seems to get rid of the warnings. :thinking_face:output-feature-set :es8 . Does someone have advice what to try next?:es8
• With :es8 I don’t see the errors and my build & app works
◦ I had an unrelated extern problem which I was able to fix
Last question is that are there any known problems with es8 as output feature set? I mean other than “doesn’t work with IE11". 😉@ directives in comment blocks. the files from OL seem to be full of them. I'm guessing it has some issues with this
/***
* @type {LayerOnSignature<import("../events").EventsKey>}
*/es8 is related to any of this though:output-feature-set:es2020, so dunno why downgrading fixes anything 😛ol/layer/Layer2.20.15 => 2.20.20 in the process. Dunno if this could explain some of the wierdness:output-feature-set :es8 and that seems to get rid of the warnings. :thinking_face::dev-http
{8280 "resources/public"}
I have to use http://localhost:8280. Is there any way to configure the response with http://localhost:8280/somethig ?resource/public/app/index.html if you want other html?resource/public/app folder:dev-http
{8280 {:root "resources/public" :path "/app"}}. So, I have to use in index.html <base href="/app/"> to all the links works. Ok until now?index.html. you are asking about additional assets like the .js files or images?index.html <base href="/">, to use with this config :dev-http {8280 "resource/public"}.<link rel="stylesheet" href="css/default.css" /><base href="/app">resources/publicln -s resources/public/app resources/public?RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. java.util.Optional.isEmpty()Z .... Caused by:NoSuchMethodError: java.util.Optional.isEmpty()Z com.google.javascript.jscomp.StaticSuperPropReplacer.tryReplaceSuper (StaticSuperPropReplacer.java:102)My first guess is that it's due to an incompatible java version. I remember I had a problem with the java version before, that's why I stick with
2.19.6 of shadow-cljs. Unfortunately this happens during the build on netlify, and before trying to reproduce or look further into it, I wanted to check if it's a known error.:dev
{:compiler-options
{:output-feature-set :es2018
:source-map true
:closure-defines {goog.DEBUG true}}}WARNING: CIDER requires cider-nrepl to be fully functional. Some features will only be available with it! (More information)I have
cider-nrepl in my ~/.shadow-cljs/config.edn, and I can see it when I run $ yarn shadow-cljs classpath.
{:dependencies [[cider/cider-nrepl "0.29.0"]
[refactor-nrepl "3.6.0"]
[cider/piggieback "0.5.2"]]}
I've also tried downgrading CIDER from 1.6.0 to 1.5.0, 1.4.0, and 1.3.0, but none worked.
Have anyone passed a similar situation?~/.shadow-cljs/config.edn, so it may just be started differently.cider-connect-clj&cljs stopped working after I bumped CIDER's version. The Emacs weren't sending commands to the REPL anymore, probably because of the warning below.
WARNING: CIDER 1.6.0 requires cider-nrepl 0.29.0, but you're currently using cider-nrepl 0.25.3. The version mismatch might break some functionality! (More information)The project I'm working on was using
yarn shadow-cljs watch :webapp :api to start the watchers, and everything worked fine before the bump. But now I have to explicitly say to shadow-cljs to inject CIDER's dependencies (like done under the hood by cider-jack-in-clj&-cljs.
yarn shadow-cljs \
-d nrepl/nrepl:1.0.0 \
-d cider/cider-nrepl:0.29.0 \
-d refactor-nrepl/refactor-nrepl:3.6.0 \
-d cider/piggieback:0.5.2 \
watch :webapp :api
I'm happy it's working now, but I wonder what changed to force me to run watch with the dependencies. I thought that if I defined those packages in my ~/.shadow-cljs/config.edn, shadow-cljs would inject them automatically.shadow-cljs.edn. Here's the project and environment configuration files if you want to take a look https://gist.github.com/wcalderipe/f2279335bbcb3a8ad63cdd13e397cd67XDG_CONFIG_HOME, so if you have another shadow-cljs/config.edn file sitting there that is empty~/.shadow-cljs/config.edn won't be usedLOCALAPPDATA in case your on windowsconfig.edn is the only file in the direction. Also, the XDG_CONFIG_HOME variable is empty.
~/.shadow-cljs❯ pwd /Users/wcalderipe/.shadow-cljs ~/.shadow-cljs❯ ls -la total 8 drwxr-xr-x 3 wcalderipe staff 96 May 10 2021 . drwxr-xr-x+ 120 wcalderipe staff 3840 Jan 21 10:48 .. -rw-r--r-- 1 wcalderipe staff 131 Jan 19 19:03 config.edn ~/.shadow-cljs❯ echo $XDG_CONFIG_HOMEI can't find docs for
XDG_CONFIG_HOME. Should I use it alongside the watch command like XDG_CONFIG_HOME=/another/config.edn yarn shadow-cljs watch :webapp?~/.shadow-cljs/config.edn should be the only file readnpx shadow-cljs release app but plenty are when I run npx shadow-cljs compile app?WARNING #1 - :infer-warning type, and started showing up as a result of https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#22017---2023-01-04 to shadow-cljs.
We have :compiler-options {:warnings-as-errors true} set on our :release but our CI system didn't fail as expected because the warnings are only showing up locally when we run shadow-cljs compile or watch:infer-warning from reagent/with-let as per https://github.com/reagent-project/reagent/issues/585*assert* is bound to false, so the code with the problem is never used:compiler-options {:elide-asserts false} makes it show up, but you don't really want asserts in release build:infer-warning errors, I would assume setting :compiler-options {:warnings {:infer-warning false}} would communicate that these warnings are not to be shown, but, to my frustration, it doesn't work this way. :thinking_face:
Is there a way to hide :infer-warnings? (Aside from fixing them 😄 They happen to be quite some)
The build description is
:test {:target :node-test
:output-to "static/tests.js"
:closure-defines {frontend.util/NODETEST true}
:devtools {:enabled false :preloads [hashp.core]}
;; disable :static-fns to allow for with-redefs and repl development
:compiler-options {:static-fns false
:warnings {:fn-deprecated false
:redef false
:infer-warning false}}
:main frontend.test.frontend-node-test-runner/main}
:compiler-options {:infer-externs false}, not inside :warnings. true also disables them. I know its weird. if you are sure you don't need any externs in an ns you can also do (set! *warn-on-infer* false) in the file after the ns:compiler-options {:infer-externs false} works like a charm!
Now when no infer warnings are shown it'll be super comfy to notice other kind of warnings (like :undeclared-var etc.) ^.^ (which show up before :infer-warnings), previously you'd need to scroll up through those 28 infer warns to get to them, which, interestingly, you get used to after a while and stop to notice 😄, but still
I've been getting infer warnings while watching :testhttps://github.com/logseq/logseq/blob/9f18a707aa2f4704f7ab126e9a9c49ba9bc20ff6/shadow-cljs.edn#L70, via clj -M:test watch test, as suggested in https://github.com/logseq/logseq/blob/master/docs/dev-practices.md#focus-tests. Log's attached. Hope this can be of help. 🙂
And thanks again for the tip! A solid bump to devUX
(Btw, I think it's a good thing that compiler thoroughly warns about infers, these warns are there for a reason, fixing them would be nice indeed):advanced build(fn [a b] (.multipliedBy a b)) just becomes (fn [^js a b] (.multipliedBy a b)) and the warning is gone:advanced, and here we've got :none , it seems, huh)
ReferenceError: js is not defined
at /home/user1/gits/logseq/logseq/.shadow-cljs/builds/test/dev/out/cljs-runtime/malli.util.js:1834:1
at global.SHADOW_IMPORT (/home/user1/gits/logseq/logseq/static/tests.js:64:44)
at /home/user1/gits/logseq/logseq/static/tests.js:1764:1
at Object.<anonymous> (/home/user1/gits/logseq/logseq/static/tests.js:2134:3)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Function.Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
at node:internal/main/run_main_module:23:47:none, as no externs are ever needed:infer-externs true, which will still do externs inference but never warn:infer-externs set to true and false yields no warns and the build works alright:infer-externs true does, logic behind true false keywords clicked 🙂------ WARNING #3 - :infer-warning ---------------------------------------------
File: /Users/m/code/arcstudiopro/src/app/system/spellcheck.cljs:180:3
--------------------------------------------------------------------------------
177 | ;; (outbox [[:spellcheck/learned params]]))))
178 | ;;
179 | (defn learn [{:keys [!dict ^js FS] :as system} params outbox]
180 | (go
---------^----------------------------------------------------------------------
Cannot infer target type in expression (. inst_10004 (appendFile inst_10024 inst_10025))
--------------------------------------------------------------------------------
181 | (let [^js FS+ (.-promises FS)
182 | ^js dict @!dict
183 | word (:word params)]
184 | (<p! (.add dict word))
--------------------------------------------------------------------------------(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
(go
(let [^js FS+ (.-promises FS)
^js dict @!dict
word (:word params)]
(<p! (.add dict word))
(<p! (.appendFile FS+ (user-dic-path system) (str word "\n")))
(outbox [[:spellcheck/learned params]]))))dict can be inferred as externable, but FS+ can't? or am I misreading the situation?go are dropped by go unfortunately(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
(let [^js FS+ (.-promises FS)
^js dict @!dict
word (:word params)]
(-> (.add dict word)
(.then #(.appendFile FS+ (user-dic-path system) (str word "\n")))
(.then #(outbox [[:spellcheck/learned params]]))))).add just doesn't require externs while .appendFile doesthens?(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
(let [^js FS+ (.-promises FS)
^js dict @!dict
word (:word params)]
(js-await [_ (.add dict word)]
(js-await [_ (.appendFile FS+ (user-dic-path system) (str word "\n"))]
(outbox [[:spellcheck/learned params]]))))).then, so not sure what you meanthens
I think it might help to see Promises at work from the JavaScript side of things. Not totally clear if the phrase "nested then" even has any real meaning in JavaScript.
myPromise.then(x =>
x.then(y =>
y.then(z =>
f(z))))
is fully equivalent to
myPromise.then(f)because, as each intermediate Promise resolves, the result is automatically unfolded into any Promise that contains it. For the more complicated case, where additional work is done at each step, you still do not need to actively handle nesting levels.
myPromise.then(x =>
transformX(x)
.then(y =>
transformY(y)
.then(z =>
transformZ(z))))
can be collapsed to the flatter and simpler
myPromise .then(transformX) .then(transformY) .then(transformZ)without changing the behavior. With this flattened version, you could choose to replace any or all of the transform functions with a function returning a simple value instead of a Promise, with no notable impact.
await is just syntactic sugar for forcefully sequential (i.e. not concurrent with other Promises in the same block) .then calls.
async function () {
const x = await promise1
const y = await promise2
const z = await promise3
return {x, y, z}
}
is strictly equivalent to
promise1.then(x =>
promise2.then(y =>
promise3.then(z =>
{x, y, z})))
The nesting here comes from using closures as a simple way to capture values, because a Promise handler function only takes a single input. We could flatten out of the nesting by jumping through some hoops to pass each partial result through or around the next promise.
If being less strict about sequential processing is okay, then this can also be considered equivalent to the await example,
Promise.all([promise1, promise2, promise3])
.then(
([x, y, z]) => {x, y, z})
with probable improved performance due to letting the 3 input promises resolve concurrently (but still synchronizing the time factor before passing the combined result on to the next consumer).(defmacro my-defn
[name bindings & body]
`(defn ~name
{:arglists '([~'z])}
~bindings
In Cljs:
(my-defn foo [x] (+ x x)) (:arglists (meta #'foo)) ;; => '([z]) - works as expected (my-defn foo-variadic [& xs] (apply + xs)) (:arglists (meta #'foo-variadic)) ;; => '([& xs]) - incorrect!
defn but in the front-end it packages up all the arguments into a vector and sends them to an API endpoint that calls the function on the backend and returns the results and wraps it in a JS promise.
The function generated on the clojurescript side is variadic (easier to package up in the vector that performs the RPC) but since tooling (cider in this case) uses the :arglists for auto-completion / docs I would like to be able to keep the original version.
I hadn't found the thread before I asked here so I'll look into a non-variadic waycljs.user> (sort [1 (js/BigInt. 2)]) Execution error (IllegalArgumentException) at shadow.build.cljs-hacks/eval117228$fn (cljs_hacks.cljc:981). No matching clause:
js/BigInt isnt a constructor, try removing the dot. This will fail anyway since you can't compare BigInts to regular numberscljs.user> (sort (vector 1 (js/BigInt 2))) Execution error (Error) at (<cljs repl>:1). Cannot compare 2 to 1 :repl/exception!
style-loader into shadow-cljs or am I better served with using something like Garden? I ask because I'm dealing with a pesky React component that unfortunately wants to be passed an embedded stylesheet.
For now my best guess would be to define a macro that simply slurps an external CSS file and I mimic the import "stylesheet.css" syntax by naming my macro something like import-csserror in process sentinel: nrepl-server-sentinel: Could not start nREPL server: ------------------------------------------------------------------------------ WARNING: shadow-cljs not installed in project. See ------------------------------------------------------------------------------ shadow-cljs - config: /Users/akiz/Code/Clojure/hh/shadow-cljs.edn shadow-cljs - starting via "clojure" --- SHADOW-CLJS FAILED TO LOAD! ----------------------
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Streams at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:259) at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:154) at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:146) at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:414) at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:178) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167) at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1743) ... 211 more Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Streams at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 222 more
com.google.guava/guava {:mvn/version "31.1-jre"}
to deps.ednws package when using node targetsshadow-cljs command line tool and nothing else. not related to CLJS compilation in any way:local/root and :git/url dependencies, as well as being sort of the new standardUncaught TypeError: shadow.js.shim.module$create_react_class is not a functionRelevant parts of the shadow-cljs config:
{:target :browser
:compiler-options {:output-feature-set :es6}
:output-dir "public/js"
:asset-path "js"
...
:js-options {:js-provider :external
:external-index "target/index.js"}}
Then I invoke webpack with the following command:
npx webpack --entry ./target/index.js --output-path ./public/js --output-filename libs.jsMy index.html has script tags ordered like so
<script src="/js/libs.js"></script> <script src="/js/main.js"></script> <script>shadow_cljs_require.core.init();</script>Yet I get the TypeError above. Why?
:asset-path is problematic and I wont be able to do much as a consequence of relative paths from URLs being unsupportedmain.js is the correct file? you elided the :modules? could be some old file sitting arround?:target :npm-module works flawlessly on my machine, but using :js-provider :external hasnt been able to workshadow.js.shim.module$create_react_class is not a function this error is NOT from the :js-provider :external build.shadow-cljs folder. Hopefully this worksrequire() statements. I had to include e.g. (:require ["react" :as react]) in my core.cljs file so that the following can be emitted
ALL["create-react-class"] = require("create-react-class");
ALL["react"] = require("react");
ALL["react-dom"] = require("react-dom");
then running webpack once more produces a libs.js that contains everything core.cljs wants
I would've never figured this out if you didn't tell me to ensure browser cache wasn't messing with my build 🙂--config-merge '{:ssl "docker/keystore.jks" :password "shadow"}', but it still fails and I get this error in the js console:
WebSocket connection to '' failed:I'm guessing that it should be
wss, but don't understand how to make it so. I note that the config merge seems to do something because when I add it, I get automatically redirected to https, from http, which does not happen without the merged config.wss://, but there's no info about how it fails. Can I enable some verbosity somehow?{:ssl {:keystore "<path-to-keystore>" :password "shadow"}}, :face_palm: , but I still don't get it to work...config-merge like that. If I move it to the shadow-cljs.edn file, it works.:ssl config via config-merge.:ssl <something> means something else in the build config.:ssl has no meaning in --config-merge.:devtools-url is set that is used. as-is. if not it tries to figure out which url to use from document.location in the client. it only uses ssl if ssl is configured in shadow-cljs:ssl has no effect in the build config, regardless of if coming from config direct or config-merge. but if you want to setup a repro I'll take a look.:devtools-url or :use-document-host false in the buidl config:target :browser in the first place?ExceptionInfo: failed to convert sources ... Caused by: RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. ... Caused by: StackOverflowError: com.google.javascript.jscomp.DeadAssignmentsElimination.tryRemoveAssignment (DeadAssignmentsElimination.java:219)
"shadow-cljs": "2.20.20":jvm-opts ["-Xss16m"] in shadow-cljs.edn:node-test build which I run with shadow-cljs release. Sometimes I get an exit code 1 if an error occurs within the test source. However, when an async test times out or does not pass an assertion, the process exits gracefully. I would like to have a failure in these instances in order to stop my deployment process in CI. Any advice on how to achieve this?async tests? easy to mess up async tests, so hard to give specific adviceasync done callback when this timeout occurs?:app with :target :browser. It has an alternate module directory called lib in addition to node_modules , configured like
:js-package-dirs ["node_modules"
"lib"]
Now I added a new build with :target :npm-module. I added the same js-package-dirs config there. This build will not compile because it cannot find the modules inside lib. Is this supposed to work with npm-module target?lib folder. I picked up some advice you gave elsewhere about just npm install the modules I need from my lib folder, that actually worked.:dev-http
{8080 {:host ""
:ssl-port 8081}}
but it's not working. I'm using shadow-cljs' default SSL config, and the shadow-cljs server listening on port 9630 is using HTTPS. So I know it's not an SSL error:root, and with :ssl properly configured just :dev-http {8080 "public"} should use sslshadow.html/copy-file that supports binary files? Learned the hard way that PNGs can't be copied this way 😄public, in this case they'd have to be in a build folder, so in the end i used webpack pluginsconsole.log of the kondo config and ask them to paste the contents into the kondo config file. So... I'm wondering if there is a way to use the shadow.cljs.devtools.client API (or another, I'm not sure) in the browser combined with a custom websocket event handler that will pass the kondo config, which is just data, to the shadow clojure process which can then write it to the filesystem. The goal would be to include this as an optional addon for malli users so they can get kondo static analysis in clojurescript files. Thanks!:clj-eval there is :cljs-eval, just need to find the correct :to via :request-clients https://github.com/thheller/shadow-cljs/blob/master/src/dev/shadow/remote_example_ws.clj#L155shadow.cljs.devtools.api/cljs-evalruntime.shared/add-extension with a new op like :write-malli-config. I don't think there's any macros involved. After your suggestion to do instrumentation at runtime I refactored it to do so https://github.com/metosin/malli/blob/master/src/malli/instrument.cljs .
so at runtime all the schema data is available and a simple data transform is run on it and then printed:
https://github.com/metosin/malli/blob/master/src/malli/clj_kondo.cljc#L208
So my hope was I could do something like
(shadow.remote.runtime.shared/call @runtime-ref
{:op :write-malli-config :data kondo-config})
and then have a listener on the clj side to simply write to file(defmethod worker/do-relay-msg ::write-kondo-config [worker-state msg] (println "Got kondo config" msg) worker-state)cljs side:
(shared/call
(deref client-shared/runtime-ref)
{:op ::write-kondo-config
:to env/worker-client-id
:data (get-kondo-config)}
{})(shadow.cljs.devtools.api/cljs-eval :the-build "(whatever.ns/get-kondo-config)") and then write the result to disk?:flush and then invokes cljs-eval but sometimes the data returned contains the old values from the previous compilation. So I think the cljs-eval is happening before the latest code is loaded. Ideally I wouldn't have to update the cljs side of things and could do this all from the build hook, so was wondering if there is a way to determine if the latest code was loaded in the client and not only written to disk.(defmethod worker/do-relay-msg ::write-kondo-config [worker-state msg]... )(defn ^:dev/after-load kondo-transfer! [] (whatever-to-send-message-to-relay)):require-macros [malli.shadow-helper]late-cljs feature in a branch for a couple months nowns to be compiled last(defn ^:dev/after-load kondo-transfer! [] (whatever-to-send-message-to-relay)) this lives in the library in a ns that cannot include the user's code, will it always run after the user's code?instrument! call is relevant?! in an after-load hook and that is where the latest schemas are picked up after hot reload. So this kondo preload would have to run after that, which I'm not sure about the order of multiple after-load hooks(md/start!) not in the preload?! however they like - could be in a preload but doesn't have to be - it also takes an options map which we want to make visible to the usermalli.dev.cljs out of the build entirely for release(ns com.my-org.client.preload
{:dev/always true}
(:require
[] ;; must require all namespace here that potentially get instrumented
[my.app.util]
[malli.dev.cljs :as md]
[malli.dev.shadow-hooks]
[malli.instrument :as mi]))
(mi/instrument!)
(md/start!)(ns com.my-org.client.preload
{:dev/always true}
(:require
[] ;; must require all namespace here that potentially get instrumented
[my.app.util]
[malli.dev.cljs :as md]
[malli.dev.shadow-hooks]
[malli.instrument :as mi]))
(defn {:dev/after-load} dev []
(md/start!))
(ns malli.dev.shadow-instrument
{:shadow.build/late-cljs true
:dev/always true}
(:require
[malli.dev.cljs :as md]
[malli.dev.shadow-hooks]
[malli.instrument :as mi]))
(mi/instrument!)
(md/start!)late-cljs part 😉(ns com.my-org.client.preload
{:dev/always true}
(:require
[] ;; must require all namespace here that potentially get instrumented
[my.app.util]
[malli.dev.cljs :as md]
[malli.dev.shadow-hooks]
[malli.instrument :as mi]))
(defn {:dev/after-load} dev []
(md/start!)
(malli.shadow-kondo/emit!))instrument! is the macro?(malli/collect [long list of all namespaces]) (malli/instrument!)
collect?!start! into the preloaddev/ater-load right?(ns user.app.shadow-instrument-preload
{:dev/always true}
(:require
[]
[malli.dev.cljs :as md]
[malli.dev.shadow-hooks]
))
(md/start!):dev/after-load hook lives in .shadow-hooks[] will ensure:init-fn ns it will ensure that the preload is actually compiled after those{:main
{:target :browser
:output-dir "resources/public/js/main"
:asset-path "js/main"
:dev {:modules {:main {:init-fn com.my-org.client.entry/init}}}
:release {:modules {:main {:init-fn com.my-org.client.release-entry/init}}
:build-options {:ns-aliases
{malli.dev.cljs malli.dev.cljs-noop
com.my-org.client.malli-registry com.my-org.client.malli-registry-release}}}
:closure-defines {malli.registry/type "custom"}
,,,shadow.cljs.devtools.api/watch? or maybe from (shadow.cljs.devtools.server/start!)?(npm-deps/main {} {})
got the job done!(def root (. js/document -getElementById "root"))(.render mithril/m root-div "hi")m.render(root-div, "Hello world")
m is equal to mithril/m(m "h1" "header")(m/render (.body js/document)
(m "h1" "my epic win")
(m "h2" "test")
(m "button" "an epic button")))whycome TypeError: document.body is not a function(ns
(:require [mithril :as m]))
(defn render-content []
(println "test rendering")
(println(. js/document -body))
(m/render (. js/document -body)
(m "h1" "my epic header")))
(defn init []
;; tests
(println "hello world")
;; renders
(.addEventListener js/document "DOMContentLoaded" render-content))
m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
])
(array []?)(defn render-content []
(println "test rendering")
(println(. js/document -body))
(m/render (. js/document -body) (m "h1" "test"
(m "h1" "my epic header")
(m "h2" "my epic subheader"))))
works
but idk whyshadow-cljs npm dependency under src/deps.cljs in the clojure library version of shadow?
I noticed when I ran (npm-deps/main {} {}) that it complained that I didn’t have shadow’s npm dep installed…shadow-cljs command?shadow-cljs.edn or package.json .
This is for Clerk, if someone wants to use a cljs library they need to rebuild the JS that Clerk uses, and I want that (for new users) to happen transparently; so new JS gets built behind the scenes and swapped into Clerk’s html[12:15 AM] (let my-pictures #js {:view (fn [] (
(m "main" #js {:class "container"}
(m "article"
(m "h1" #js {:role "button"} "My Name")
(m "h2" "My Pictures")))))})
(defn render-content []
(println "test rendering")
(println my-pictures)
(println(. js/document -body))
(m/mount (. js/document -body) my-pictures))
(defn init []
(.addEventListener js/document "DOMContentLoaded" render-content))
[12:16 AM] TypeError: fexpr__12320.call is not a function at line
(let my-pictures #js {:view (fn [] (
Seems I'm calling the function incorrectlyutil namespace and never change that namespace, then it wont be refreshed. So in that case I can understand the previous state you’re speaking of.
If I wanted to make namespaces forcibly refresh every time, I would add the ^:dev/always metadata to themshadow-cljs - watching build :viewer [:viewer] Configuring build. -> build target: :esm stage: :configure <- build target: :esm stage: :configure (2 ms) [:viewer] Compiling ... -> Resolving Module: :viewer <- Resolving Module: :viewer (1293 ms) -> build target: :esm stage: :compile-prepare <- build target: :esm stage: :compile-prepare (5 ms) -> Closure JS Cache read: 101 JS files <- Closure JS Cache read: 101 JS files (21 ms) -> Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js <- Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js (394 ms) -> Shadow JS converting 1 JS sources <- Shadow JS converting 1 JS sources (551 ms) [:viewer] Build failure: Closure compilation failed with 1 errors --- node_modules/squint-cljs/core.js:625 Transpilation of 'Computed fields' is not yet implemented.The offending code seems indeed to be:
export const IIterable = Symbol('Iterable');
...
class LazyIterable {
constructor(gen) {
this.gen = gen;
}
[IIterable] = true;
[Symbol.iterator]() {
return this.gen();
}
}
https://github.com/squint-cljs/squint/blob/c50c4c2582aeda9e874a867e19a2bfcfc9e4caab/core.js#L452-L460
Does anyone have also encountered this issue before? Couldn’t find much around closure compiler and computed fields or properties.
Both targets :browser and :esm produce the same issue, changing :output-feature-set to different ES levels also has no effect2.20.20squint-cljs/core.js which produces the error above:esm target? What is the transformation doing?squint-cljs/core.js is pure es6:js-provider :import for :esm buildsnpx esbuild public/main.js --bundle --minify --platform=browser --outfile=public/main2.js --format=esm
<script async src=""></script>
<script type="importmap">
{
"imports": {
"squint-cljs": "",
"squint-cljs/core.js": "",
"squint-cljs/string.js": ""
}
}
</script>:js-provider selective to just squint-cljs/core? Is that :resolve https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve?:js-options {:keep-as-import #{"fs"}}:keep-as-import #{"squint-cljs/core.js"}
in :js-options I still get the transpile error:keep-as-import #{"squint-cljs"}unhandledRejection and usually run a snippet like the one below to avoid this. Is there a way to configure this at a project level?
(js/process.on "unhandledRejection"
(fn [err]
(js/console.log "unhandledRejection" err)
(tap> {:unhandledRejection err}))):preloads it?node process dies..catch -- probably I’m thinking too simplistic here 🙂tap> seems a bit iffy though, since then the problem goes unreported if there is no tap reporter is set up. Maybe default to just print, but allow switching to tap> in the config?tap> is specific to my setup java, whereever that leads is up to your systemnode -e "require('which').sync('java')" in the project dirwhich java or whereis java or whatever OS command you ahve[2023-01-31 14:41:59.327 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@automerge/automerge-wasm/nodejs/automerge_wasm.js", :requires [{:line 4, :column 37}]}const { TextDecoder, TextEncoder } = require(`util`);const path = require('path').join(__dirname, 'automerge_wasm_bg.wasm');:external js provider like that, is it still possible somehow to use shadow-cljs for interactive development (like with hot reloading and stuff)? Because if I understand the order of operations correctly, first we invoke shadow-cljs, which generates a js file, which then we feed into webpack, and then we have our index.html load both files ...Automerge/init doesn't work - it can't find it), but also I think something about the build related to my inclusion of io.github.nextjournal/markdown didn't work, because I get this error upon loading::js-provider :external buildnpx webpack (with a suitable config just telling it what to read from and where to write to) ...:js-options :resolve:
"user-gql-query" {:target :global :global "UserGqlQuery"}
"all-gql-queries" {:target :file
:file "dist/all_gql_queries_bundle.js"}
My all_gql_queries_bundle is generated from a JS file that does import * as UserGqlQuery "user.gql" window.UserGqlQuery = UserGqlQuery and uses webpack to "compile" gql files into js files.
my cljs namespace imports both "all-gql-queries" and "user-gql-query"
when the namespace tries to load, it fails with shadow-cljs - failed to load module$users_gql_queries
Inspecting the browser, I am able to access window.UserGqlQuery without issues (it returns the value that I expect)
but shadow$provide returns an empty object. then shadow$provide.module$users_gql_queries returns undefined.:target :file is really not recommended. neither is the :resolve config:js-package-dirs ["node-modules" "your-modules"] in the build configyour-modules/all-gql-queries/index.jsjs/UserGqlQuery?.gql files directly into JS bundle
Tomorrow I will try to access the globals directly. Maybe even add the external script src= and leave the cljs build way cleaner..gql files are, but webpack in the process of bundling them might include npm dependenciessrc/deps.cljs in peerDependencies, and found that shadow would try to install it every time.
The problem was that the npm install call that shadow issued would destroy any npm link calls I had run, to get npm to look at local versions of one of the dependencies I was working onnpm link is, so no idea about thatnpm link when you have an npm dependency like mathbox, and you want to develop against local copy of itpeerDependencynpm install actually WILL install my declared peerDependencies; but usually it’s like a JVM “provided” dependency. It means “consumers have to have SOME version of this but I want to force you to declare it on your own”node_modules entry of a library with a symlink to a local path. the problem is that shadow-cljs is calling npm install inappopriately, since its is-installed? filter is not catching things I have in peerDependencies; and that npm install call blows away my npm link symlinksnpm-deps install thing entirely:npm-deps {:install false} in shadow-cljs.edndeps.cljs entries had made it into package.jsonsrc/deps.cljs in your classpath:deps dependenciesnpm after declaring the dep, so it actually feels like the right thing to do to get my deps in via deps.cljsdeps.cljs is causing trouble, you’re the expert here… maybe I’m too used to the status quo to imagine other solutions(:require ["clojure.string" :as x]) is valid, which I consider a bug["mafs" :as m] is treated as a self-require and would error out?mafs.core["mafs" :as m] is treated as a self-require and would error out?
I have only tried it with shadow, where it works fine… I should get a proper vanilla build goingmafs is fineinit-fn I try to disable logging like this:
(ns app.entry (:require [app.core :as core])) (defn init [] (js/console.log "Initializing app!") ;; (when-not ^boolean js/goog.DEBUG) (set! *print-fn* (fn [& _])) (js/console.log "This shouldn't appear.") ,,,,)But it never works. It does if I eval the
set! call manually though. Any ideas on what might be causing this?js/console.log is not related to printing in any way. that is a browser feature.js/console.log is not affected by *print-fn*, prn or others use *print-fn* which defaults to using js/console.log(js/console.log "This shouldn't appear.") so this will always appear(println "This shouldn't appear.") won'tjs/console.log with println?println but prn facepalm
Ah. (set! js/console.log (fn [& _])) does the trickrelease builds, you can enable them by setting :compiler-options {:source-map true}release locally again. that will give you a different build + adow$provide[0]=function(T,I,ia,ha){var E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;ia.exports=function(){try{if(!Object.assign)return!1;var h=new String("abc");h[5]="de";if("5"===Object.getOwnPropertyNames(h)[0])return!1;var k=app.v1.js file and you have uploaded a app.v1.js.map file to LR, you should get proper stacktraces alreadycljs-runtime/ codeshadow-cljs release app and produce just a app.js(:require ["styles.js"]) is kind of confusing(my-require "styles.css") would be fine, as long as the reference is straightforward(:require ["styles.js"])(ns
(:require [shadow.css :refer (css)]))
(defn hiccup-example []
[:div {:class (css :px-4 :shadow {:color "green"})}
"Hello World"])(def styles (css "./button.css"))
[:div {:class (:base styles)} ...]
[:div {:class (:warn styles)} ...](css "./button.js") is fine as a starting point(:require ["button.js"])public folder, then shadow-cljs takes care of the hot reloading and it works out very nicely in practice. As a benefit you get mixins, color blending functions, scoping, and so on. I cannot see myself ever going back to pure CSS or even what feels like the CLJS equivalent of CSS-in-JSXcss macro you can do so. but you have to build it yourself. you can inform shadow-cljs that it needs to watch the css files as described here(:require ["./button.css" :as x]) to work you can also get that:source-paths entry, something like src/gensrc/main/your/app.css goes to src/gen/your/app.css.jsdevcards yet? Is it still usable with latest version of shadow-cljs?devcards. This https://github.com/bhauman/devcards/issues/168#issuecomment-640257949 has a little bit of boilerplate code that you need to make devcards' dependencies work with shadow-cljs.:target :esm can we output each entry as a separate ESM file, much similar to :npm-modules?
:app-esm {:target :esm
:modules {:main {:entries [app.mod1 app.mod2]}}}:npm-module is the way to go:esm also really expects exports, otherwise its pretty useless in an interop scenario{:target :esm
:modules {:base {:entries []}
:app.mod1 {:entries [app.mod1] :depends-on #{:base}}
:app.mod2 {:entries [app.mod2] :depends-on #{:base}}}}:base-test$ namespaces, then rewrite the :modules config to the above format:npm-module:esm. but far too much trouble doing everything manually:npm-module problem:npm-module doesn't support browser runtimes, right?:npm-module supports browsers, but only with more processing by third party tools as browser can't load commonjs files otherwise:npm-module to output things like app.foo-test.cljs to app.foo-test.js and cypress test running would load it and execute it in the browsershadow-cljs browser-repl or so^:dev/after-load to kick a re-run:npm-module since there is no controlled entry pointrequire("./cljs-out/your.preload") in some prepended configuration or sorequire("./cljs-out/shadow.cljs.devtools.client.browser") is the ns for the REPL/hot-reload runtime{:target :esm
:modules {:base {:entries []}
:app.mod1 {:entries [app.mod1] :depends-on #{:base}}
:app.mod2 {:entries [app.mod2] :depends-on #{:base}}}}:browser-test works with cypress? I really never looked into cypress much:browser-test. doesn't have to be cljs.test:browser-test just generates JS, with the assumption that it is executed in a browser environment:npm-module?js/it ...?describe it etc functions?(def cy js/parent.Cypress) (.onSpecWindow cy js/window #js []) (.action cy "app:window:before:load" js/window)
(defn ^:dev/before-load click-cypress-ui-restart-button
[]
(when-not (= js/window.parent js/window)
(-> (js/window.parent.document.querySelector "button.restart")
.click)))
IMHO it's okay for the app iframe to do a full reload in e2e tests, since most of the e2e tests takes much longer and the benefit of hot-reloading over full page reload is dwarfed.devServer option equivalent as far as I can tellapp.mod1.js and app.mod2.js under <output-dir>:app-esm {:target :esm
:modules {:app.mod1 {:entries [app.mod1]}
:app.mod2 {:entries [app.mod2]}}}:cache-blockers , but I’m wondering if there is a more elegant way to handle this.
In short, my configuration has a few :closure-defines like so
:closure-defines
{foo.bar/const #shadow/env ["FOO_BAR" "BAZ"]}
I’ve noticed that running npx shadow-cljs release target once then running FOO_BAR=QUUX npx shadow-cljs release target will give me a bundle with the older environment variable set, unless I delete cache in between builds.
Maybe finding a way to set :cache-level to :off in release builds is what I want?release when a previous server is already running?FOO_BAR=QUUX npx shadow-cljs release target --force-spawnnpx shadow-cljs compile target multiple times, yet I didn’t see :closure-defines update in the app. Then out of sheer luck I tried a release build and everything worked; then I suspected my compilation caches were messing with things:closure-defines are also not cached, so nuking the cache doesn't have any effect:js-provider :import and
2) have a classpath ESM that makes uses of a npm ESM pkg (`promsemirror-state` in the repro below)
then advanced compilation would fail with Required namespace "esm_import$prosemirror_state" never defined.
Repro is here https://github.com/lins05/my-repros/tree/master/repro-shadow-cljs-advanced-using-npm-esm:closure-defines values. At the moment I am duplicating everything for each build, so
:builds {:env1 {:target :browser
:compiler-options {:output-feature-set :es-next
:closure-defines {app.foo/BAR "baz1"}}
:modules {:main {:init-fn app.core/init}}
:output-dir "public/js"
:asset-path "/js"
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:http-root "public"
:http-port 3900
:preloads [devtools.preload
shadow.remote.runtime.cljs.browser]}}
:env2 {:target :browser
:compiler-options {:output-feature-set :es-next
:closure-defines {app.foo/BAR "baz2"}}
:modules {:main {:init-fn app.core/init}}
...
Is there a way to share things between these different builds? or maybe a better way to inject variables for different builds?--config-merge to use from the command line https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge
(edit: wrong link):npm-module build and running through the built-in webpack?amperity.cypress.integration.databases and then a cypress/integration/databases.spec.js which contains a require
require("amperity-cypress/amperity.cypress.integration.databases");
and cypress watches that dir and rebuilds when the node_module/amperity-cypress code changesLOG Running "Harvey" with {"rootTag":131,"initialProps":{}}
LOG shadow-cljs #77 ready!
BUNDLE ./index.js
LOG Running "Harvey" with {"rootTag":141,"initialProps":{}}
LOG shadow-cljs #78 ready!
BUNDLE ./index.js
LOG Running "Harvey" with {"rootTag":151,"initialProps":{}}
LOG shadow-cljs #79 ready!
BUNDLE ./index.js
LOG Running "Harvey" with {"rootTag":161,"initialProps":{}}
LOG shadow-cljs #80 ready!
BUNDLE ./index.js
LOG Running "Harvey" with {"rootTag":171,"initialProps":{}}
LOG shadow-cljs #81 ready!
BUNDLE ./index.js
LOG Running "Harvey" with {"rootTag":181,"initialProps":{}}
LOG shadow-cljs #82 ready!shadow.react-native/render-root isnt compatible with 0.71?reload-comp strategy in https://github.com/flexsurfer/rn-shadow-steroid is working fine.clj files to my project so I added a deps.edn and I am now using that to connect to a REPL. When I was still using shadow-cljs.edn I followed the recommended steps for developing with shadow-css at the REPL. Now that I'm using deps.edn, though, I'm having issues. When I connect with npx shadow-cljs clj repl and try to load the repl ns, it either cannot find shadow.css.build or the symbol update-vals from build.cljc is unresolved.:target :node-library support code-splitting / modules?:npm-module, but I think that might be a rather unsupported target, and I have no clue if it supports code splitting anyway.:node-library targets?:node-library does not support splitting, :npm-module is an option:modules but that seems to be ignored:advanced builds no:advanced optimization and :simple is good enough then this is doable, but still tricky and not supported out of the box[:app] Compiling ... Closure compilation failed with 1 errors --- metabase/domain_entities/queries/util.cljc:13and it's not clear from that line what the issue is. is there a flag to set or a hidden folder where I see the intermediate JS? (or the macroexpanded CLJS code?) there's a new, complex macro in play here, but it seems to be correct from playing around with
macroexpand.npx shadow-cljs release app directly showed me the error. but it was just "missing semicolon" which didn't help much.(let [defn# (defn ...)] (other things) defn#).shadow-cljs/builds/release/<the-build-id> foldersNoSuchFileException: out/js/main.jsWhen I change
:output-to to "out/js/main.js" it does work. Perhaps it's hardcoded?:browser buildsUncaught (in promise) Module not provided: @web3modal/ui
Thanks for your help 🙏.mjs files rather than .js files? I have a project which requires the entry point to be a cjs .js fileout directory?globalThis.joyride_vscode = require("vscode");
(for reasons...) and refer to it from CLJS as:
(def vscode js/joyride_vscode)and then do:
(vscode.window.showInputBox ...)how can I prevent advanced renaming these usages
global:joyride_vscode window showInputBox createOutputChannel showInformationMessagebut this gets a bit tedious
vscode.window.showInputBox may just loose the necessary type info, did you try with proper interop?(def ^js vscode js/joyride_vscode), although that should be inferred(.. vscode -window (showInputBox ...)) might work, although I remember something about .. not preserving typehints(:require ["vscode" :as vscode]) with the same interop(:require ["vscode" :as x]) x/window.showInputBox should properly infermodule.exports = globalThis.joyride_vscode;and then:
["/joyride/vscode.js" :as vscode]
Activating extension 'betterthantomorrow.joyride' failed: WebSocket is not defined.My workaround for this is:
globalThis.WebSocket = require("ws");
in the main wrapper, but I wonder if there's a better solutionws_file = require.resolve("ws");
if (ws_file != null) {
globalThis.WebSocket = require(ws_file);
}:target :esm assumes that it is executed in the browser runtime by default:runtime :node in the build config, but thats not implemented